2 Documentation Create A&AI Customer API.
4 Resource aai_interface.robot
5 Library OperatingSystem
7 Library ONAPLibrary.Templating
11 ${ZONE_INDEX_PATH} /aai/v11
12 ${ROOT_ZONE_PATH} /network/zones/zone
14 ${AAI_ADD_ZONE_BODY}= aai/add_zone_body.jinja
17 Inventory Zone If Not Exists
18 [Documentation] Creates a service in A&AI if it doesn't exist
19 [Arguments] ${zone_id}=${GLOBAL_AAI_ZONE_ID} ${zone_name}=${GLOBAL_AAI_ZONE_NAME} ${design_type}=${GLOBAL_AAI_DESIGN_TYPE} ${zone_context}=${GLOBAL_AAI_ZONE_CONTEXT}
20 ${get_resp}= Run A&AI Get Request ${ZONE_INDEX_PATH}${ROOT_ZONE_PATH}/${zone_id}
21 Return From Keyword If '${get_resp.status_code}' == '200'
22 Inventory Zone ${zone_id} ${zone_name} ${design_type} ${zone_context}
25 [Documentation] Inventorys a Tenant in A&AI
26 [Arguments] ${zone_id} ${zone_name} ${design_type} ${zone_context}
27 ${arguments}= Create Dictionary zone_id=${zone_id} zone_name=${zone_name} design_type=${design_type} zone_context=${zone_context}
28 Create Environment aai ${GLOBAL_TEMPLATE_FOLDER}
29 ${data}= Apply Template aai ${AAI_ADD_ZONE_BODY} ${arguments}
30 ${put_resp}= Run A&AI Put Request ${ZONE_INDEX_PATH}${ROOT_ZONE_PATH}/${zone_id} ${data}
31 ${status_string}= Convert To String ${put_resp.status_code}
32 Should Match Regexp ${status_string} ^(201|200)$
35 [Documentation] Removes both Tenant
36 [Arguments] ${zone_id}=${GLOBAL_AAI_ZONE_ID}
37 ${get_resp}= Run A&AI Get Request ${ZONE_INDEX_PATH}${ROOT_ZONE_PATH}/${zone_id}
38 Run Keyword If '${get_resp.status_code}' == '200' Delete Zone Exists ${zone_id} ${get_resp.json()}
41 [Arguments] ${zone_id} ${json}
42 ${resource_version}= Catenate ${json['resource-version']}
43 ${put_resp}= Run A&AI Delete Request ${ZONE_INDEX_PATH}${ROOT_ZONE_PATH}/${zone_id} ${resource_version}
44 Should Be Equal As Strings ${put_resp.status_code} 204
47 [Documentation] Return zone
48 [Arguments] ${zone_id}
49 ${resp}= Run A&AI Get Request ${ZONE_INDEX_PATH}${ROOT_ZONE_PATH}/${zone_id}
50 Should Be Equal As Strings ${resp.status_code} 200
51 [Return] ${resp.json()}