blob: 11979f0b06138177315cd7c22a68fb9042366d88 [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
4Library UUID
5Resource ../global_properties.robot
6
7*** Variables ***
8${AAI_HEALTH_PATH} /aai/util/echo?action=long
jf98600f7f2652017-02-22 14:44:06 -05009${VERSIONED_INDEX_PATH} /aai/v8
DR695Hccff30b2017-02-17 18:44:24 -050010
11*** Keywords ***
12Run 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
17Run 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
28Run 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
39Run 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
50Run 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}
jf98600f7f2652017-02-22 14:44:06 -050059 [Return] ${resp}
60
61Delete 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
67Delete 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