blob: c0600064a6ef84999e94ced712a837c4c178ab5d [file] [log] [blame]
DR695Hccff30b2017-02-17 18:44:24 -05001*** Settings ***
2Documentation The main interface for interacting with A&AI. It handles low level stuff like managing the http request library and A&AI required fields
3Library RequestsLibrary
Jerry Floodfe22bf12017-04-21 16:53:10 -04004Library UUID
5Library HTTPUtils
DR695Hccff30b2017-02-17 18:44:24 -05006Resource ../global_properties.robot
7
8*** Variables ***
9${AAI_HEALTH_PATH} /aai/util/echo?action=long
Jerry Flood8a6b0b52017-11-12 15:44:21 -050010${VERSIONED_INDEX_PATH} /aai/v11
DR695Hbf5a3a32017-06-30 13:09:57 -040011${AAI_FRONTEND_ENDPOINT} ${GLOBAL_AAI_SERVER_PROTOCOL}://${GLOBAL_INJECTED_AAI1_IP_ADDR}:${GLOBAL_AAI_SERVER_PORT}
12
DR695Hccff30b2017-02-17 18:44:24 -050013
14*** Keywords ***
15Run A&AI Health Check
16 [Documentation] Runs an A&AI health check
Jerry Floodfe22bf12017-04-21 16:53:10 -040017 ${resp}= Run A&AI Get Request ${AAI_HEALTH_PATH}
DR695Hccff30b2017-02-17 18:44:24 -050018 Should Be Equal As Strings ${resp.status_code} 200
19
20Run A&AI Get Request
21 [Documentation] Runs an A&AI get request
22 [Arguments] ${data_path}
Jerry Floodfe22bf12017-04-21 16:53:10 -040023 Disable Warnings
DR695Hccff30b2017-02-17 18:44:24 -050024 ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD}
DR695Hbf5a3a32017-06-30 13:09:57 -040025 ${session}= Create Session aai ${AAI_FRONTEND_ENDPOINT} auth=${auth}
DR695Hccff30b2017-02-17 18:44:24 -050026 ${uuid}= Generate UUID
27 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
28 ${resp}= Get Request aai ${data_path} headers=${headers}
29 Log Received response from aai ${resp.text}
30 [Return] ${resp}
Jerry Floodfe22bf12017-04-21 16:53:10 -040031
DR695Hccff30b2017-02-17 18:44:24 -050032Run A&AI Put Request
33 [Documentation] Runs an A&AI put request
34 [Arguments] ${data_path} ${data}
Jerry Floodfe22bf12017-04-21 16:53:10 -040035 Disable Warnings
DR695Hccff30b2017-02-17 18:44:24 -050036 ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD}
DR695Hbf5a3a32017-06-30 13:09:57 -040037 ${session}= Create Session aai ${AAI_FRONTEND_ENDPOINT} auth=${auth}
DR695Hccff30b2017-02-17 18:44:24 -050038 ${uuid}= Generate UUID
39 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
40 ${resp}= Put Request aai ${data_path} data=${data} headers=${headers}
41 Log Received response from aai ${resp.text}
42 [Return] ${resp}
43
44Run A&AI Post Request
45 [Documentation] Runs an A&AI Post request
46 [Arguments] ${data_path} ${data}
Jerry Floodfe22bf12017-04-21 16:53:10 -040047 Disable Warnings
DR695Hccff30b2017-02-17 18:44:24 -050048 ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD}
DR695Hbf5a3a32017-06-30 13:09:57 -040049 ${session}= Create Session aai ${AAI_FRONTEND_ENDPOINT} auth=${auth}
DR695Hccff30b2017-02-17 18:44:24 -050050 ${uuid}= Generate UUID
51 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
52 ${resp}= Post Request aai ${data_path} data=${data} headers=${headers}
53 Log Received response from aai ${resp.text}
54 [Return] ${resp}
Jerry Floodfe22bf12017-04-21 16:53:10 -040055
DR695Hccff30b2017-02-17 18:44:24 -050056Run A&AI Delete Request
57 [Documentation] Runs an A&AI delete request
58 [Arguments] ${data_path} ${resource_version}
Jerry Floodfe22bf12017-04-21 16:53:10 -040059 Disable Warnings
DR695Hccff30b2017-02-17 18:44:24 -050060 ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD}
DR695Hbf5a3a32017-06-30 13:09:57 -040061 ${session}= Create Session aai ${AAI_FRONTEND_ENDPOINT} auth=${auth}
DR695Hccff30b2017-02-17 18:44:24 -050062 ${uuid}= Generate UUID
63 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
64 ${resp}= Delete Request aai ${data_path}?resource-version=${resource_version} headers=${headers}
65 Log Received response from aai ${resp.text}
jf98600f7f2652017-02-22 14:44:06 -050066 [Return] ${resp}
67
68Delete A&AI Entity
Jerry Floodfe22bf12017-04-21 16:53:10 -040069 [Documentation] Deletes an entity in A&AI
jf98600f7f2652017-02-22 14:44:06 -050070 [Arguments] ${uri}
Keong Lim3a5d9472019-03-04 17:15:06 +110071 ${get_resp}= Run A&AI Get Request ${VERSIONED_INDEX_PATH}${uri}
jf98600f7f2652017-02-22 14:44:06 -050072 Run Keyword If '${get_resp.status_code}' == '200' Delete A&AI Entity Exists ${uri} ${get_resp.json()['resource-version']}
73
74Delete A&AI Entity Exists
75 [Documentation] Deletes an A&AI entity
Jerry Floodfe22bf12017-04-21 16:53:10 -040076 [Arguments] ${uri} ${resource_version_id}
Keong Lim3a5d9472019-03-04 17:15:06 +110077 ${put_resp}= Run A&AI Delete Request ${VERSIONED_INDEX_PATH}${uri} ${resource_version_id}
Jerry Floodfe22bf12017-04-21 16:53:10 -040078 Should Be Equal As Strings ${put_resp.status_code} 204
jf98600f7f2652017-02-22 14:44:06 -050079