Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Create A&AI Customer API. |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 3 | |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 4 | Resource aai_interface.robot |
| 5 | Library OperatingSystem |
| 6 | Library Collections |
DR695H | 3bb6cf4 | 2019-06-20 15:04:04 -0400 | [diff] [blame] | 7 | Library ONAPLibrary.Templating |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 8 | |
| 9 | |
| 10 | *** Variables *** |
| 11 | ${COMPLEX_INDEX_PATH} /aai/v11 |
| 12 | ${ROOT_COMPLEXES_PATH} /cloud-infrastructure/complexes |
| 13 | ${ROOT_COMPLEX_PATH} /cloud-infrastructure/complexes/complex |
| 14 | |
DR695H | 3bb6cf4 | 2019-06-20 15:04:04 -0400 | [diff] [blame] | 15 | ${AAI_ADD_COMPLEX_BODY} aai/add_complex_body.jinja |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 16 | |
| 17 | *** Keywords *** |
| 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} |
| 24 | |
| 25 | Inventory Complex |
DR695H | 3bb6cf4 | 2019-06-20 15:04:04 -0400 | [diff] [blame] | 26 | [Documentation] Inventorys a Complex in A&AI |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 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} |
DR695H | 3bb6cf4 | 2019-06-20 15:04:04 -0400 | [diff] [blame] | 33 | Create Environment aai ${GLOBAL_TEMPLATE_FOLDER} |
| 34 | ${data}= Apply Template aai ${AAI_ADD_COMPLEX_BODY} ${arguments} |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 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)$ |
| 38 | |
| 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} |
DR695H | 910097e | 2019-05-08 13:55:32 -0400 | [diff] [blame] | 43 | Run Keyword If '${get_resp.status_code}' == '200' Delete Complex ${physical_location_id} ${get_resp.json()} |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 44 | |
| 45 | Delete Complex |
| 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 |
| 50 | |
| 51 | Get Complex |
| 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()} |
| 57 | |
| 58 | Get Complexes |
| 59 | [Documentation] Return all complexes |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 60 | ${resp}= Run A&AI Get Request ${COMPLEX_INDEX_PATH}${ROOT_COMPLEXES_PATH} |
| 61 | Should Be Equal As Strings ${resp.status_code} 200 |
| 62 | Log ${resp.json()} |
DR695H | b034c28 | 2018-02-23 18:33:19 -0500 | [diff] [blame] | 63 | [Return] ${resp.json()} |