2 Documentation Create A&AI Customer API.
4 Resource aai_interface.robot
5 Library OperatingSystem
7 Library ONAPLibrary.Templating
11 ${COMPLEX_INDEX_PATH} /aai/v11
12 ${ROOT_COMPLEXES_PATH} /cloud-infrastructure/complexes
13 ${ROOT_COMPLEX_PATH} /cloud-infrastructure/complexes/complex
15 ${AAI_ADD_COMPLEX_BODY} aai/add_complex_body.jinja
18 Inventory Complex If Not Exists
19 [Documentation] Creates a service in A&AI if it doesn't exist
20 [Arguments] ${complex_name} ${physical_location_id} ${cloud_owner} ${region} ${owner_defined_type}
21 ${get_resp}= Run A&AI Get Request ${COMPLEX_INDEX_PATH}${ROOT_COMPLEX_PATH}/${physical_location_id}
22 Return From Keyword If '${get_resp.status_code}' == '200'
23 Inventory Complex ${complex_name} ${physical_location_id} ${cloud_owner} ${region} ${owner_defined_type}
26 [Documentation] Inventorys a Complex in A&AI
27 [Arguments] ${complex_name} ${physical_location_id} ${cloud_owner} ${region} ${owner_defined_type}
28 ${arguments}= Create Dictionary complex_name=${complex_name}
29 Set To Dictionary ${arguments} physical_location_id=${physical_location_id}
30 Set To Dictionary ${arguments} cloud_owner=${cloud_owner}
31 Set To Dictionary ${arguments} region=${region}
32 Set To Dictionary ${arguments} owner_defined_type=${owner_defined_type}
33 Create Environment aai ${GLOBAL_TEMPLATE_FOLDER}
34 ${data}= Apply Template aai ${AAI_ADD_COMPLEX_BODY} ${arguments}
35 ${put_resp}= Run A&AI Put Request ${COMPLEX_INDEX_PATH}${ROOT_COMPLEX_PATH}/${physical_location_id} ${data}
36 ${status_string}= Convert To String ${put_resp.status_code}
37 Should Match Regexp ${status_string} ^(201|200)$
39 Delete Complex If Exists
40 [Documentation] Removes a complex
41 [Arguments] ${physical_location_id}
42 ${get_resp}= Run A&AI Get Request ${COMPLEX_INDEX_PATH}${ROOT_COMPLEX_PATH}/${physical_location_id}
43 Run Keyword If '${get_resp.status_code}' == '200' Delete Complex ${physical_location_id} ${get_resp.json()}
46 [Arguments] ${physical_location_id} ${json}
47 ${resource_version}= Catenate ${json['resource-version']}
48 ${put_resp}= Run A&AI Delete Request ${COMPLEX_INDEX_PATH}${ROOT_COMPLEX_PATH}/${physical_location_id} ${resource_version}
49 Should Be Equal As Strings ${put_resp.status_code} 204
52 [Documentation] Return a complex
53 [Arguments] ${physical_location_id}
54 ${resp}= Run A&AI Get Request ${COMPLEX_INDEX_PATH}${ROOT_COMPLEX_PATH}/${physical_location_id}
55 Should Be Equal As Strings ${resp.status_code} 200
56 [Return] ${resp.json()}
59 [Documentation] Return all complexes
60 ${resp}= Run A&AI Get Request ${COMPLEX_INDEX_PATH}${ROOT_COMPLEXES_PATH}
61 Should Be Equal As Strings ${resp.status_code} 200
63 [Return] ${resp.json()}