2 Documentation Create A&AI Customer API.
4 Resource aai_interface.robot
6 Library ONAPLibrary.Utilities
7 Library ONAPLibrary.Templating WITH NAME Templating
8 Library ONAPLibrary.AAI WITH NAME AAI
12 ${INDEX PATH} /aai/v11
13 ${ROOT_SERVICE_PATH} /service-design-and-creation/services
15 ${SYSTEM USER} robot-ete
16 ${AAI_ADD_SERVICE_BODY}= aai/add_service_body.jinja
19 Create Service If Not Exists
20 [Documentation] Creates a service in A&AI if it doesn't exist
21 [Arguments] ${service_type}
23 ${status} ${value}= Run Keyword And Ignore Error Dictionary Should Contain Key ${dict} ${service_type}
24 Run Keyword If '${status}' == 'FAIL' Create Service ${service_type}
27 [Documentation] Creates a service in A&AI
28 [Arguments] ${service_type}
29 ${uuid}= Generate UUID4
30 ${arguments}= Create Dictionary service_type=${service_type} UUID=${uuid}
31 Templating.Create Environment aai ${GLOBAL_TEMPLATE_FOLDER}
32 ${data}= Templating.Apply Template aai ${AAI_ADD_SERVICE_BODY} ${arguments}
33 ${fullpath}= Catenate ${INDEX PATH}${ROOT_SERVICE_PATH}/service/${uuid}
34 ${put_resp}= AAI.Run Put Request ${AAI_FRONTEND_ENDPOINT} ${fullpath} ${data} auth=${GLOBAL_AAI_AUTHENTICATION}
35 Should Be Equal As Strings ${put_resp.status_code} 201
36 [Return] ${put_resp.status_code}
38 Delete Service If Exists
39 [Documentation] Deletes a service in A&AI if it exists
40 [Arguments] ${service_type}
42 ${status} ${value}= Run Keyword And Ignore Error Dictionary Should Contain Key ${dict} ${service_type}
43 Run Keyword If '${status}' == 'PASS' Delete Service ${dict['${service_type}']}
46 [Documentation] Delete passed service in A&AI
48 ${uuid}= Get From Dictionary ${dict} service-id
49 ${resource_version}= Get From Dictionary ${dict} resource-version
50 ${fullpath}= Catenate ${INDEX PATH}${ROOT_SERVICE_PATH}/service/${uuid}
51 ${resp}= AAI.Run Delete Request ${AAI_FRONTEND_ENDPOINT} ${fullpath} ${resource_version} auth=${GLOBAL_AAI_AUTHENTICATION}
52 Should Be Equal As Strings ${resp.status_code} 204
55 [Documentation] Creates a service in A&AI
56 ${resp}= AAI.Run Get Request ${AAI_FRONTEND_ENDPOINT} ${INDEX PATH}${ROOT_SERVICE_PATH} auth=${GLOBAL_AAI_AUTHENTICATION}
57 ${dict}= Create Dictionary
58 ${status} ${value}= Run Keyword And Ignore Error Should Be Equal As Strings ${resp.status_code} 200
59 Run Keyword If '${status}' == 'PASS' Update Service Dictionary ${dict} ${resp.json()}
63 [Documentation] Gets a service id in A&AI
64 [Arguments] ${service_description}
65 ${resp}= AAI.Run Get Request ${AAI_FRONTEND_ENDPOINT} ${INDEX PATH}${ROOT_SERVICE_PATH} auth=${GLOBAL_AAI_AUTHENTICATION}
66 ${resp_json}= Set Variable ${resp.json()}
68 @{list}= Copy List ${resp_json['service']}
69 :FOR ${map} IN @{list}
70 \ ${service_type}= Get From Dictionary ${map} service-description
71 \ ${service_id}= Get From Dictionary ${map} service-id
72 \ ${id} Run Keyword If '${service_type}' == '${service_description}' Set Variable ${service_id}
75 Update Service Dictionary
76 [Arguments] ${dict} ${json}
77 @{list}= Copy List ${json['service']}
78 :FOR ${map} IN @{list}
79 \ ${status} ${service_type}= Run Keyword And Ignore Error Get From Dictionary ${map} service-description
80 \ Run Keyword If '${status}' == 'PASS' Set To Dictionary ${dict} ${service_type}=${map}