DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation The main interface for interacting with A&AI. It handles low level stuff like managing the http request library and A&AI required fields |
| 3 | Library RequestsLibrary |
DR695H | 18872bc | 2019-06-13 16:16:52 -0400 | [diff] [blame] | 4 | Library ONAPLibrary.Utilities |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 5 | Resource ../global_properties.robot |
| 6 | |
| 7 | *** Variables *** |
| 8 | ${AAI_HEALTH_PATH} /aai/util/echo?action=long |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 9 | ${VERSIONED_INDEX_PATH} /aai/v11 |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 10 | ${AAI_FRONTEND_ENDPOINT} ${GLOBAL_AAI_SERVER_PROTOCOL}://${GLOBAL_INJECTED_AAI1_IP_ADDR}:${GLOBAL_AAI_SERVER_PORT} |
| 11 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 12 | |
| 13 | *** Keywords *** |
| 14 | Run A&AI Health Check |
| 15 | [Documentation] Runs an A&AI health check |
Jerry Flood | fe22bf1 | 2017-04-21 16:53:10 -0400 | [diff] [blame] | 16 | ${resp}= Run A&AI Get Request ${AAI_HEALTH_PATH} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 17 | Should Be Equal As Strings ${resp.status_code} 200 |
| 18 | |
| 19 | Run A&AI Get Request |
| 20 | [Documentation] Runs an A&AI get request |
| 21 | [Arguments] ${data_path} |
Jerry Flood | fe22bf1 | 2017-04-21 16:53:10 -0400 | [diff] [blame] | 22 | Disable Warnings |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 23 | ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 24 | ${session}= Create Session aai ${AAI_FRONTEND_ENDPOINT} auth=${auth} |
DR695H | 18872bc | 2019-06-13 16:16:52 -0400 | [diff] [blame] | 25 | ${uuid}= Generate UUID4 |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 26 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} |
| 27 | ${resp}= Get Request aai ${data_path} headers=${headers} |
| 28 | Log Received response from aai ${resp.text} |
| 29 | [Return] ${resp} |
Jerry Flood | fe22bf1 | 2017-04-21 16:53:10 -0400 | [diff] [blame] | 30 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 31 | Run A&AI Put Request |
| 32 | [Documentation] Runs an A&AI put request |
| 33 | [Arguments] ${data_path} ${data} |
Jerry Flood | fe22bf1 | 2017-04-21 16:53:10 -0400 | [diff] [blame] | 34 | Disable Warnings |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 35 | ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 36 | ${session}= Create Session aai ${AAI_FRONTEND_ENDPOINT} auth=${auth} |
DR695H | 18872bc | 2019-06-13 16:16:52 -0400 | [diff] [blame] | 37 | ${uuid}= Generate UUID4 |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 38 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} |
| 39 | ${resp}= Put Request aai ${data_path} data=${data} headers=${headers} |
| 40 | Log Received response from aai ${resp.text} |
| 41 | [Return] ${resp} |
| 42 | |
| 43 | Run A&AI Post Request |
| 44 | [Documentation] Runs an A&AI Post request |
| 45 | [Arguments] ${data_path} ${data} |
Jerry Flood | fe22bf1 | 2017-04-21 16:53:10 -0400 | [diff] [blame] | 46 | Disable Warnings |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 47 | ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 48 | ${session}= Create Session aai ${AAI_FRONTEND_ENDPOINT} auth=${auth} |
DR695H | 18872bc | 2019-06-13 16:16:52 -0400 | [diff] [blame] | 49 | ${uuid}= Generate UUID4 |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 50 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} |
| 51 | ${resp}= Post Request aai ${data_path} data=${data} headers=${headers} |
| 52 | Log Received response from aai ${resp.text} |
| 53 | [Return] ${resp} |
Jerry Flood | fe22bf1 | 2017-04-21 16:53:10 -0400 | [diff] [blame] | 54 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 55 | Run A&AI Delete Request |
| 56 | [Documentation] Runs an A&AI delete request |
| 57 | [Arguments] ${data_path} ${resource_version} |
Jerry Flood | fe22bf1 | 2017-04-21 16:53:10 -0400 | [diff] [blame] | 58 | Disable Warnings |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 59 | ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 60 | ${session}= Create Session aai ${AAI_FRONTEND_ENDPOINT} auth=${auth} |
DR695H | 18872bc | 2019-06-13 16:16:52 -0400 | [diff] [blame] | 61 | ${uuid}= Generate UUID4 |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 62 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} |
| 63 | ${resp}= Delete Request aai ${data_path}?resource-version=${resource_version} headers=${headers} |
| 64 | Log Received response from aai ${resp.text} |
jf9860 | 0f7f265 | 2017-02-22 14:44:06 -0500 | [diff] [blame] | 65 | [Return] ${resp} |
| 66 | |
| 67 | Delete A&AI Entity |
Jerry Flood | fe22bf1 | 2017-04-21 16:53:10 -0400 | [diff] [blame] | 68 | [Documentation] Deletes an entity in A&AI |
jf9860 | 0f7f265 | 2017-02-22 14:44:06 -0500 | [diff] [blame] | 69 | [Arguments] ${uri} |
Keong Lim | 3a5d947 | 2019-03-04 17:15:06 +1100 | [diff] [blame] | 70 | ${get_resp}= Run A&AI Get Request ${VERSIONED_INDEX_PATH}${uri} |
jf9860 | 0f7f265 | 2017-02-22 14:44:06 -0500 | [diff] [blame] | 71 | Run Keyword If '${get_resp.status_code}' == '200' Delete A&AI Entity Exists ${uri} ${get_resp.json()['resource-version']} |
| 72 | |
| 73 | Delete A&AI Entity Exists |
| 74 | [Documentation] Deletes an A&AI entity |
Jerry Flood | fe22bf1 | 2017-04-21 16:53:10 -0400 | [diff] [blame] | 75 | [Arguments] ${uri} ${resource_version_id} |
Keong Lim | 3a5d947 | 2019-03-04 17:15:06 +1100 | [diff] [blame] | 76 | ${put_resp}= Run A&AI Delete Request ${VERSIONED_INDEX_PATH}${uri} ${resource_version_id} |
Jerry Flood | fe22bf1 | 2017-04-21 16:53:10 -0400 | [diff] [blame] | 77 | Should Be Equal As Strings ${put_resp.status_code} 204 |
jf9860 | 0f7f265 | 2017-02-22 14:44:06 -0500 | [diff] [blame] | 78 | |