Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame^] | 1 | *** Settings *** |
| 2 | Documentation Create A&AI Customer API. |
| 3 | ... |
| 4 | ... Create A&AI Customer API |
| 5 | |
| 6 | Resource ../json_templater.robot |
| 7 | Resource aai_interface.robot |
| 8 | Library OperatingSystem |
| 9 | Library 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 *** |
| 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} |
| 28 | |
| 29 | Inventory 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 | |
| 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 Zone Exists ${physical_location_id} ${get_resp.json()} |
| 47 | |
| 48 | Delete 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 | |
| 54 | Get 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 | |
| 61 | Get Complexes |
| 62 | [Documentation] Return all complexes |
| 63 | [Arguments] |
| 64 | ${resp}= Run A&AI Get Request ${COMPLEX_INDEX_PATH}${ROOT_COMPLEXES_PATH} |
| 65 | Should Be Equal As Strings ${resp.status_code} 200 |
| 66 | Log ${resp.json()} |
| 67 | [Return] ${resp.json()} |
| 68 | |
| 69 | |
| 70 | |
| 71 | |