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