70727d95516fada1a19ef64c7544da34b1d48779
[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}    /orchestration-template-candidate
26 ${ASDC_FE_CATALOG_RESOURCES_PATH}    /sdc1/feProxy/rest/v1/catalog/resources
27 ${ASDC_FE_CATALOG_SERVICES_PATH}    /sdc1/feProxy/rest/v1/catalog/services
28 ${ASDC_CATALOG_RESOURCES_PATH}    /sdc2/rest/v1/catalog/resources
29 ${ASDC_CATALOG_SERVICES_PATH}    /sdc2/rest/v1/catalog/services
30 ${ASDC_CATALOG_INACTIVE_RESOURCES_PATH}    /sdc2/rest/v1/inactiveComponents/resource
31 ${ASDC_CATALOG_RESOURCES_QUERY_PATH}    /sdc2/rest/v1/catalog/resources/resourceName
32 ${ASDC_CATALOG_INACTIVE_SERVICES_PATH}    /sdc2/rest/v1/inactiveComponents/service
33 ${ASDC_CATALOG_LIFECYCLE_PATH}    /lifecycleState
34 ${ASDC_CATALOG_SERVICE_RESOURCE_INSTANCE_PATH}    /resourceInstance
35 ${ASDC_CATALOG_SERVICE_DISTRIBUTION_STATE_PATH}    /distribution-state
36 ${ASDC_CATALOG_SERVICE_DISTRIBUTION_PATH}    /distribution
37 ${ASDC_DISTRIBUTION_STATE_APPROVE_PATH}    /approve
38 ${ASDC_CATALOG_SERVICE_DISTRIBUTION_ACTIVATE_PATH}    /distribution/PROD/activate
39 ${ASDC_LICENSE_MODEL_TEMPLATE}    robot/assets/templates/asdc/license_model.template
40 ${ASDC_KEY_GROUP_TEMPLATE}    robot/assets/templates/asdc/key_group.template
41 ${ASDC_ENTITLEMENT_POOL_TEMPLATE}    robot/assets/templates/asdc/entitlement_pool.template
42 ${ASDC_FEATURE_GROUP_TEMPLATE}    robot/assets/templates/asdc/feature_group.template
43 ${ASDC_LICENSE_AGREEMENT_TEMPLATE}    robot/assets/templates/asdc/license_agreement.template
44 ${ASDC_ACTION_TEMPLATE}    robot/assets/templates/asdc/action.template
45 ${ASDC_SOFTWARE_PRODUCT_TEMPLATE}    robot/assets/templates/asdc/software_product.template
46 ${ASDC_CATALOG_RESOURCE_TEMPLATE}    robot/assets/templates/asdc/catalog_resource.template
47 ${ASDC_USER_REMARKS_TEMPLATE}    robot/assets/templates/asdc/user_remarks.template
48 ${ASDC_CATALOG_SERVICE_TEMPLATE}    robot/assets/templates/asdc/catalog_service.template
49 ${ASDC_RESOURCE_INSTANCE_TEMPLATE}    robot/assets/templates/asdc/resource_instance.template
50 ${ASDC_RESOURCE_INSTANCE_VNF_PROPERTIES_TEMPLATE}    robot/assets/templates/asdc/catalog_vnf_properties.template
51 ${ASDC_RESOURCE_INSTANCE_VNF_INPUTS_TEMPLATE}    robot/assets/templates/asdc/catalog_vnf_inputs.template
52 ${SDC_CATALOG_NET_RESOURCE_INPUT_TEMPLATE}    robot/assets/templates/asdc/catalog_net_input_properties.template
53 ${ASDC_FE_ENDPOINT}     ${GLOBAL_ASDC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SDC_FE_IP_ADDR}:${GLOBAL_ASDC_FE_PORT}
54 ${ASDC_BE_ENDPOINT}     ${GLOBAL_ASDC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SDC_BE_IP_ADDR}:${GLOBAL_ASDC_BE_PORT}
55 ${ASDC_BE_ONBOARD_ENDPOINT}     ${GLOBAL_ASDC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SDC_BE_ONBOARD_IP_ADDR}:${GLOBAL_ASDC_BE_ONBOARD_PORT}
56
57 *** Keywords ***
58 Distribute Model From ASDC
59     [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
60     [Arguments]    ${model_zip_path}   ${catalog_service_name}=    ${cds}=    ${service}=
61     #${random}=    Get Current Date
62     #${catalog_service_id}=    Add ASDC Catalog Service    ${catalog_service_name}_${random}
63     ${catalog_service_id}=    Add ASDC Catalog Service    ${catalog_service_name}
64     ${catalog_resource_ids}=    Create List
65     ${catalog_resources}=   Create Dictionary
66     : FOR    ${zip}     IN     @{model_zip_path}
67     \    ${loop_catalog_resource_id}=    Setup ASDC Catalog Resource    ${zip}    ${cds}
68     \    Append To List    ${catalog_resource_ids}   ${loop_catalog_resource_id}
69     \    ${loop_catalog_resource_resp}=    Get ASDC Catalog Resource    ${loop_catalog_resource_id}
70     \    Add ASDC Resource Instance    ${catalog_service_id}    ${loop_catalog_resource_id}    ${loop_catalog_resource_resp['name']}
71     \    Set To Dictionary    ${catalog_resources}   ${loop_catalog_resource_id}=${loop_catalog_resource_resp}
72     #
73     # do this here because the loop_catalog_resource_resp is different format after adding networks
74     ${vf_module}=   Find Element In Array    ${loop_catalog_resource_resp['groups']}    type    org.openecomp.groups.VfModule
75     #
76     #  do network
77     ${networklist}=   Get From Dictionary    ${GLOBAL_SERVICE_GEN_NEUTRON_NETWORK_MAPPING}    ${service}
78     ${xoffset}=    Set Variable    ${100}
79     ${generic_neutron_net_uuid}=   Get Generic NeutronNet UUID
80     :FOR   ${network}   in   @{networklist}
81     \    ${loop_catalog_resource_id}=   Set Variable    ${generic_neutron_net_uuid}
82     \    Append To List    ${catalog_resource_ids}   ${loop_catalog_resource_id}
83     \    ${loop_catalog_resource_resp}=    Get ASDC Catalog Resource    ${loop_catalog_resource_id}
84     #
85     \    ${loop_catalog_resource_id}=   Add ASDC Resource Instance    ${catalog_service_id}    ${loop_catalog_resource_id}    ${network}    ${xoffset}      ${0}
86     \    ${nf_role}=   Convert To Lowercase   ${network}
87     \    Setup SDC Catalog Resource GenericNeutronNet Properties      ${catalog_service_id}    ${nf_role}   ${loop_catalog_resource_id}
88     \    ${xoffset}=   Set Variable   ${xoffset+100}
89     \    Set To Dictionary    ${catalog_resources}   ${loop_catalog_resource_id}=${loop_catalog_resource_resp}
90     #
91     ${catalog_service_resp}=    Get ASDC Catalog Service    ${catalog_service_id}
92     Checkin ASDC Catalog Service    ${catalog_service_id}
93     Request Certify ASDC Catalog Service    ${catalog_service_id}
94     Start Certify ASDC Catalog Service    ${catalog_service_id}
95     # on certify it gets a new id
96     ${catalog_service_id}=    Certify ASDC Catalog Service    ${catalog_service_id}
97     Approve ASDC Catalog Service    ${catalog_service_id}
98         : FOR   ${DIST_INDEX}    IN RANGE   1
99         \   Log     Distribution Attempt ${DIST_INDEX}
100         \   Distribute ASDC Catalog Service    ${catalog_service_id}
101         \   ${catalog_service_resp}=    Get ASDC Catalog Service    ${catalog_service_id}
102         \   ${status}   ${_} =   Run Keyword And Ignore Error   Loop Over Check Catalog Service Distributed       ${catalog_service_resp['uuid']}
103         \   Exit For Loop If   '${status}'=='PASS'
104         Should Be Equal As Strings  ${status}  PASS
105     [Return]    ${catalog_service_resp['name']}    ${loop_catalog_resource_resp['name']}    ${vf_module}   ${catalog_resource_ids}    ${catalog_service_id}   ${catalog_resources}
106
107 Download CSAR
108    [Documentation]   Download CSAR 
109    [Arguments]    ${catalog_service_id}    ${save_directory}=/tmp/csar
110    # get meta data
111    ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}/filteredDataByParams?include=toscaArtifacts    ${ASDC_DESIGNER_USER_ID}    ${ASDC_BE_ENDPOINT}
112    ${csar_resource_id}=    Set Variable   ${resp.json()['toscaArtifacts']['assettoscacsar']['uniqueId']}
113    ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}/artifacts/${csar_resource_id}
114    ${csar_file_name}=   Set Variable    ${resp.json()['artifactName']}
115    ${base64Obj}=   Set Variable    ${resp.json()['base64Contents']}
116    ${binObj}=   Evaluate   base64.b64decode("${base64Obj}")   modules=base64
117    Create Binary File  ${save_directory}/${csar_file_name}  ${binObj}
118    Log To Console      Downloaded:${csar_file_name} 
119    [Return]
120
121
122 Get Generic NeutronNet UUID
123    [Documentation]   Lookoup the UUID of the Generic NeutronNetwork Resource
124    # http://137.117.87.170:30205/sdc2/rest/v1/catalog/resources/resourceName/Generic%20NeutronNet/resourceVersion/1.0
125    #  411edcfd-c290-41dc-bd2c-5600f9f0af05
126    ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_RESOURCES_QUERY_PATH}/Generic%20NeutronNet/resourceVersion/1.0   ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ENDPOINT}
127    [Return]    ${resp.json()['allVersions']['1.0']}
128
129 Loop Over Check Catalog Service Distributed
130     [Arguments]    ${catalog_service_id}
131     # SO watchdog timeout is 300 seconds need buffer
132     ${dist_status}=   Set Variable    FAIL
133     : FOR     ${CHECK_INDEX}  IN RANGE   20
134     \   ${status}   ${_} =   Run Keyword And Ignore Error     Check Catalog Service Distributed    ${catalog_service_id}    ${dist_status}
135     \   Sleep     20s
136     \   Return From Keyword If   '${status}'=='PASS'
137     \   Exit For Loop If   '${dist_status}'=='EXIT'
138     Should Be Equal As Strings  ${status}   PASS 
139
140 Setup ASDC Catalog Resource
141     [Documentation]    Creates all the steps a vf needs for an asdc catalog resource and returns the id
142     [Arguments]    ${model_zip_path}    ${cds}=
143     ${license_model_id}   ${license_model_version_id}=    Add ASDC License Model
144     ${key_group_id}=    Add ASDC License Group    ${license_model_id}   ${license_model_version_id}
145     ${pool_id}=    Add ASDC Entitlement Pool    ${license_model_id}   ${license_model_version_id}
146     ${feature_group_id}=    Add ASDC Feature Group    ${license_model_id}    ${key_group_id}    ${pool_id}  ${license_model_version_id}
147     ${license_agreement_id}=    Add ASDC License Agreement    ${license_model_id}    ${feature_group_id}   ${license_model_version_id}
148     Submit ASDC License Model    ${license_model_id}   ${license_model_version_id}
149     ${license_model_resp}=    Get ASDC License Model    ${license_model_id}   ${license_model_version_id}
150     ${software_product_id}   ${software_product_version_id}=    Add ASDC Software Product    ${license_agreement_id}    ${feature_group_id}    ${license_model_resp['vendorName']}    ${license_model_id}    ${license_model_version_id}
151     Upload ASDC Heat Package    ${software_product_id}    ${model_zip_path}   ${software_product_version_id}
152     Validate ASDC Software Product    ${software_product_id}  ${software_product_version_id}
153     Submit ASDC Software Product    ${software_product_id}  ${software_product_version_id}
154     Package ASDC Software Product    ${software_product_id}   ${software_product_version_id}
155     ${software_product_resp}=    Get ASDC Software Product    ${software_product_id}    ${software_product_version_id}
156     ${catalog_resource_id}=    Add ASDC Catalog Resource     ${license_agreement_id}    ${software_product_resp['name']}    ${license_model_resp['vendorName']}    ${software_product_id}  
157     # Check if need to set up CDS properties
158     Run Keyword If    '${cds}' == 'vfwng'    Setup ASDC Catalog Resource CDS Properties    ${catalog_resource_id}
159     
160     ${catalog_resource_id}=   Certify ASDC Catalog Resource    ${catalog_resource_id}  ${ASDC_DESIGNER_USER_ID}
161     [Return]    ${catalog_resource_id}
162
163 Setup SDC Catalog Resource GenericNeutronNet Properties
164     [Documentation]    Set up GenericNeutronNet properties and inputs 
165     [Arguments]    ${catalog_service_id}    ${nf_role}    ${catalog_parent_service_id}
166     # Set component instances properties 
167     ${resp}=    Get ASDC Catalog Resource Component Instances Properties  ${catalog_service_id}
168     #${resp}=    Get ASDC Catalog Resource Component Instances    ${catalog_service_id}
169     ${componentInstances}  Set Variable   @{resp['componentInstancesProperties']}
170     # componentInstances can have 1 or more than 1 entry
171     ${passed}=    Run Keyword And Return Status   Evaluate    type(${componentInstances})
172     ${type}=      Run Keyword If     ${passed}    Evaluate    type(${componentInstances})
173     ${componentInstancesList}=    Run Keyword If   "${type}"!="<type 'list'>"    Create List  ${componentInstances}
174     ...    ELSE   Set Variable    ${componentInstances}
175     :FOR   ${item}  IN   @{componentInstancesList}
176     \    ${test}    ${v}=    Run Keyword and Ignore Error    Should Contain    ${item}     ${nf_role}
177     \    Run Keyword If    '${test}' == 'FAIL'    Continue For Loop
178     \    ${componentInstance1}=   Set Variable    ${item}
179     :FOR    ${comp}    IN    @{resp['componentInstancesProperties']["${componentInstance1}"]}
180     \    ${name}    Set Variable   ${comp['name']}
181     \    ${test}    ${v}=    Run Keyword and Ignore Error    Should Contain    ${name}    network_role
182     \    Run Keyword If    '${test}' == 'FAIL'    Continue For Loop
183     \    ${description}    Set Variable    ${comp['description']}
184     \    ${description}=    Replace String    ${description}    ${\n}   \
185     \    ${uniqueId}    Set Variable    ${comp['uniqueId']}
186     \    ${parentUniqueId}    Set Variable    ${comp['parentUniqueId']}
187     \    ${ownerId}    Set Variable    ${comp['ownerId']}
188     \    ${dict}=    Create Dictionary    parentUniqueId=${parentUniqueId}   ownerId=${ownerId}  uniqueId=${uniqueId}    description=${description}
189     \    Run Keyword If   '${name}'=='network_role'   Set To Dictionary    ${dict}    name=${name}    value=${nf_role}
190     \    ${data}=   Fill JSON Template File    ${SDC_CATALOG_NET_RESOURCE_INPUT_TEMPLATE}    ${dict} 
191     \    ${response}=    Set ASDC Catalog Resource Component Instance Properties    ${catalog_parent_service_id}    ${catalog_service_id}    ${data}
192     #\    Log To Console    resp=${response}
193     [Return]
194
195 Setup ASDC Catalog Resource CDS Properties
196     [Documentation]    Set up vfwng VNF properties and inputs for CDS
197     [Arguments]    ${catalog_resource_id} 
198     # Set vnf module properties
199     ${resp}=    Get ASDC Catalog Resource Component Instances   ${catalog_resource_id}
200     :FOR    ${comp}    in    @{resp['componentInstances']}
201     \    ${name}    Set Variable   ${comp['name']}
202     \    ${uniqueId}    Set Variable    ${comp['uniqueId']}
203     \    ${actualComponentUid}    Set Variable    ${comp['actualComponentUid']}
204     \    ${test}    ${v}=    Run Keyword and Ignore Error    Should Contain    ${name}    abstract_
205     \    Run Keyword If    '${test}' == 'FAIL'    Continue For Loop
206     \    ${response}=    Get ASDC Catalog Resource Component Instance Properties    ${catalog_resource_id}    ${uniqueId}    ${actualComponentUid}
207     \    ${dict}=    Create Dictionary    parent_id=${response[6]['parentUniqueId']}
208     \    Run Keyword If   '${name}'=='abstract_vfw'   Set To Dictionary    ${dict}    nfc_function=vfw    nfc_naming_policy=SDNC_Policy.ONAP_VFW_NAMING_TIMESTAMP
209     \    Run Keyword If   '${name}'=='abstract_vpg'   Set To Dictionary    ${dict}    nfc_function=vpg    nfc_naming_policy=SDNC_Policy.ONAP_VPG_NAMING_TIMESTAMP
210     \    Run Keyword If   '${name}'=='abstract_vsn'   Set To Dictionary    ${dict}    nfc_function=vsn    nfc_naming_policy=SDNC_Policy.ONAP_VSN_NAMING_TIMESTAMP
211     \    ${data}=   Fill JSON Template File    ${ASDC_RESOURCE_INSTANCE_VNF_PROPERTIES_TEMPLATE}    ${dict} 
212     \    ${response}=    Set ASDC Catalog Resource Component Instance Properties    ${catalog_resource_id}    ${uniqueId}    ${data}
213     \    Log To Console    resp=${response}
214
215     # Set vnf inputs
216     ${resp}=    Get ASDC Catalog Resource Inputs    ${catalog_resource_id}
217     ${dict}=    Create Dictionary
218     :FOR    ${comp}    in    @{resp['inputs']} 
219     \    ${name}    Set Variable    ${comp['name']}
220     \    ${uid}    Set Variable    ${comp['uniqueId']}
221     \    Run Keyword If    '${name}'=='nf_function'    Set To Dictionary    ${dict}    nf_function=ONAP-FIREWALL    nf_function_uid=${uid}
222     \    Run Keyword If    '${name}'=='nf_type'    Set To Dictionary    ${dict}    nf_type=FIREWALL    nf_type_uid=${uid}
223     \    Run Keyword If    '${name}'=='nf_naming_code'    Set To Dictionary    ${dict}    nf_naming_code=vfw    nf_naming_code_uid=${uid}
224     \    Run Keyword If    '${name}'=='nf_role'    Set To Dictionary    ${dict}    nf_role=vFW    nf_role_uid=${uid}
225     \    Run Keyword If    '${name}'=='cloud_env'    Set To Dictionary    ${dict}    cloud_env=openstack    cloud_env_uid=${uid}
226     ${data}=   Fill JSON Template File    ${ASDC_RESOURCE_INSTANCE_VNF_INPUTS_TEMPLATE}    ${dict} 
227     ${response}=    Set ASDC Catalog Resource VNF Inputs    ${catalog_resource_id}    ${data}
228
229 Add ASDC License Model
230     [Documentation]    Creates an asdc license model and returns its id
231     ${uuid}=    Generate UUID
232     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
233     ${map}=    Create Dictionary    vendor_name=${shortened_uuid}
234     ${data}=   Fill JSON Template File    ${ASDC_LICENSE_MODEL_TEMPLATE}    ${map}
235     ${resp}=    Run ASDC Post Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}    ${data}  ${ASDC_DESIGNER_USER_ID}  ${ASDC_BE_ONBOARD_ENDPOINT}
236     Should Be Equal As Strings  ${resp.status_code}     200
237     [Return]    ${resp.json()['itemId']}    ${resp.json()['version']['id']}
238 Get ASDC License Model
239     [Documentation]    gets an asdc license model by its id
240     [Arguments]    ${id}   ${version_id}=0.1
241     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${id}/versions/${version_id}   ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT}
242     [Return]    ${resp.json()}
243 Get ASDC License Models
244     [Documentation]    gets an asdc license model by its id
245     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}   ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT}
246
247     [Return]    ${resp.json()}
248 Checkin ASDC License Model
249     [Documentation]    checksin an asdc license model by its id
250     [Arguments]    ${id}   ${version_id}=0.1
251     ${map}=    Create Dictionary    action=Checkin
252     ${data}=   Fill JSON Template File    ${ASDC_ACTION_TEMPLATE}    ${map}
253     ${resp}=    Run ASDC Put Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${id}/versions/${version_id}${ASDC_VENDOR_ACTIONS_PATH}    ${data}   ${ASDC_DESIGNER_USER_ID}  ${ASDC_BE_ONBOARD_ENDPOINT} 
254     Should Be Equal As Strings  ${resp.status_code}     200
255     [Return]    ${resp.json()}
256 Submit ASDC License Model
257     [Documentation]    submits an asdc license model by its id
258     [Arguments]    ${id}   ${version_id}=0.1
259     ${map}=    Create Dictionary    action=Submit
260     ${data}=   Fill JSON Template File    ${ASDC_ACTION_TEMPLATE}    ${map}
261     ${resp}=    Run ASDC Put Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${id}/versions/${version_id}${ASDC_VENDOR_ACTIONS_PATH}    ${data}   ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT}
262     Should Be Equal As Strings  ${resp.status_code}     200
263     [Return]    ${resp.json()}
264 Checkin ASDC Software Product
265     [Documentation]    checksin an asdc Software Product by its id
266     [Arguments]    ${id}   ${version_id}=0.1
267     ${map}=    Create Dictionary    action=Checkin
268     ${data}=   Fill JSON Template File    ${ASDC_ACTION_TEMPLATE}    ${map}
269     ${resp}=    Run ASDC Put Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${id}/versions/${version_id}${ASDC_VENDOR_ACTIONS_PATH}    ${data}  ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT}
270     Should Be Equal As Strings  ${resp.status_code}     200
271     [Return]    ${resp.json()}
272 Validate ASDC Software Product
273     [Documentation]    checksin an asdc Software Product by its id
274     [Arguments]    ${id}   ${version_id}=0.1
275     ${data}=   Catenate
276     ${resp}=    Run ASDC Put Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${id}/versions/${version_id}/orchestration-template-candidate/process    ${data}    ${ASDC_DESIGNER_USER_ID}  ${ASDC_BE_ONBOARD_ENDPOINT} 
277     Should Be Equal As Strings  ${resp.status_code}     200
278     [Return]    ${resp.json()}
279 Submit ASDC Software Product
280     [Documentation]    submits an asdc Software Product by its id
281     [Arguments]    ${id}   ${version_id}=0.1
282     ${map}=    Create Dictionary    action=Submit
283     ${data}=   Fill JSON Template File    ${ASDC_ACTION_TEMPLATE}    ${map}
284     ${resp}=    Run ASDC Put Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${id}/versions/${version_id}${ASDC_VENDOR_ACTIONS_PATH}    ${data}   ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT} 
285     Should Be Equal As Strings  ${resp.status_code}     200
286     [Return]    ${resp.json()}
287 Package ASDC Software Product
288     [Documentation]    creates_package on an asdc Software Product by its id
289     [Arguments]    ${id}   ${version_id}=0.1
290     ${map}=    Create Dictionary    action=Create_Package
291     ${data}=   Fill JSON Template File    ${ASDC_ACTION_TEMPLATE}    ${map}
292     ${resp}=    Run ASDC Put Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${id}/versions/${version_id}${ASDC_VENDOR_ACTIONS_PATH}    ${data}   ${ASDC_DESIGNER_USER_ID}  ${ASDC_BE_ONBOARD_ENDPOINT} 
293     Should Be Equal As Strings  ${resp.status_code}     200
294     [Return]    ${resp.json()}
295 Add ASDC Entitlement Pool
296     [Documentation]    Creates an asdc Entitlement Pool and returns its id
297     [Arguments]    ${license_model_id}   ${version_id}=0.1
298     ${uuid}=    Generate UUID
299     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
300     ${map}=    Create Dictionary    entitlement_pool_name=${shortened_uuid}
301     ${data}=   Fill JSON Template File    ${ASDC_ENTITLEMENT_POOL_TEMPLATE}    ${map}
302     ${resp}=    Run ASDC Post Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}/versions/${version_id}${ASDC_VENDOR_ENTITLEMENT_POOL_PATH}     ${data}   ${ASDC_DESIGNER_USER_ID}  ${ASDC_BE_ONBOARD_ENDPOINT} 
303     Should Be Equal As Strings  ${resp.status_code}     200
304     [Return]    ${resp.json()['value']}
305 Get ASDC Entitlement Pool
306     [Documentation]    gets an asdc Entitlement Pool by its id
307     [Arguments]    ${license_model_id}    ${pool_id}
308     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}${ASDC_VENDOR_ENTITLEMENT_POOL_PATH}/${pool_id}  ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT} 
309     [Return]    ${resp.json()}
310 Add ASDC License Group
311     [Documentation]    Creates an asdc license group and returns its id
312     [Arguments]    ${license_model_id}   ${version_id}=1.0
313     ${uuid}=    Generate UUID
314     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
315     ${map}=    Create Dictionary    key_group_name=${shortened_uuid}
316     ${data}=   Fill JSON Template File    ${ASDC_KEY_GROUP_TEMPLATE}    ${map}
317     ${resp}=    Run ASDC Post Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}/versions/${version_id}${ASDC_VENDOR_KEY_GROUP_PATH}     ${data}   ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT} 
318     Should Be Equal As Strings  ${resp.status_code}     200
319     [Return]    ${resp.json()['value']}
320 Get ASDC License Group
321     [Documentation]    gets an asdc license group by its id
322     [Arguments]    ${license_model_id}    ${group_id}      ${version_id}
323     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}/versions/${version_id}${ASDC_VENDOR_KEY_GROUP_PATH}/${group_id}   ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT} 
324     [Return]    ${resp.json()}
325 Add ASDC Feature Group
326     [Documentation]    Creates an asdc Feature Group and returns its id
327     [Arguments]    ${license_model_id}    ${key_group_id}    ${entitlement_pool_id}      ${version_id}=0.1
328     ${uuid}=    Generate UUID
329     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
330     ${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}
331     ${data}=   Fill JSON Template File    ${ASDC_FEATURE_GROUP_TEMPLATE}    ${map}
332     ${resp}=    Run ASDC Post Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}/versions/${version_id}${ASDC_VENDOR_FEATURE_GROUP_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT} 
333     Should Be Equal As Strings  ${resp.status_code}     200
334     [Return]    ${resp.json()['value']}
335 Get ASDC Feature Group
336     [Documentation]    gets an asdc Feature Group by its id
337     [Arguments]    ${license_model_id}    ${group_id}
338     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}${ASDC_VENDOR_FEATURE_GROUP_PATH}/${group_id}   ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT} 
339     [Return]    ${resp.json()}
340 Add ASDC License Agreement
341     [Documentation]    Creates an asdc License Agreement and returns its id
342     [Arguments]    ${license_model_id}    ${feature_group_id}      ${version_id}=0.1
343     ${uuid}=    Generate UUID
344     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
345     ${map}=    Create Dictionary    license_agreement_name=${shortened_uuid}    feature_group_id=${feature_group_id}
346     ${data}=   Fill JSON Template File    ${ASDC_LICENSE_AGREEMENT_TEMPLATE}    ${map}
347     ${resp}=    Run ASDC Post Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}/versions/${version_id}${ASDC_VENDOR_LICENSE_AGREEMENT_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT} 
348     Should Be Equal As Strings  ${resp.status_code}     200
349     [Return]    ${resp.json()['value']}
350 Get ASDC License Agreement
351     [Documentation]    gets an asdc License Agreement by its id
352     [Arguments]    ${license_model_id}    ${agreement_id}
353     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_LICENSE_MODEL_PATH}/${license_model_id}${ASDC_VENDOR_LICENSE_AGREEMENT_PATH}/${agreement_id}   ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT} 
354     [Return]    ${resp.json()}
355 Add ASDC Software Product
356     [Documentation]    Creates an asdc Software Product and returns its id
357     [Arguments]    ${license_agreement_id}    ${feature_group_id}    ${license_model_name}    ${license_model_id}   ${license_model_version_id}
358     ${uuid}=    Generate UUID
359     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
360     ${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}    version_id=${license_model_version_id}
361     ${data}=   Fill JSON Template File    ${ASDC_SOFTWARE_PRODUCT_TEMPLATE}    ${map}
362     ${resp}=    Run ASDC Post Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}   ${ASDC_BE_ONBOARD_ENDPOINT} 
363     Should Be Equal As Strings  ${resp.status_code}     200
364     [Return]    ${resp.json()['itemId']}   ${resp.json()['version']['id']}
365 Get ASDC Software Product
366     [Documentation]    gets an asdc Software Product by its id
367     [Arguments]    ${software_product_id}   ${version_id}=0.1
368     ${resp}=    Run ASDC Get Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${software_product_id}/versions/${version_id}   ${ASDC_DESIGNER_USER_ID}  ${ASDC_BE_ONBOARD_ENDPOINT} 
369     [Return]    ${resp.json()}
370 Add ASDC Catalog Resource
371     [Documentation]    Creates an asdc Catalog Resource and returns its id
372     [Arguments]    ${license_agreement_id}    ${software_product_name}    ${license_model_name}    ${software_product_id}
373     ${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}
374     ${data}=   Fill JSON Template File    ${ASDC_CATALOG_RESOURCE_TEMPLATE}    ${map}
375     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}   
376     Should Be Equal As Strings  ${resp.status_code}     201
377     [Return]    ${resp.json()['uniqueId']}
378 Mark ASDC Catalog Resource Inactive
379     [Documentation]    deletes an asdc Catalog Resource
380     [Arguments]    ${catalog_resource_id}
381     ${resp}=    Run ASDC Delete Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}     ${ASDC_DESIGNER_USER_ID}
382     Should Be Equal As Strings  ${resp.status_code}     204
383     [Return]    ${resp}
384 Delete Inactive ASDC Catalog Resources
385     [Documentation]    delete all asdc Catalog Resources that are inactive
386     ${resp}=    Run ASDC Delete Request    ${ASDC_CATALOG_INACTIVE_RESOURCES_PATH}     ${ASDC_DESIGNER_USER_ID}
387     Should Be Equal As Strings  ${resp.status_code}     200
388     [Return]    ${resp.json()}
389 Get ASDC Catalog Resource
390     [Documentation]    gets an asdc Catalog Resource by its id
391     [Arguments]    ${catalog_resource_id}
392     ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}    ${ASDC_DESIGNER_USER_ID} 
393     [Return]    ${resp.json()}
394
395 Get ASDC Catalog Resource Component Instances
396     [Documentation]    gets asdc Catalog Resource Component Instances by its id
397     [Arguments]    ${catalog_resource_id}
398     ${resp}=    Run ASDC Get Request    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/filteredDataByParams?include=componentInstances    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
399     [Return]    ${resp.json()}
400 Get ASDC Catalog Resource Component Instances Properties
401     [Documentation]    gets asdc Catalog Resource Component Instances Properties by its id
402     [Arguments]    ${catalog_resource_id}
403     #${resp}=    Run ASDC Get Request    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/filteredDataByParams?include=componentInstancesProperties    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
404     ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_resource_id}/filteredDataByParams?include=componentInstancesProperties    ${ASDC_DESIGNER_USER_ID}    ${ASDC_BE_ENDPOINT}
405     [Return]    ${resp.json()}
406
407
408 Get ASDC Catalog Resource Inputs
409     [Documentation]    gets asdc Catalog Inputs by its id
410     [Arguments]    ${catalog_resource_id}
411     ${resp}=    Run ASDC Get Request    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/filteredDataByParams?include=inputs    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
412     [Return]    ${resp.json()}
413
414 Get ASDC Catalog Resource Component Instance Properties
415     [Documentation]    gets an asdc Catalog Resource properties by its id
416     [Arguments]    ${catalog_resource_id}    ${component_instance_id}    ${component_id}
417     ${resp}=    Run ASDC Get Request    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/componentInstances/${component_instance_id}/${component_id}/inputs    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
418     [Return]    ${resp.json()}
419 Set ASDC Catalog Resource Component Instance Properties
420     [Documentation]    sets an asdc Catalog Resource by its id
421     [Arguments]    ${catalog_resource_id}    ${component_parent_service_id}    ${data}
422     #${resp}=    Run ASDC Post Request    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${component_parent_service_id}/resourceInstance/${catalog_resource_id}/inputs    ${data}    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
423     ${resp}=    Run ASDC Post Request    ${ASDC_FE_CATALOG_SERVICES_PATH}/${component_parent_service_id}/resourceInstance/${catalog_resource_id}/properties    ${data}    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
424     [Return]    ${resp.json()}
425
426 Set ASDC Catalog Resource VNF Inputs
427     [Documentation]    sets an asdc Catalog Resource by its id
428     [Arguments]    ${catalog_resource_id}    ${data}
429     ${resp}=    Run ASDC Post Request    ${ASDC_FE_CATALOG_RESOURCES_PATH}/${catalog_resource_id}/update/inputs    ${data}    ${ASDC_DESIGNER_USER_ID}    ${ASDC_FE_ENDPOINT}
430     [Return]    ${resp.json()}
431 Get SDC Demo Vnf Catalog Resource
432     [Documentation]  gets resource id's for demonstration VNFs for instantiate
433     [Arguments]    ${service_name}
434     ${resp}=   Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}/serviceName/${service_name}/serviceVersion/1.0
435     @{ITEMS}=    Copy List    ${resp.json()['componentInstances']}
436     ${demo_catalog_resource}=   Create Dictionary
437     :FOR    ${ELEMENT}    IN    @{ITEMS}
438     \    Log    ${ELEMENT['name']}
439     \    Log    ${ELEMENT['groupInstances'][0]['groupName']}
440     \    ${vnf}=   Get VNF From Group Name     ${ELEMENT['groupInstances'][0]['groupName']}     ${service_name}
441     \    ${vnf_data}=    Create Dictionary    vnf_type=${ELEMENT['name']}  vf_module=${ELEMENT['groupInstances'][0]['groupName']}
442     \    LOG     ${vnf_data}
443     \    Set To Dictionary    ${demo_catalog_resource}    ${vnf}=${vnf_data}
444     \    LOG     ${demo_catalog_resource}
445     [Return]    ${demo_catalog_resource}
446
447 Get VNF From Group Name
448     [Documentation]   looks up vnf key from service mapping for a regex on groupName and service_name
449     [Arguments]   ${group_name}    ${service_name}
450     ${vnf}=   Set Variable If
451     ...                      ('${service_name}'=='demoVFWCL') and ('base_vfw' in '${group_name}')   vFWSNK
452     ...                      ('${service_name}'=='demoVFWCL') and ('base_vpkg' in '${group_name}')   vPKG
453     ...                      ('${service_name}'=='demoVLB') and ('base_vlb' in '${group_name}')   vLB
454     [Return]   ${vnf}
455 Checkin ASDC Catalog Resource
456     [Documentation]    checksin an asdc Catalog Resource by its id
457     [Arguments]    ${catalog_resource_id}
458     ${map}=    Create Dictionary    user_remarks=Robot remarks
459     ${data}=   Fill JSON Template File    ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
460     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/checkin    ${data}    ${ASDC_DESIGNER_USER_ID}
461     Should Be Equal As Strings  ${resp.status_code}     200
462     [Return]    ${resp.json()}
463 Request Certify ASDC Catalog Resource
464     [Documentation]    requests certify on an asdc Catalog Resource by its id
465     [Arguments]    ${catalog_resource_id}
466     ${map}=    Create Dictionary    user_remarks=Robot remarks
467     ${data}=   Fill JSON Template File    ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
468     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certificationRequest    ${data}    ${ASDC_DESIGNER_USER_ID}
469     Should Be Equal As Strings  ${resp.status_code}     200
470     [Return]    ${resp.json()}
471 Start Certify ASDC Catalog Resource
472     [Documentation]    start certify an asdc Catalog Resource by its id
473     [Arguments]    ${catalog_resource_id}
474     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/startCertification    ${None}    ${ASDC_TESTER_USER_ID}
475     Should Be Equal As Strings  ${resp.status_code}     200
476     [Return]    ${resp.json()}
477 Certify ASDC Catalog Resource
478     [Documentation]    start certify an asdc Catalog Resource by its id and returns the new id
479     [Arguments]    ${catalog_resource_id}    ${user_id}=${ASDC_TESTER_USER_ID}
480     ${map}=    Create Dictionary    user_remarks=Robot remarks
481     ${data}=   Fill JSON Template File    ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
482     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certify    ${data}    ${user_id}
483     Should Be Equal As Strings  ${resp.status_code}     200
484     [Return]    ${resp.json()['uniqueId']}
485
486 Upload ASDC Heat Package
487     [Documentation]    Creates an asdc Software Product and returns its id
488     [Arguments]    ${software_product_id}    ${file_path}   ${version_id}=0.1
489      ${files}=     Create Dictionary
490      Create Multi Part     ${files}  upload  ${file_path}    contentType=application/zip
491     ${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}   ${ASDC_BE_ONBOARD_ENDPOINT} 
492         Should Be Equal As Strings      ${resp.status_code}     200
493
494 Add ASDC Catalog Service
495     [Documentation]    Creates an asdc Catalog Service and returns its id
496     [Arguments]   ${catalog_service_name}
497     ${uuid}=    Generate UUID
498     ${shortened_uuid}=     Evaluate    str("${uuid}")[:23]
499     ${catalog_service_name}=   Set Variable If   '${catalog_service_name}' ==''   ${shortened_uuid}   ${catalog_service_name}
500     ${map}=    Create Dictionary    service_name=${catalog_service_name}
501     ${data}=   Fill JSON Template File    ${ASDC_CATALOG_SERVICE_TEMPLATE}    ${map}
502     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}
503     Should Be Equal As Strings  ${resp.status_code}     201
504     [Return]    ${resp.json()['uniqueId']}
505 Mark ASDC Catalog Service Inactive
506     [Documentation]    Deletes an asdc Catalog Service
507     [Arguments]    ${catalog_service_id}
508     ${resp}=    Run ASDC Delete Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}     ${ASDC_DESIGNER_USER_ID}
509     Should Be Equal As Strings  ${resp.status_code}     204
510     [Return]    ${resp}
511 Delete Inactive ASDC Catalog Services
512     [Documentation]    delete all asdc Catalog Serivces that are inactive
513     ${resp}=    Run ASDC Delete Request    ${ASDC_CATALOG_INACTIVE_SERVICES_PATH}     ${ASDC_DESIGNER_USER_ID}
514     Should Be Equal As Strings  ${resp.status_code}     200
515     [Return]    ${resp.json()}
516 Get ASDC Catalog Service
517     [Documentation]    gets an asdc Catalog Service by its id
518     [Arguments]    ${catalog_service_id}
519     ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}    ${ASDC_DESIGNER_USER_ID}
520     [Return]    ${resp.json()}
521 Checkin ASDC Catalog Service
522     [Documentation]    checksin an asdc Catalog Service by its id
523     [Arguments]    ${catalog_service_id}
524     ${map}=    Create Dictionary    user_remarks=Robot remarks
525     ${data}=   Fill JSON Template File    ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
526     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/checkin    ${data}    ${ASDC_DESIGNER_USER_ID}
527     Should Be Equal As Strings  ${resp.status_code}     200
528     [Return]    ${resp.json()}
529 Request Certify ASDC Catalog Service
530     [Documentation]    requests certify on an asdc Catalog Service by its id
531     [Arguments]    ${catalog_service_id}
532     ${map}=    Create Dictionary    user_remarks=Robot remarks
533     ${data}=   Fill JSON Template File    ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
534     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certificationRequest    ${data}    ${ASDC_DESIGNER_USER_ID}
535     Should Be Equal As Strings  ${resp.status_code}     200
536     [Return]    ${resp.json()}
537 Start Certify ASDC Catalog Service
538     [Documentation]    start certify an asdc Catalog Service by its id
539     [Arguments]    ${catalog_service_id}
540     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/startCertification    ${None}    ${ASDC_TESTER_USER_ID}
541     Should Be Equal As Strings  ${resp.status_code}     200
542     [Return]    ${resp.json()}
543 Certify ASDC Catalog Service
544     [Documentation]    start certify an asdc Catalog Service by its id and returns the new id
545     [Arguments]    ${catalog_service_id}
546     ${map}=    Create Dictionary    user_remarks=Robot remarks
547     ${data}=   Fill JSON Template File    ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
548     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certify    ${data}    ${ASDC_TESTER_USER_ID}
549     Should Be Equal As Strings  ${resp.status_code}     200
550     [Return]    ${resp.json()['uniqueId']}
551 Approve ASDC Catalog Service
552     [Documentation]    approve an asdc Catalog Service by its id
553     [Arguments]    ${catalog_service_id}
554     ${map}=    Create Dictionary    user_remarks=Robot remarks
555     ${data}=   Fill JSON Template File    ${ASDC_USER_REMARKS_TEMPLATE}    ${map}
556     ${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}
557     Should Be Equal As Strings  ${resp.status_code}     200
558     [Return]    ${resp.json()}
559 Distribute ASDC Catalog Service
560     [Documentation]    distribute an asdc Catalog Service by its id
561     [Arguments]    ${catalog_service_id}
562     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_SERVICE_DISTRIBUTION_ACTIVATE_PATH}    ${None}    ${ASDC_OPS_USER_ID}
563     Should Be Equal As Strings  ${resp.status_code}     200
564     [Return]    ${resp.json()}
565 Add ASDC Resource Instance
566     [Documentation]    Creates an asdc Resource Instance and returns its id
567     [Arguments]    ${catalog_service_id}    ${catalog_resource_id}    ${catalog_resource_name}  ${xoffset}=${0}   ${yoffset}=${0}
568     ${milli_timestamp}=    Generate MilliTimestamp UUID
569     ${xoffset}=    Set Variable   ${xoffset+306}
570     ${yoffset}=    Set Variable   ${yoffset+248}
571     ${map}=    Create Dictionary    catalog_resource_id=${catalog_resource_id}    catalog_resource_name=${catalog_resource_name}    milli_timestamp=${milli_timestamp}   posX=${xoffset}    posY=${yoffset}
572     ${data}=   Fill JSON Template File    ${ASDC_RESOURCE_INSTANCE_TEMPLATE}    ${map}
573     ${resp}=    Run ASDC Post Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_SERVICE_RESOURCE_INSTANCE_PATH}     ${data}    ${ASDC_DESIGNER_USER_ID}
574     Should Be Equal As Strings  ${resp.status_code}     201
575     [Return]    ${resp.json()['uniqueId']}
576
577 Get Catalog Service Distribution
578     [Documentation]    gets an asdc catalog Service distrbution
579     [Arguments]    ${catalog_service_uuid}
580     ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_uuid}${ASDC_CATALOG_SERVICE_DISTRIBUTION_PATH}    ${ASDC_OPS_USER_ID}
581     Should Be Equal As Strings  ${resp.status_code}     200
582     [Return]    ${resp.json()}
583 Check Catalog Service Distributed
584     [Documentation]    gets an asdc catalog Service distrbution
585     [Arguments]    ${catalog_service_uuid}    ${dist_status}
586     ${dist_resp}=    Get Catalog Service Distribution    ${catalog_service_uuid}
587     Should Be Equal As Strings  ${dist_resp['distributionStatusOfServiceList'][0]['deployementStatus']}         Distributed
588     ${det_resp}=    Get Catalog Service Distribution Details    ${dist_resp['distributionStatusOfServiceList'][0]['distributionID']}
589     @{ITEMS}=    Copy List    ${det_resp['distributionStatusList']}
590     Should Not Be Empty   ${ITEMS}
591     ${SO_COMPLETE}   Set Variable   FALSE
592     :FOR    ${ELEMENT}    IN    @{ITEMS}
593     \    Log    ${ELEMENT['omfComponentID']}
594     \    Log    ${ELEMENT['status']}
595     \    ${SO_COMPLETE}   Set Variable If   (('${ELEMENT['status']}' == 'DISTRIBUTION_COMPLETE_OK')) or ('${SO_COMPLETE}'=='TRUE')  TRUE
596     \    Exit For Loop If   ('${SO_COMPLETE}'=='TRUE')
597     \    Exit For Loop If   ('${ELEMENT['status']}' == 'DISTRIBUTION_COMPLETE_ERROR')
598     \    ${dist_status}=  Set Variable If   (('${ELEMENT['status']}' == 'COMPONENT_DONE_ERROR') and ('${ELEMENT['omfComponentID']}' == 'aai-ml'))  EXIT
599     \    Exit For Loop If   (('${ELEMENT['status']}' == 'COMPONENT_DONE_ERROR') and ('${ELEMENT['omfComponentID']}' == 'aai-ml'))
600     Should Be True   ( '${SO_COMPLETE}'=='TRUE')   SO Test
601 Get Catalog Service Distribution Details
602     [Documentation]    gets an asdc catalog Service distrbution details
603     [Arguments]    ${catalog_service_distribution_id}
604     ${resp}=    Run ASDC Get Request    ${ASDC_CATALOG_SERVICES_PATH}${ASDC_CATALOG_SERVICE_DISTRIBUTION_PATH}/${catalog_service_distribution_id}    ${ASDC_OPS_USER_ID} 
605     Should Be Equal As Strings  ${resp.status_code}     200
606     [Return]    ${resp.json()}
607 Run ASDC Health Check
608     [Documentation]    Runs a ASDC health check
609     ${session}=    Create Session       asdc    ${ASDC_FE_ENDPOINT}
610     ${uuid}=    Generate UUID
611     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
612     ${resp}=    Get Request     asdc    ${ASDC_HEALTH_CHECK_PATH}     headers=${headers}
613     # only test for HTTP 200 to determine SDC Health. SDC_DE_HEALTH is informational
614     Should Be Equal As Strings  ${resp.status_code}     200    SDC DOWN
615     ${SDC_DE_HEALTH}=    Catenate   DOWN
616     @{ITEMS}=    Copy List    ${resp.json()['componentsInfo']}
617     :FOR    ${ELEMENT}    IN    @{ITEMS}
618     \    Log    ${ELEMENT['healthCheckStatus']}
619     \    ${SDC_DE_HEALTH}  Set Variable If   (('DE' in '${ELEMENT['healthCheckComponent']}') and ('${ELEMENT['healthCheckStatus']}' == 'UP')) or ('${SDC_DE_HEALTH}'=='UP')  UP
620     Log To Console   (DMaaP:${SDC_DE_HEALTH})    no_newline=true
621 Run ASDC Get Request
622     [Documentation]    Runs an ASDC get request
623     [Arguments]    ${data_path}    ${user}=${ASDC_DESIGNER_USER_ID}  ${MY_ASDC_BE_ENDPOINT}=${ASDC_BE_ENDPOINT}
624     ${auth}=  Create List  ${GLOBAL_ASDC_BE_USERNAME}    ${GLOBAL_ASDC_BE_PASSWORD}
625     Log    Creating session ${MY_ASDC_BE_ENDPOINT}
626     ${session}=    Create Session       asdc    ${MY_ASDC_BE_ENDPOINT}    auth=${auth}
627     ${uuid}=    Generate UUID
628     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    USER_ID=${user}    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
629     ${resp}=    Get Request     asdc    ${data_path}     headers=${headers}
630     Log    Received response from asdc ${resp.text}
631     [Return]    ${resp}
632 Run ASDC Put Request
633     [Documentation]    Runs an ASDC put request
634     [Arguments]    ${data_path}    ${data}    ${user}=${ASDC_DESIGNER_USER_ID}   ${MY_ASDC_BE_ENDPOINT}=${ASDC_BE_ENDPOINT}
635     ${auth}=  Create List  ${GLOBAL_ASDC_BE_USERNAME}    ${GLOBAL_ASDC_BE_PASSWORD}
636     Log    Creating session ${MY_ASDC_BE_ENDPOINT}
637     ${session}=    Create Session       asdc    ${MY_ASDC_BE_ENDPOINT}    auth=${auth}
638     ${uuid}=    Generate UUID
639     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    USER_ID=${user}    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
640     ${resp}=    Put Request     asdc    ${data_path}     data=${data}    headers=${headers}
641     Log    Received response from asdc ${resp.text}
642     [Return]    ${resp}
643
644 Run ASDC Post Files Request
645     [Documentation]    Runs an ASDC post request
646     [Arguments]    ${data_path}    ${files}    ${user}=${ASDC_DESIGNER_USER_ID}   ${MY_ASDC_BE_ENDPOINT}=${ASDC_BE_ENDPOINT}
647     ${auth}=  Create List  ${GLOBAL_ASDC_BE_USERNAME}    ${GLOBAL_ASDC_BE_PASSWORD}
648     Log    Creating session ${MY_ASDC_BE_ENDPOINT}
649     ${session}=    Create Session       asdc    ${MY_ASDC_BE_ENDPOINT}    auth=${auth}
650     ${uuid}=    Generate UUID
651     ${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}
652     ${resp}=    Post Request    asdc    ${data_path}     files=${files}    headers=${headers}
653     Log    Received response from asdc ${resp.text}
654     [Return]    ${resp}
655
656 Run ASDC Post Request
657     [Documentation]    Runs an ASDC post request
658     [Arguments]    ${data_path}    ${data}    ${user}=${ASDC_DESIGNER_USER_ID}   ${MY_ASDC_BE_ENDPOINT}=${ASDC_BE_ENDPOINT}
659     ${auth}=  Create List  ${GLOBAL_ASDC_BE_USERNAME}    ${GLOBAL_ASDC_BE_PASSWORD}
660     Log    Creating session ${MY_ASDC_BE_ENDPOINT}
661     ${session}=    Create Session       asdc    ${MY_ASDC_BE_ENDPOINT}    auth=${auth}
662     ${uuid}=    Generate UUID
663     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    USER_ID=${user}    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
664     ${resp}=    Post Request    asdc    ${data_path}     data=${data}    headers=${headers}
665     Log    Received response from asdc ${resp.text}
666     [Return]    ${resp}
667 Run ASDC Delete Request
668     [Documentation]    Runs an ASDC delete request
669     [Arguments]    ${data_path}    ${user}=${ASDC_DESIGNER_USER_ID}  ${MY_ASDC_BE_ENDPOINT}=${ASDC_BE_ENDPOINT}
670     ${auth}=  Create List  ${GLOBAL_ASDC_BE_USERNAME}    ${GLOBAL_ASDC_BE_PASSWORD} 
671     Log    Creating session ${MY_ASDC_BE_ENDPOINT}
672     ${session}=    Create Session       asdc    ${MY_ASDC_BE_ENDPOINT}    auth=${auth}
673     ${uuid}=    Generate UUID
674     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    USER_ID=${user}    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
675     ${resp}=    Delete Request  asdc    ${data_path}        headers=${headers}
676     Log    Received response from asdc ${resp.text}
677     [Return]    ${resp}
678 Open ASDC GUI
679     [Documentation]   Logs in to ASDC GUI
680     [Arguments]    ${PATH}
681     ## Setup Browever now being managed by the test case
682     ##Setup Browser
683     Go To    ${ASDC_FE_ENDPOINT}${PATH}
684     Maximize Browser Window
685
686     Set Browser Implicit Wait    ${GLOBAL_SELENIUM_BROWSER_IMPLICIT_WAIT}
687     Log    Logging in to ${ASDC_FE_ENDPOINT}${PATH}
688     Title Should Be    ASDC
689     Wait Until Page Contains Element    xpath=//div/a[text()='SDC']    ${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT}
690     Log    Logged in to ${ASDC_FE_ENDPOINT}${PATH}
691
692
693 Create Multi Part
694    [Arguments]  ${addTo}  ${partName}  ${filePath}  ${contentType}=${None}
695    ${fileData}=   Get Binary File  ${filePath}
696    ${fileDir}  ${fileName}=  Split Path  ${filePath}
697    ${partData}=  Create List  ${fileName}  ${fileData}  ${contentType}
698    Set To Dictionary  ${addTo}  ${partName}=${partData}
699