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 |
| 4 | Library UUID |
| 5 | Resource ../global_properties.robot |
| 6 | |
| 7 | *** Variables *** |
| 8 | ${AAI_HEALTH_PATH} /aai/util/echo?action=long |
jf9860 | 0f7f265 | 2017-02-22 14:44:06 -0500 | [diff] [blame] | 9 | ${VERSIONED_INDEX_PATH} /aai/v8 |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 10 | |
| 11 | *** Keywords *** |
| 12 | Run A&AI Health Check |
| 13 | [Documentation] Runs an A&AI health check |
| 14 | ${resp}= Run A&AI Get Request ${AAI_HEALTH_PATH} |
| 15 | Should Be Equal As Strings ${resp.status_code} 200 |
| 16 | |
| 17 | Run A&AI Get Request |
| 18 | [Documentation] Runs an A&AI get request |
| 19 | [Arguments] ${data_path} |
| 20 | ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD} |
| 21 | ${session}= Create Session aai ${GLOBAL_AAI_SERVER_URL} auth=${auth} |
| 22 | ${uuid}= Generate UUID |
| 23 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} |
| 24 | ${resp}= Get Request aai ${data_path} headers=${headers} |
| 25 | Log Received response from aai ${resp.text} |
| 26 | [Return] ${resp} |
| 27 | |
| 28 | Run A&AI Put Request |
| 29 | [Documentation] Runs an A&AI put request |
| 30 | [Arguments] ${data_path} ${data} |
| 31 | ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD} |
| 32 | ${session}= Create Session aai ${GLOBAL_AAI_SERVER_URL} auth=${auth} |
| 33 | ${uuid}= Generate UUID |
| 34 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} |
| 35 | ${resp}= Put Request aai ${data_path} data=${data} headers=${headers} |
| 36 | Log Received response from aai ${resp.text} |
| 37 | [Return] ${resp} |
| 38 | |
| 39 | Run A&AI Post Request |
| 40 | [Documentation] Runs an A&AI Post request |
| 41 | [Arguments] ${data_path} ${data} |
| 42 | ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD} |
| 43 | ${session}= Create Session aai ${GLOBAL_AAI_SERVER_URL} auth=${auth} |
| 44 | ${uuid}= Generate UUID |
| 45 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} |
| 46 | ${resp}= Post Request aai ${data_path} data=${data} headers=${headers} |
| 47 | Log Received response from aai ${resp.text} |
| 48 | [Return] ${resp} |
| 49 | |
| 50 | Run A&AI Delete Request |
| 51 | [Documentation] Runs an A&AI delete request |
| 52 | [Arguments] ${data_path} ${resource_version} |
| 53 | ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD} |
| 54 | ${session}= Create Session aai ${GLOBAL_AAI_SERVER_URL} auth=${auth} |
| 55 | ${uuid}= Generate UUID |
| 56 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} |
| 57 | ${resp}= Delete Request aai ${data_path}?resource-version=${resource_version} headers=${headers} |
| 58 | Log Received response from aai ${resp.text} |
jf9860 | 0f7f265 | 2017-02-22 14:44:06 -0500 | [diff] [blame] | 59 | [Return] ${resp} |
| 60 | |
| 61 | Delete A&AI Entity |
| 62 | [Documentation] Deletes an entity in A&AI |
| 63 | [Arguments] ${uri} |
| 64 | ${get_resp}= Run A&AI Get Request ${VERSIONED_INDEX PATH}${uri} |
| 65 | Run Keyword If '${get_resp.status_code}' == '200' Delete A&AI Entity Exists ${uri} ${get_resp.json()['resource-version']} |
| 66 | |
| 67 | Delete A&AI Entity Exists |
| 68 | [Documentation] Deletes an A&AI entity |
| 69 | [Arguments] ${uri} ${resource_version_id} |
| 70 | ${put_resp}= Run A&AI Delete Request ${VERSIONED_INDEX PATH}${uri} ${resource_version_id} |
| 71 | Should Be Equal As Strings ${put_resp.status_code} 204 |
| 72 | |
| 73 | |