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