blob: 5580033f69ac502625b651a846780077fcf29753 [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
DR695H18872bc2019-06-13 16:16:52 -04004Library ONAPLibrary.Utilities
DR695Hccff30b2017-02-17 18:44:24 -05005Resource ../global_properties.robot
6
7*** Variables ***
8${AAI_HEALTH_PATH} /aai/util/echo?action=long
Jerry Flood8a6b0b52017-11-12 15:44:21 -05009${VERSIONED_INDEX_PATH} /aai/v11
DR695Hbf5a3a32017-06-30 13:09:57 -040010${AAI_FRONTEND_ENDPOINT} ${GLOBAL_AAI_SERVER_PROTOCOL}://${GLOBAL_INJECTED_AAI1_IP_ADDR}:${GLOBAL_AAI_SERVER_PORT}
11
DR695Hccff30b2017-02-17 18:44:24 -050012
13*** Keywords ***
14Run A&AI Health Check
15 [Documentation] Runs an A&AI health check
Jerry Floodfe22bf12017-04-21 16:53:10 -040016 ${resp}= Run A&AI Get Request ${AAI_HEALTH_PATH}
DR695Hccff30b2017-02-17 18:44:24 -050017 Should Be Equal As Strings ${resp.status_code} 200
18
19Run A&AI Get Request
20 [Documentation] Runs an A&AI get request
21 [Arguments] ${data_path}
Jerry Floodfe22bf12017-04-21 16:53:10 -040022 Disable Warnings
DR695Hccff30b2017-02-17 18:44:24 -050023 ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD}
DR695Hbf5a3a32017-06-30 13:09:57 -040024 ${session}= Create Session aai ${AAI_FRONTEND_ENDPOINT} auth=${auth}
DR695H18872bc2019-06-13 16:16:52 -040025 ${uuid}= Generate UUID4
DR695Hccff30b2017-02-17 18:44:24 -050026 ${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 Floodfe22bf12017-04-21 16:53:10 -040030
DR695Hccff30b2017-02-17 18:44:24 -050031Run A&AI Put Request
32 [Documentation] Runs an A&AI put request
33 [Arguments] ${data_path} ${data}
Jerry Floodfe22bf12017-04-21 16:53:10 -040034 Disable Warnings
DR695Hccff30b2017-02-17 18:44:24 -050035 ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD}
DR695Hbf5a3a32017-06-30 13:09:57 -040036 ${session}= Create Session aai ${AAI_FRONTEND_ENDPOINT} auth=${auth}
DR695H18872bc2019-06-13 16:16:52 -040037 ${uuid}= Generate UUID4
DR695Hccff30b2017-02-17 18:44:24 -050038 ${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
43Run A&AI Post Request
44 [Documentation] Runs an A&AI Post request
45 [Arguments] ${data_path} ${data}
Jerry Floodfe22bf12017-04-21 16:53:10 -040046 Disable Warnings
DR695Hccff30b2017-02-17 18:44:24 -050047 ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD}
DR695Hbf5a3a32017-06-30 13:09:57 -040048 ${session}= Create Session aai ${AAI_FRONTEND_ENDPOINT} auth=${auth}
DR695H18872bc2019-06-13 16:16:52 -040049 ${uuid}= Generate UUID4
DR695Hccff30b2017-02-17 18:44:24 -050050 ${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 Floodfe22bf12017-04-21 16:53:10 -040054
DR695Hccff30b2017-02-17 18:44:24 -050055Run A&AI Delete Request
56 [Documentation] Runs an A&AI delete request
57 [Arguments] ${data_path} ${resource_version}
Jerry Floodfe22bf12017-04-21 16:53:10 -040058 Disable Warnings
DR695Hccff30b2017-02-17 18:44:24 -050059 ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD}
DR695Hbf5a3a32017-06-30 13:09:57 -040060 ${session}= Create Session aai ${AAI_FRONTEND_ENDPOINT} auth=${auth}
DR695H18872bc2019-06-13 16:16:52 -040061 ${uuid}= Generate UUID4
DR695Hccff30b2017-02-17 18:44:24 -050062 ${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}
jf98600f7f2652017-02-22 14:44:06 -050065 [Return] ${resp}
66
67Delete A&AI Entity
Jerry Floodfe22bf12017-04-21 16:53:10 -040068 [Documentation] Deletes an entity in A&AI
jf98600f7f2652017-02-22 14:44:06 -050069 [Arguments] ${uri}
Keong Lim3a5d9472019-03-04 17:15:06 +110070 ${get_resp}= Run A&AI Get Request ${VERSIONED_INDEX_PATH}${uri}
jf98600f7f2652017-02-22 14:44:06 -050071 Run Keyword If '${get_resp.status_code}' == '200' Delete A&AI Entity Exists ${uri} ${get_resp.json()['resource-version']}
72
73Delete A&AI Entity Exists
74 [Documentation] Deletes an A&AI entity
Jerry Floodfe22bf12017-04-21 16:53:10 -040075 [Arguments] ${uri} ${resource_version_id}
Keong Lim3a5d9472019-03-04 17:15:06 +110076 ${put_resp}= Run A&AI Delete Request ${VERSIONED_INDEX_PATH}${uri} ${resource_version_id}
Jerry Floodfe22bf12017-04-21 16:53:10 -040077 Should Be Equal As Strings ${put_resp.status_code} 204
jf98600f7f2652017-02-22 14:44:06 -050078