blob: 49f98f0cbe74b123e0154737288ffa3f07c27a4f [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
jf98600f7f2652017-02-22 14:44:06 -050010${VERSIONED_INDEX_PATH} /aai/v8
DR695Hccff30b2017-02-17 18:44:24 -050011
12*** Keywords ***
13Run A&AI Health Check
14 [Documentation] Runs an A&AI health check
Jerry Floodfe22bf12017-04-21 16:53:10 -040015 ${resp}= Run A&AI Get Request ${AAI_HEALTH_PATH}
DR695Hccff30b2017-02-17 18:44:24 -050016 Should Be Equal As Strings ${resp.status_code} 200
17
18Run A&AI Get Request
19 [Documentation] Runs an A&AI get request
20 [Arguments] ${data_path}
Jerry Floodfe22bf12017-04-21 16:53:10 -040021 Disable Warnings
DR695Hccff30b2017-02-17 18:44:24 -050022 ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD}
23 ${session}= Create Session aai ${GLOBAL_AAI_SERVER_URL} auth=${auth}
24 ${uuid}= Generate UUID
25 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
26 ${resp}= Get Request aai ${data_path} headers=${headers}
27 Log Received response from aai ${resp.text}
28 [Return] ${resp}
Jerry Floodfe22bf12017-04-21 16:53:10 -040029
DR695Hccff30b2017-02-17 18:44:24 -050030Run A&AI Put Request
31 [Documentation] Runs an A&AI put request
32 [Arguments] ${data_path} ${data}
Jerry Floodfe22bf12017-04-21 16:53:10 -040033 Disable Warnings
DR695Hccff30b2017-02-17 18:44:24 -050034 ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD}
35 ${session}= Create Session aai ${GLOBAL_AAI_SERVER_URL} auth=${auth}
36 ${uuid}= Generate UUID
37 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
38 ${resp}= Put Request aai ${data_path} data=${data} headers=${headers}
39 Log Received response from aai ${resp.text}
40 [Return] ${resp}
41
42Run A&AI Post Request
43 [Documentation] Runs an A&AI Post request
44 [Arguments] ${data_path} ${data}
Jerry Floodfe22bf12017-04-21 16:53:10 -040045 Disable Warnings
DR695Hccff30b2017-02-17 18:44:24 -050046 ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD}
47 ${session}= Create Session aai ${GLOBAL_AAI_SERVER_URL} auth=${auth}
48 ${uuid}= Generate UUID
49 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
50 ${resp}= Post Request aai ${data_path} data=${data} headers=${headers}
51 Log Received response from aai ${resp.text}
52 [Return] ${resp}
Jerry Floodfe22bf12017-04-21 16:53:10 -040053
DR695Hccff30b2017-02-17 18:44:24 -050054Run A&AI Delete Request
55 [Documentation] Runs an A&AI delete request
56 [Arguments] ${data_path} ${resource_version}
Jerry Floodfe22bf12017-04-21 16:53:10 -040057 Disable Warnings
DR695Hccff30b2017-02-17 18:44:24 -050058 ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD}
59 ${session}= Create Session aai ${GLOBAL_AAI_SERVER_URL} auth=${auth}
60 ${uuid}= Generate UUID
61 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
62 ${resp}= Delete Request aai ${data_path}?resource-version=${resource_version} headers=${headers}
63 Log Received response from aai ${resp.text}
jf98600f7f2652017-02-22 14:44:06 -050064 [Return] ${resp}
65
66Delete A&AI Entity
Jerry Floodfe22bf12017-04-21 16:53:10 -040067 [Documentation] Deletes an entity in A&AI
jf98600f7f2652017-02-22 14:44:06 -050068 [Arguments] ${uri}
Jerry Floodfe22bf12017-04-21 16:53:10 -040069 ${get_resp}= Run A&AI Get Request ${VERSIONED_INDEX PATH}${uri}
jf98600f7f2652017-02-22 14:44:06 -050070 Run Keyword If '${get_resp.status_code}' == '200' Delete A&AI Entity Exists ${uri} ${get_resp.json()['resource-version']}
71
72Delete A&AI Entity Exists
73 [Documentation] Deletes an A&AI entity
Jerry Floodfe22bf12017-04-21 16:53:10 -040074 [Arguments] ${uri} ${resource_version_id}
jf98600f7f2652017-02-22 14:44:06 -050075 ${put_resp}= Run A&AI Delete Request ${VERSIONED_INDEX PATH}${uri} ${resource_version_id}
Jerry Floodfe22bf12017-04-21 16:53:10 -040076 Should Be Equal As Strings ${put_resp.status_code} 204
jf98600f7f2652017-02-22 14:44:06 -050077