blob: 185d44d5a62cde83702008d7fab8d759bde791c9 [file] [log] [blame]
Jerry Flood8a6b0b52017-11-12 15:44:21 -05001*** Settings ***
2Documentation Create A&AI Customer API.
3...
4... Create A&AI Customer API
5
6Resource ../json_templater.robot
7Resource aai_interface.robot
8Library OperatingSystem
9Library Collections
10
11
12
13*** Variables ***
14${COMPLEX_INDEX_PATH} /aai/v11
15${ROOT_COMPLEXES_PATH} /cloud-infrastructure/complexes
16${ROOT_COMPLEX_PATH} /cloud-infrastructure/complexes/complex
17
18${SYSTEM USER} robot-ete
19${AAI_ADD_COMPLEX_BODY}= robot/assets/templates/aai/add_complex_body.template
20
21*** Keywords ***
22Inventory 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}
28
29Inventory Complex
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)$
41
42Delete 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 Zone Exists ${physical_location_id} ${get_resp.json()}
47
48Delete Complex
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
53
54Get Complex
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()}
60
61Get Complexes
62 [Documentation] Return all complexes
Jerry Flood8a6b0b52017-11-12 15:44:21 -050063 ${resp}= Run A&AI Get Request ${COMPLEX_INDEX_PATH}${ROOT_COMPLEXES_PATH}
64 Should Be Equal As Strings ${resp.status_code} 200
65 Log ${resp.json()}
DR695Hb034c282018-02-23 18:33:19 -050066 [Return] ${resp.json()}