Merge "Update annotations to spec for clamp"
[oom.git] / kubernetes / config / docker / init / src / config / robot / robot / resources / asdc_interface.robot
1 *** Settings ***
2 Documentation     The main interface for interacting with ASDC. It handles low level stuff like managing the http request library and DCAE required fields
3 Library               RequestsLibrary
4 Library           UUID
5 Library           JSONUtils
6 Library           OperatingSystem
7 Library           Collections
8 Library               ExtendedSelenium2Library
9 Resource          global_properties.robot
10 Resource          browser_setup.robot
11 Resource          json_templater.robot
12 *** Variables ***
13 ${ASDC_DESIGNER_USER_ID}    cs0008
14 ${ASDC_TESTER_USER_ID}    jm0007
15 ${ASDC_GOVERNOR_USER_ID}    gv0001
16 ${ASDC_OPS_USER_ID}    op0001
17 ${ASDC_HEALTH_CHECK_PATH}    /sdc1/rest/healthCheck
18 ${ASDC_VENDOR_LICENSE_MODEL_PATH}    /onboarding-api/v1.0/vendor-license-models
19 ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}    /onboarding-api/v1.0/vendor-software-products
20 ${ASDC_VENDOR_KEY_GROUP_PATH}    /license-key-groups
21 ${ASDC_VENDOR_ENTITLEMENT_POOL_PATH}    /entitlement-pools
22 ${ASDC_VENDOR_FEATURE_GROUP_PATH}    /feature-groups
23 ${ASDC_VENDOR_LICENSE_AGREEMENT_PATH}    /license-agreements
24 ${ASDC_VENDOR_ACTIONS_PATH}    /actions
25 ${ASDC_VENDOR_SOFTWARE_UPLOAD_PATH}    /orchestration-template-candidate
26 ${ASDC_CATALOG_RESOURCES_PATH}    /sdc2/rest/v1/catalog/resources
27 ${ASDC_CATALOG_SERVICES_PATH}    /sdc2/rest/v1/catalog/services
28 ${ASDC_CATALOG_INACTIVE_RESOURCES_PATH}    /sdc2/rest/v1/inactiveComponents/resource
29 ${ASDC_CATALOG_INACTIVE_SERVICES_PATH}    /sdc2/rest/v1/inactiveComponents/service
30 ${ASDC_CATALOG_LIFECYCLE_PATH}    /lifecycleState
31 ${ASDC_CATALOG_SERVICE_RESOURCE_INSTANCE_PATH}    /resourceInstance
32 ${ASDC_CATALOG_SERVICE_DISTRIBUTION_STATE_PATH}    /distribution-state
33 ${ASDC_CATALOG_SERVICE_DISTRIBUTION_PATH}    /distribution
34 ${ASDC_DISTRIBUTION_STATE_APPROVE_PATH}    /approve
35 ${ASDC_CATALOG_SERVICE_DISTRIBUTION_ACTIVATE_PATH}    /distribution/PROD/activate
36 ${ASDC_LICENSE_MODEL_TEMPLATE}    robot/assets/templates/asdc/license_model.template
37 ${ASDC_KEY_GROUP_TEMPLATE}    robot/assets/templates/asdc/key_group.template
38 ${ASDC_ENTITLEMENT_POOL_TEMPLATE}    robot/assets/templates/asdc/entitlement_pool.template
39 ${ASDC_FEATURE_GROUP_TEMPLATE}    robot/assets/templates/asdc/feature_group.template
40 ${ASDC_LICENSE_AGREEMENT_TEMPLATE}    robot/assets/templates/asdc/license_agreement.template
41 ${ASDC_ACTION_TEMPLATE}    robot/assets/templates/asdc/action.template
42 ${ASDC_SOFTWARE_PRODUCT_TEMPLATE}    robot/assets/templates/asdc/software_product.template
43 ${ASDC_CATALOG_RESOURCE_TEMPLATE}    robot/assets/templates/asdc/catalog_resource.template
44 ${ASDC_USER_REMARKS_TEMPLATE}    robot/assets/templates/asdc/user_remarks.template
45 ${ASDC_CATALOG_SERVICE_TEMPLATE}    robot/assets/templates/asdc/catalog_service.template
46 ${ASDC_RESOURCE_INSTANCE_TEMPLATE}    robot/assets/templates/asdc/resource_instance.template
47 ${ASDC_FE_ENDPOINT}     ${GLOBAL_ASDC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SDC_FE_IP_ADDR}:${GLOBAL_ASDC_FE_PORT}
48 ${ASDC_BE_ENDPOINT}     ${GLOBAL_ASDC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SDC_BE_IP_ADDR}:${GLOBAL_ASDC_BE_PORT}
49
50 *** Keywords ***
51 Distribute Model From ASDC
52     [Documentation]    goes end to end creating all the asdc objects based ona  model and distributing it to the systems. it then returns the service name, vf name and vf module name
53     [Arguments]    ${model_zip_path}   ${catalog_service_name}=
54     ${catalog_service_id}=    Add ASDC Catalog Service    ${catalog_service_name}
55     ${catalog_resource_ids}=    Create List
56     : FOR    ${zip}     IN     @{model_zip_path}
57     \    ${loop_catalog_resource_id}=    Setup ASDC Catalog Resource    ${zip}
58     \    Append To List    ${catalog_resource_ids}   ${loop_catalog_resource_id}
59     \    ${loop_catalog_resource_resp}=    Get ASDC Catalog Resource    ${loop_catalog_resource_id}
60     \    Add ASDC Resource Instance    ${catalog_service_id}    ${loop_catalog_resource_id}    ${loop_catalog_resource_resp['name']}
61     ${catalog_service_resp}=    Get ASDC Catalog Service    ${catalog_service_id}
62     Checkin ASDC Catalog Service    ${catalog_service_id}
63     Request Certify ASDC Catalog Service    ${catalog_service_id}
64     Start Certify ASDC Catalog Service    ${catalog_service_id}
65     # on certify it gets a new id
66     ${catalog_service_id}=    Certify ASDC Catalog Service    ${catalog_service_id}
67     Approve ASDC Catalog Service    ${catalog_service_id}
68         Distribute ASDC Catalog Service    ${catalog_service_id}
69         ${catalog_service_resp}=    Get ASDC Catalog Service    ${catalog_service_id}
70         ${vf_module}=    Find Element In Array    ${loop_catalog_resource_resp['groups']}    type    org.openecomp.groups.VfModule
71         Check Catalog Service Distributed    ${catalog_service_resp['uuid']}
72     [Return]    ${catalog_service_resp['name']}    ${loop_catalog_resource_resp['name']}    ${vf_module}   ${catalog_resource_ids}    ${catalog_service_id}
73     
74 Setup ASDC Catalog Resource
75     [Documentation]    Creates all the steps a vf needs for an asdc catalog resource and returns the id
76     [Arguments]    ${model_zip_path}
77     ${license_model_id}=    Add ASDC License Model
78     ${key_group_id}=    Add ASDC License Group    ${license_model_id}
79     ${pool_id}=    Add ASDC Entitlement Pool    ${license_model_id}
80     ${feature_group_id}=    Add ASDC Feature Group    ${license_model_id}    ${key_group_id}    ${pool_id}
81     ${license_agreement_id}=    Add ASDC License Agreement    ${license_model_id}    ${feature_group_id}
82     Checkin ASDC License Model    ${license_model_id}
83     Submit ASDC License Model    ${license_model_id}
84     ${license_model_resp}=    Get ASDC License Model    ${license_model_id}   1.0
85     ${software_product_id}=    Add ASDC Software Product    ${license_agreement_id}    ${feature_group_id}    ${license_model_resp['vendorName']}    ${license_model_id}
86     Upload ASDC Heat Package    ${software_product_id}    ${model_zip_path}
87     Validate ASDC Software Product    ${software_product_id}
88     Checkin ASDC Software Product    ${software_product_id}
89     Submit ASDC Software Product    ${software_product_id}
90     Package ASDC Software Product    ${software_product_id}
91     ${software_product_resp}=    Get ASDC Software Product    ${software_product_id}   1.0
92     ${catalog_resource_id}=    Add ASDC Catalog Resource     ${license_agreement_id}    ${software_product_resp['name']}    ${license_model_resp['vendorName']}    ${software_product_id}
93     Checkin ASDC Catalog Resource    ${catalog_resource_id}
94     Request Certify ASDC Catalog Resource    ${catalog_resource_id}
95     Start Certify ASDC Catalog Resource    ${catalog_resource_id}
96     # on certify it gets a new id
97     [Return]    ${catalog_resource_id}
98     ${catalog_resource_id}=    Certify ASDC Catalog Resource    ${catalog_resource_id}
99 Add ASDC License Model
100     [Documentation]    Creates an asdc license model and returns its id
101     ${uuid}=    Generate UUID
102     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
103     ${map}=    Create Dictionary    vendor_name=${shortened_uuid}
104     ${data}=   Fill JSON Template File    ${ASDC_LICENSE_MODEL_TEMPLATE}    ${map}
105     ${resp}=    Run ASDC Post Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}    ${data}
106     Should Be Equal As Strings  ${resp.status_code}     200
107     [Return]    ${resp.json()['value']}
108 Get ASDC License Model
109     [Documentation]    gets an asdc license model by its id
110     [Arguments]    ${id}   ${version_id}=0.1
111     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${id}/versions/${version_id}
112     [Return]    ${resp.json()}
113 Get ASDC License Models
114     [Documentation]    gets an asdc license model by its id
115     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}
116     [Return]    ${resp.json()}
117 Checkin ASDC License Model
118     [Documentation]    checksin an asdc license model by its id
119     [Arguments]    ${id}   ${version_id}=0.1
120     ${map}=    Create Dictionary    action=Checkin
121     ${data}=   Fill JSON Template File    ${ASDC_ACTION_TEMPLATE}    ${map}
122     ${resp}=    Run ASDC Put Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${id}/versions/${version_id}${ASDC_VENDOR_ACTIONS_PATH}    ${data}
123     Should Be Equal As Strings  ${resp.status_code}     200
124     [Return]    ${resp.json()}
125 Submit ASDC License Model
126     [Documentation]    submits an asdc license model by its id
127     [Arguments]    ${id}   ${version_id}=0.1
128     ${map}=    Create Dictionary    action=Submit
129     ${data}=   Fill JSON Template File    ${ASDC_ACTION_TEMPLATE}    ${map}
130     ${resp}=    Run ASDC Put Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${id}/versions/${version_id}${ASDC_VENDOR_ACTIONS_PATH}    ${data}
131     Should Be Equal As Strings  ${resp.status_code}     200
132     [Return]    ${resp.json()}
133 Checkin ASDC Software Product
134     [Documentation]    checksin an asdc Software Product by its id
135     [Arguments]    ${id}   ${version_id}=0.1
136     ${map}=    Create Dictionary    action=Checkin
137     ${data}=   Fill JSON Template File    ${ASDC_ACTION_TEMPLATE}    ${map}
138     ${resp}=    Run ASDC Put Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${id}/versions/${version_id}${ASDC_VENDOR_ACTIONS_PATH}    ${data}
139     Should Be Equal As Strings  ${resp.status_code}     200
140     [Return]    ${resp.json()}
141 Validate ASDC Software Product
142     [Documentation]    checksin an asdc Software Product by its id
143     [Arguments]    ${id}   ${version_id}=0.1
144     ${data}=   Catenate
145     ${resp}=    Run ASDC Put Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${id}/versions/${version_id}/orchestration-template-candidate/process    ${data}
146     Should Be Equal As Strings  ${resp.status_code}     200
147     [Return]    ${resp.json()}
148 Submit ASDC Software Product
149     [Documentation]    submits an asdc Software Product by its id
150     [Arguments]    ${id}   ${version_id}=0.1
151     ${map}=    Create Dictionary    action=Submit
152     ${data}=   Fill JSON Template File    ${ASDC_ACTION_TEMPLATE}    ${map}
153     ${resp}=    Run ASDC Put Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${id}/versions/${version_id}${ASDC_VENDOR_ACTIONS_PATH}    ${data}
154     Should Be Equal As Strings  ${resp.status_code}     200
155     [Return]    ${resp.json()}
156 Package ASDC Software Product
157     [Documentation]    creates_package on an asdc Software Product by its id
158     [Arguments]    ${id}   ${version_id}=0.1
159     ${map}=    Create Dictionary    action=Create_Package
160     ${data}=   Fill JSON Template File    ${ASDC_ACTION_TEMPLATE}    ${map}
161     ${resp}=    Run ASDC Put Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${id}/versions/${version_id}${ASDC_VENDOR_ACTIONS_PATH}    ${data}
162     Should Be Equal As Strings  ${resp.status_code}     200
163     [Return]    ${resp.json()}
164 Add ASDC Entitlement Pool
165     [Documentation]    Creates an asdc Entitlement Pool and returns its id
166     [Arguments]    ${license_model_id}   ${version_id}=0.1
167     ${uuid}=    Generate UUID
168     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
169     ${map}=    Create Dictionary    entitlement_pool_name=${shortened_uuid}
170     ${data}=   Fill JSON Template File    ${ASDC_ENTITLEMENT_POOL_TEMPLATE}    ${map}
171     ${resp}=    Run ASDC Post Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}/versions/${version_id}${ASDC_VENDOR_ENTITLEMENT_POOL_PATH}     ${data}
172     Should Be Equal As Strings  ${resp.status_code}     200
173     [Return]    ${resp.json()['value']}
174 Get ASDC Entitlement Pool
175     [Documentation]    gets an asdc Entitlement Pool by its id
176     [Arguments]    ${license_model_id}    ${pool_id}
177     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}${ASDC_VENDOR_ENTITLEMENT_POOL_PATH}/${pool_id}
178     [Return]    ${resp.json()}
179 Add ASDC License Group
180     [Documentation]    Creates an asdc license group and returns its id
181     [Arguments]    ${license_model_id}   ${version_id}=0.1
182     ${uuid}=    Generate UUID
183     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
184     ${map}=    Create Dictionary    key_group_name=${shortened_uuid}
185     ${data}=   Fill JSON Template File    ${ASDC_KEY_GROUP_TEMPLATE}    ${map}
186     ${resp}=    Run ASDC Post Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}/versions/${version_id}${ASDC_VENDOR_KEY_GROUP_PATH}     ${data}
187     Should Be Equal As Strings  ${resp.status_code}     200
188     [Return]    ${resp.json()['value']}
189 Get ASDC License Group
190     [Documentation]    gets an asdc license group by its id
191     [Arguments]    ${license_model_id}    ${group_id}      ${version_id}
192     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}/versions/${version_id}${ASDC_VENDOR_KEY_GROUP_PATH}/${group_id}
193     [Return]    ${resp.json()}
194 Add ASDC Feature Group
195     [Documentation]    Creates an asdc Feature Group and returns its id
196     [Arguments]    ${license_model_id}    ${key_group_id}    ${entitlement_pool_id}      ${version_id}=0.1
197     ${uuid}=    Generate UUID
198     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
199     ${map}=    Create Dictionary    feature_group_name=${shortened_uuid}    key_group_id=${key_group_id}    entitlement_pool_id=${entitlement_pool_id}   manufacturer_reference_number=mrn${shortened_uuid}
200     ${data}=   Fill JSON Template File    ${ASDC_FEATURE_GROUP_TEMPLATE}    ${map}
201     ${resp}=    Run ASDC Post Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}/versions/${version_id}${ASDC_VENDOR_FEATURE_GROUP_PATH}     ${data}
202     Should Be Equal As Strings  ${resp.status_code}     200
203     [Return]    ${resp.json()['value']}
204 Get ASDC Feature Group
205     [Documentation]    gets an asdc Feature Group by its id
206     [Arguments]    ${license_model_id}    ${group_id}
207     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}${ASDC_VENDOR_FEATURE_GROUP_PATH}/${group_id}
208     [Return]    ${resp.json()}
209 Add ASDC License Agreement
210     [Documentation]    Creates an asdc License Agreement and returns its id
211     [Arguments]    ${license_model_id}    ${feature_group_id}      ${version_id}=0.1
212     ${uuid}=    Generate UUID
213     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
214     ${map}=    Create Dictionary    license_agreement_name=${shortened_uuid}    feature_group_id=${feature_group_id}
215     ${data}=   Fill JSON Template File    ${ASDC_LICENSE_AGREEMENT_TEMPLATE}    ${map}
216     ${resp}=    Run ASDC Post Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}/versions/${version_id}${ASDC_VENDOR_LICENSE_AGREEMENT_PATH}     ${data}
217     Should Be Equal As Strings  ${resp.status_code}     200
218     [Return]    ${resp.json()['value']}
219 Get ASDC License Agreement
220     [Documentation]    gets an asdc License Agreement by its id
221     [Arguments]    ${license_model_id}    ${agreement_id}
222     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}${ASDC_VENDOR_LICENSE_AGREEMENT_PATH}/${agreement_id}
223     [Return]    ${resp.json()}
224 Add ASDC Software Product
225     [Documentation]    Creates an asdc Software Product and returns its id
226     [Arguments]    ${license_agreement_id}    ${feature_group_id}    ${license_model_name}    ${license_model_id}
227     ${uuid}=    Generate UUID
228     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
229     ${map}=    Create Dictionary    software_product_name=${shortened_uuid}    feature_group_id=${feature_group_id}    license_agreement_id=${license_agreement_id}    vendor_name=${license_model_name}    vendor_id=${license_model_id}
230     ${data}=   Fill JSON Template File    ${ASDC_SOFTWARE_PRODUCT_TEMPLATE}    ${map}
231     ${resp}=    Run ASDC Post Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}     ${data}
232     Should Be Equal As Strings  ${resp.status_code}     200
233     [Return]    ${resp.json()['vspId']}
234 Get ASDC Software Product
235     [Documentation]    gets an asdc Software Product by its id
236     [Arguments]    ${software_product_id}   ${version_id}=0.1
237     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${software_product_id}/versions/${version_id}
238     [Return]    ${resp.json()}
239 Add ASDC Catalog Resource
240     [Documentation]    Creates an asdc Catalog Resource and returns its id
241     [Arguments]    ${license_agreement_id}    ${software_product_name}    ${license_model_name}    ${software_product_id}
242     ${map}=    Create Dictionary    software_product_id=${software_product_id}    software_product_name=${software_product_name}    license_agreement_id=${license_agreement_id}    vendor_name=${license_model_name}
243     ${data}=   Fill JSON Template File    ${ASDC_CATALOG_RESOURCE_TEMPLATE}    ${map}
244     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}
245     Should Be Equal As Strings  ${resp.status_code}     201
246     [Return]    ${resp.json()['uniqueId']}
247 Mark ASDC Catalog Resource Inactive
248     [Documentation]    deletes an asdc Catalog Resource
249     [Arguments]    ${catalog_resource_id}
250     ${resp}=    Run ASDC Delete Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}     ${ASDC_DESIGNER_USER_ID}
251     Should Be Equal As Strings  ${resp.status_code}     204
252     [Return]    ${resp}
253 Delete Inactive ASDC Catalog Resources
254     [Documentation]    delete all asdc Catalog Resources that are inactive
255     ${resp}=    Run ASDC Delete Request    ${ASDC_CATALOG_INACTIVE_RESOURCES_PATH}     ${ASDC_DESIGNER_USER_ID}
256     Should Be Equal As Strings  ${resp.status_code}     200
257     [Return]    ${resp.json()}
258 Get ASDC Catalog Resource
259     [Documentation]    gets an asdc Catalog Resource by its id
260     [Arguments]    ${catalog_resource_id}
261     ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}    ${ASDC_DESIGNER_USER_ID}
262     [Return]    ${resp.json()}
263 Checkin ASDC Catalog Resource
264     [Documentation]    checksin an asdc Catalog Resource by its id
265     [Arguments]    ${catalog_resource_id}
266     ${map}=    Create Dictionary    user_remarks=Robot remarks
267     ${data}=   Fill JSON Template File    ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
268     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/checkin    ${data}    ${ASDC_DESIGNER_USER_ID}
269     Should Be Equal As Strings  ${resp.status_code}     200
270     [Return]    ${resp.json()}
271 Request Certify ASDC Catalog Resource
272     [Documentation]    requests certify on an asdc Catalog Resource by its id
273     [Arguments]    ${catalog_resource_id}
274     ${map}=    Create Dictionary    user_remarks=Robot remarks
275     ${data}=   Fill JSON Template File    ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
276     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certificationRequest    ${data}    ${ASDC_DESIGNER_USER_ID}
277     Should Be Equal As Strings  ${resp.status_code}     200
278     [Return]    ${resp.json()}
279 Start Certify ASDC Catalog Resource
280     [Documentation]    start certify an asdc Catalog Resource by its id
281     [Arguments]    ${catalog_resource_id}
282     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/startCertification    ${None}    ${ASDC_TESTER_USER_ID}
283     Should Be Equal As Strings  ${resp.status_code}     200
284     [Return]    ${resp.json()}
285 Certify ASDC Catalog Resource
286     [Documentation]    start certify an asdc Catalog Resource by its id and returns the new id
287     [Arguments]    ${catalog_resource_id}
288     ${map}=    Create Dictionary    user_remarks=Robot remarks
289     ${data}=   Fill JSON Template File    ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
290     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certify    ${data}    ${ASDC_TESTER_USER_ID}
291     Should Be Equal As Strings  ${resp.status_code}     200
292     [Return]    ${resp.json()['uniqueId']}
293
294 Upload ASDC Heat Package
295     [Documentation]    Creates an asdc Software Product and returns its id
296     [Arguments]    ${software_product_id}    ${file_path}   ${version_id}=0.1
297      ${files}=     Create Dictionary
298      Create Multi Part     ${files}  upload  ${file_path}    contentType=application/zip
299     ${resp}=    Run ASDC Post Files Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${software_product_id}/versions/${version_id}${ASDC_VENDOR_SOFTWARE_UPLOAD_PATH}     ${files}    ${ASDC_DESIGNER_USER_ID}
300         Should Be Equal As Strings      ${resp.status_code}     200
301
302 Add ASDC Catalog Service
303     [Documentation]    Creates an asdc Catalog Service and returns its id
304     [Arguments]   ${catalog_service_name}
305     ${uuid}=    Generate UUID
306     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
307     ${catalog_service_name}=   Set Variable If   '${catalog_service_name}' ==''   ${shortened_uuid}   ${catalog_service_name}
308     ${map}=    Create Dictionary    service_name=${catalog_service_name}
309     ${data}=   Fill JSON Template File    ${ASDC_CATALOG_SERVICE_TEMPLATE}    ${map}
310     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}
311     Should Be Equal As Strings  ${resp.status_code}     201
312     [Return]    ${resp.json()['uniqueId']}
313 Mark ASDC Catalog Service Inactive
314     [Documentation]    Deletes an asdc Catalog Service
315     [Arguments]    ${catalog_service_id}
316     ${resp}=    Run ASDC Delete Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}     ${ASDC_DESIGNER_USER_ID}
317     Should Be Equal As Strings  ${resp.status_code}     204
318     [Return]    ${resp}
319 Delete Inactive ASDC Catalog Services
320     [Documentation]    delete all asdc Catalog Serivces that are inactive
321     ${resp}=    Run ASDC Delete Request    ${ASDC_CATALOG_INACTIVE_SERVICES_PATH}     ${ASDC_DESIGNER_USER_ID}
322     Should Be Equal As Strings  ${resp.status_code}     200
323     [Return]    ${resp.json()}
324 Get ASDC Catalog Service
325     [Documentation]    gets an asdc Catalog Service by its id
326     [Arguments]    ${catalog_service_id}
327     ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}    ${ASDC_DESIGNER_USER_ID}
328     [Return]    ${resp.json()}
329 Checkin ASDC Catalog Service
330     [Documentation]    checksin an asdc Catalog Service by its id
331     [Arguments]    ${catalog_service_id}
332     ${map}=    Create Dictionary    user_remarks=Robot remarks
333     ${data}=   Fill JSON Template File    ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
334     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/checkin    ${data}    ${ASDC_DESIGNER_USER_ID}
335     Should Be Equal As Strings  ${resp.status_code}     200
336     [Return]    ${resp.json()}
337 Request Certify ASDC Catalog Service
338     [Documentation]    requests certify on an asdc Catalog Service by its id
339     [Arguments]    ${catalog_service_id}
340     ${map}=    Create Dictionary    user_remarks=Robot remarks
341     ${data}=   Fill JSON Template File    ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
342     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certificationRequest    ${data}    ${ASDC_DESIGNER_USER_ID}
343     Should Be Equal As Strings  ${resp.status_code}     200
344     [Return]    ${resp.json()}
345 Start Certify ASDC Catalog Service
346     [Documentation]    start certify an asdc Catalog Service by its id
347     [Arguments]    ${catalog_service_id}
348     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/startCertification    ${None}    ${ASDC_TESTER_USER_ID}
349     Should Be Equal As Strings  ${resp.status_code}     200
350     [Return]    ${resp.json()}
351 Certify ASDC Catalog Service
352     [Documentation]    start certify an asdc Catalog Service by its id and returns the new id
353     [Arguments]    ${catalog_service_id}
354     ${map}=    Create Dictionary    user_remarks=Robot remarks
355     ${data}=   Fill JSON Template File    ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
356     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certify    ${data}    ${ASDC_TESTER_USER_ID}
357     Should Be Equal As Strings  ${resp.status_code}     200
358     [Return]    ${resp.json()['uniqueId']}
359 Approve ASDC Catalog Service
360     [Documentation]    approve an asdc Catalog Service by its id
361     [Arguments]    ${catalog_service_id}
362     ${map}=    Create Dictionary    user_remarks=Robot remarks
363     ${data}=   Fill JSON Template File    ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
364     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_SERVICE_DISTRIBUTION_STATE_PATH}${ASDC_DISTRIBUTION_STATE_APPROVE_PATH}    ${data}    ${ASDC_GOVERNOR_USER_ID}
365     Should Be Equal As Strings  ${resp.status_code}     200
366     [Return]    ${resp.json()}
367 Distribute ASDC Catalog Service
368     [Documentation]    distribute an asdc Catalog Service by its id
369     [Arguments]    ${catalog_service_id}
370     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_SERVICE_DISTRIBUTION_ACTIVATE_PATH}    ${None}    ${ASDC_OPS_USER_ID}
371     Should Be Equal As Strings  ${resp.status_code}     200
372     [Return]    ${resp.json()}
373 Add ASDC Resource Instance
374     [Documentation]    Creates an asdc Resource Instance and returns its id
375     [Arguments]    ${catalog_service_id}    ${catalog_resource_id}    ${catalog_resource_name}
376     ${milli_timestamp}=    Generate MilliTimestamp UUID
377     ${map}=    Create Dictionary    catalog_resource_id=${catalog_resource_id}    catalog_resource_name=${catalog_resource_name}    milli_timestamp=${milli_timestamp}
378     ${data}=   Fill JSON Template File    ${ASDC_RESOURCE_INSTANCE_TEMPLATE}    ${map}
379     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_SERVICE_RESOURCE_INSTANCE_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}
380     Should Be Equal As Strings  ${resp.status_code}     201
381     [Return]    ${resp.json()['uniqueId']}
382 Get Catalog Service Distribution
383     [Documentation]    gets an asdc catalog Service distrbution
384     [Arguments]    ${catalog_service_uuid}
385     ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_uuid}${ASDC_CATALOG_SERVICE_DISTRIBUTION_PATH}    ${ASDC_OPS_USER_ID}
386     Should Be Equal As Strings  ${resp.status_code}     200
387     [Return]    ${resp.json()}
388 Check Catalog Service Distributed
389     [Documentation]    gets an asdc catalog Service distrbution
390     [Arguments]    ${catalog_service_uuid}
391     ${dist_resp}=    Get Catalog Service Distribution    ${catalog_service_uuid}
392     Should Be Equal As Strings  ${dist_resp['distributionStatusOfServiceList'][0]['deployementStatus']}         Distributed
393     ${det_resp}=    Get Catalog Service Distribution Details    ${dist_resp['distributionStatusOfServiceList'][0]['distributionID']}
394     @{ITEMS}=    Copy List    ${det_resp['distributionStatusList']}
395     :FOR    ${ELEMENT}    IN    @{ITEMS}
396     \    Log    ${ELEMENT['status']}
397     \    Should Match Regexp    ${ELEMENT['status']}    ^(DEPLOY_OK|NOTIFIED|DOWNLOAD_OK|NOT_NOTIFIED)$
398 Get Catalog Service Distribution Details
399     [Documentation]    gets an asdc catalog Service distrbution details
400     [Arguments]    ${catalog_service_distribution_id}
401     ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}${ASDC_CATALOG_SERVICE_DISTRIBUTION_PATH}/${catalog_service_distribution_id}    ${ASDC_OPS_USER_ID}
402     Should Be Equal As Strings  ${resp.status_code}     200
403     [Return]    ${resp.json()}
404 Run ASDC Health Check
405     [Documentation]    Runs a ASDC health check
406     ${session}=    Create Session       asdc    ${ASDC_FE_ENDPOINT}
407     ${uuid}=    Generate UUID
408     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
409     ${resp}=    Get Request     asdc    ${ASDC_HEALTH_CHECK_PATH}     headers=${headers}
410     Should Be Equal As Strings  ${resp.status_code}     200
411     @{ITEMS}=    Copy List    ${resp.json()['componentsInfo']}
412     :FOR    ${ELEMENT}    IN    @{ITEMS}
413     \    Log    ${ELEMENT['healthCheckStatus']}
414     \    Should Be Equal As Strings     ${ELEMENT['healthCheckStatus']}         UP
415 Run ASDC Get Request
416     [Documentation]    Runs an ASDC get request
417     [Arguments]    ${data_path}    ${user}=${ASDC_DESIGNER_USER_ID}
418     ${auth}=  Create List  ${GLOBAL_ASDC_BE_USERNAME}    ${GLOBAL_ASDC_BE_PASSWORD}
419     Log    Creating session ${ASDC_BE_ENDPOINT}
420     ${session}=    Create Session       asdc    ${ASDC_BE_ENDPOINT}    auth=${auth}
421     ${uuid}=    Generate UUID
422     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    USER_ID=${user}    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
423     ${resp}=    Get Request     asdc    ${data_path}     headers=${headers}
424     Log    Received response from asdc ${resp.text}
425     [Return]    ${resp}
426 Run ASDC Put Request
427     [Documentation]    Runs an ASDC put request
428     [Arguments]    ${data_path}    ${data}    ${user}=${ASDC_DESIGNER_USER_ID}
429     ${auth}=  Create List  ${GLOBAL_ASDC_BE_USERNAME}    ${GLOBAL_ASDC_BE_PASSWORD}
430     Log    Creating session ${ASDC_BE_ENDPOINT}
431     ${session}=    Create Session       asdc    ${ASDC_BE_ENDPOINT}    auth=${auth}
432     ${uuid}=    Generate UUID
433     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    USER_ID=${user}    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
434     ${resp}=    Put Request     asdc    ${data_path}     data=${data}    headers=${headers}
435     Log    Received response from asdc ${resp.text}
436     [Return]    ${resp}
437
438 Run ASDC Post Files Request
439     [Documentation]    Runs an ASDC post request
440     [Arguments]    ${data_path}    ${files}    ${user}=${ASDC_DESIGNER_USER_ID}
441     ${auth}=  Create List  ${GLOBAL_ASDC_BE_USERNAME}    ${GLOBAL_ASDC_BE_PASSWORD}
442     Log    Creating session ${ASDC_BE_ENDPOINT}
443     ${session}=    Create Session       asdc    ${ASDC_BE_ENDPOINT}    auth=${auth}
444     ${uuid}=    Generate UUID
445     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=multipart/form-data    USER_ID=${user}    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
446     ${resp}=    Post Request    asdc    ${data_path}     files=${files}    headers=${headers}
447     Log    Received response from asdc ${resp.text}
448     [Return]    ${resp}
449
450 Run ASDC Post Request
451     [Documentation]    Runs an ASDC post request
452     [Arguments]    ${data_path}    ${data}    ${user}=${ASDC_DESIGNER_USER_ID}
453     ${auth}=  Create List  ${GLOBAL_ASDC_BE_USERNAME}    ${GLOBAL_ASDC_BE_PASSWORD}
454     Log    Creating session ${ASDC_BE_ENDPOINT}
455     ${session}=    Create Session       asdc    ${ASDC_BE_ENDPOINT}    auth=${auth}
456     ${uuid}=    Generate UUID
457     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    USER_ID=${user}    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
458     ${resp}=    Post Request    asdc    ${data_path}     data=${data}    headers=${headers}
459     Log    Received response from asdc ${resp.text}
460     [Return]    ${resp}
461 Run ASDC Delete Request
462     [Documentation]    Runs an ASDC delete request
463     [Arguments]    ${data_path}    ${user}=${ASDC_DESIGNER_USER_ID}
464     ${auth}=  Create List  ${GLOBAL_ASDC_BE_USERNAME}    ${GLOBAL_ASDC_BE_PASSWORD}
465     Log    Creating session ${ASDC_BE_ENDPOINT}
466     ${session}=    Create Session       asdc    ${ASDC_BE_ENDPOINT}    auth=${auth}
467     ${uuid}=    Generate UUID
468     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    USER_ID=${user}    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
469     ${resp}=    Delete Request  asdc    ${data_path}        headers=${headers}
470     Log    Received response from asdc ${resp.text}
471     [Return]    ${resp}
472 Open ASDC GUI
473     [Documentation]   Logs in to ASDC GUI
474     [Arguments]    ${PATH}
475     ## Setup Browever now being managed by the test case
476     ##Setup Browser
477     Go To    ${ASDC_FE_ENDPOINT}${PATH}
478     Maximize Browser Window
479
480     Set Browser Implicit Wait    ${GLOBAL_SELENIUM_BROWSER_IMPLICIT_WAIT}
481     Log    Logging in to ${ASDC_FE_ENDPOINT}${PATH}
482     Title Should Be    ASDC
483     Wait Until Page Contains Element    xpath=//div/a[text()='SDC']    ${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT}
484     Log    Logged in to ${ASDC_FE_ENDPOINT}${PATH}
485
486
487 Create Multi Part
488    [Arguments]  ${addTo}  ${partName}  ${filePath}  ${contentType}=${None}
489    ${fileData}=   Get Binary File  ${filePath}
490    ${fileDir}  ${fileName}=  Split Path  ${filePath}
491    ${partData}=  Create List  ${fileName}  ${fileData}  ${contentType}
492    Set To Dictionary  ${addTo}  ${partName}=${partData}