2 Documentation Create A&AI Customer API.
4 ... Create A&AI Customer API
6 Resource ../json_templater.robot
7 Resource aai_interface.robot
8 Library OperatingSystem
14 ${COMPLEX_INDEX_PATH} /aai/v11
15 ${ROOT_COMPLEXES_PATH} /cloud-infrastructure/complexes
16 ${ROOT_COMPLEX_PATH} /cloud-infrastructure/complexes/complex
18 ${SYSTEM USER} robot-ete
19 ${AAI_ADD_COMPLEX_BODY}= robot/assets/templates/aai/add_complex_body.template
22 Inventory Complex If Not Exists
23 [Documentation] Creates a service in A&AI if it doesn't exist
24 [Arguments] ${complex_name} ${physical_location_id} ${cloud_owner} ${region} ${owner_defined_type}
25 ${get_resp}= Run A&AI Get Request ${COMPLEX_INDEX_PATH}${ROOT_COMPLEX_PATH}/${physical_location_id}
26 Return From Keyword If '${get_resp.status_code}' == '200'
27 Inventory Complex ${complex_name} ${physical_location_id} ${cloud_owner} ${region} ${owner_defined_type}
30 [Documentation] Inventorys a COmplex in A&AI
31 [Arguments] ${complex_name} ${physical_location_id} ${cloud_owner} ${region} ${owner_defined_type}
32 ${arguments}= Create Dictionary complex_name=${complex_name}
33 Set To Dictionary ${arguments} physical_location_id=${physical_location_id}
34 Set To Dictionary ${arguments} cloud_owner=${cloud_owner}
35 Set To Dictionary ${arguments} region=${region}
36 Set To Dictionary ${arguments} owner_defined_type=${owner_defined_type}
37 ${data}= Fill JSON Template File ${AAI_ADD_COMPLEX_BODY} ${arguments}
38 ${put_resp}= Run A&AI Put Request ${COMPLEX_INDEX_PATH}${ROOT_COMPLEX_PATH}/${physical_location_id} ${data}
39 ${status_string}= Convert To String ${put_resp.status_code}
40 Should Match Regexp ${status_string} ^(201|200)$
42 Delete Complex If Exists
43 [Documentation] Removes a complex
44 [Arguments] ${physical_location_id}
45 ${get_resp}= Run A&AI Get Request ${COMPLEX_INDEX_PATH}${ROOT_COMPLEX_PATH}/${physical_location_id}
46 Run Keyword If '${get_resp.status_code}' == '200' Delete Complex ${physical_location_id} ${get_resp.json()}
49 [Arguments] ${physical_location_id} ${json}
50 ${resource_version}= Catenate ${json['resource-version']}
51 ${put_resp}= Run A&AI Delete Request ${COMPLEX_INDEX_PATH}${ROOT_COMPLEX_PATH}/${physical_location_id} ${resource_version}
52 Should Be Equal As Strings ${put_resp.status_code} 204
55 [Documentation] Return a complex
56 [Arguments] ${physical_location_id}
57 ${resp}= Run A&AI Get Request ${COMPLEX_INDEX_PATH}${ROOT_COMPLEX_PATH}/${physical_location_id}
58 Should Be Equal As Strings ${resp.status_code} 200
59 [Return] ${resp.json()}
62 [Documentation] Return all complexes
63 ${resp}= Run A&AI Get Request ${COMPLEX_INDEX_PATH}${ROOT_COMPLEXES_PATH}
64 Should Be Equal As Strings ${resp.status_code} 200
66 [Return] ${resp.json()}