blob: 0584a2a1a1e4286399cde12dbacf669f2e4f63fc [file] [log] [blame]
DR695Hccff30b2017-02-17 18:44:24 -05001*** Settings ***
2Documentation Create A&AI Customer API.
3...
4... Create A&AI Customer API
5
6Resource ../json_templater.robot
7Resource aai_interface.robot
DR695Hccff30b2017-02-17 18:44:24 -05008Library Collections
DR695H18872bc2019-06-13 16:16:52 -04009Library ONAPLibrary.Utilities
DR695Hccff30b2017-02-17 18:44:24 -050010
11
12
13*** Variables ***
Jerry Flood8a6b0b52017-11-12 15:44:21 -050014${INDEX PATH} /aai/v11
DR695Hccff30b2017-02-17 18:44:24 -050015${ROOT_SERVICE_PATH} /service-design-and-creation/services
16
17${SYSTEM USER} robot-ete
18${AAI_ADD_SERVICE_BODY}= robot/assets/templates/aai/add_service_body.template
19
Jerry Flood8a6b0b52017-11-12 15:44:21 -050020*** Keywords ***
DR695Hccff30b2017-02-17 18:44:24 -050021Create Service If Not Exists
Jerry Flood8a6b0b52017-11-12 15:44:21 -050022 [Documentation] Creates a service in A&AI if it doesn't exist
DR695Hccff30b2017-02-17 18:44:24 -050023 [Arguments] ${service_type}
24 ${dict}= Get Services
Jerry Flood8a6b0b52017-11-12 15:44:21 -050025 ${status} ${value}= Run Keyword And Ignore Error Dictionary Should Contain Key ${dict} ${service_type}
DR695Hccff30b2017-02-17 18:44:24 -050026 Run Keyword If '${status}' == 'FAIL' Create Service ${service_type}
Jerry Flood8a6b0b52017-11-12 15:44:21 -050027
DR695Hccff30b2017-02-17 18:44:24 -050028Create Service
Jerry Flood8a6b0b52017-11-12 15:44:21 -050029 [Documentation] Creates a service in A&AI
DR695Hccff30b2017-02-17 18:44:24 -050030 [Arguments] ${service_type}
DR695H18872bc2019-06-13 16:16:52 -040031 ${uuid}= Generate UUID4
Jerry Flood8a6b0b52017-11-12 15:44:21 -050032 ${arguments}= Create Dictionary service_type=${service_type} UUID=${uuid}
DR695Hdaec16c2019-06-19 17:40:26 -040033 ${data}= Fill JSON Template File ${AAI_ADD_SERVICE_BODY} ${arguments}
DR695Hccff30b2017-02-17 18:44:24 -050034 ${fullpath}= Catenate ${INDEX PATH}${ROOT_SERVICE_PATH}/service/${uuid}
35 ${put_resp}= Run A&AI Put Request ${fullpath} ${data}
36 Should Be Equal As Strings ${put_resp.status_code} 201
37 [Return] ${put_resp.status_code}
38
Jerry Flood8a6b0b52017-11-12 15:44:21 -050039
DR695Hccff30b2017-02-17 18:44:24 -050040Delete Service If Exists
Jerry Flood8a6b0b52017-11-12 15:44:21 -050041 [Documentation] Deletes a service in A&AI if it exists
DR695Hccff30b2017-02-17 18:44:24 -050042 [Arguments] ${service_type}
43 ${dict}= Get Services
Jerry Flood8a6b0b52017-11-12 15:44:21 -050044 ${status} ${value}= Run Keyword And Ignore Error Dictionary Should Contain Key ${dict} ${service_type}
DR695Hccff30b2017-02-17 18:44:24 -050045 Run Keyword If '${status}' == 'PASS' Delete Service ${dict['${service_type}']}
46
47Delete Service
Jerry Flood8a6b0b52017-11-12 15:44:21 -050048 [Documentation] Delete passed service in A&AI
DR695Hccff30b2017-02-17 18:44:24 -050049 [Arguments] ${dict}
Jerry Flood8a6b0b52017-11-12 15:44:21 -050050 ${uuid}= Get From Dictionary ${dict} service-id
DR695Hccff30b2017-02-17 18:44:24 -050051 ${resource_version}= Get From Dictionary ${dict} resource-version
52 ${fullpath}= Catenate ${INDEX PATH}${ROOT_SERVICE_PATH}/service/${uuid}
Jerry Flood8a6b0b52017-11-12 15:44:21 -050053 ${resp}= Run A&AI Delete Request ${fullpath} ${resource_version}
DR695Hccff30b2017-02-17 18:44:24 -050054 Should Be Equal As Strings ${resp.status_code} 204
55
Jerry Flood8a6b0b52017-11-12 15:44:21 -050056
DR695Hccff30b2017-02-17 18:44:24 -050057Get Services
Jerry Flood8a6b0b52017-11-12 15:44:21 -050058 [Documentation] Creates a service in A&AI
DR695Hccff30b2017-02-17 18:44:24 -050059 ${resp}= Run A&AI Get Request ${INDEX PATH}${ROOT_SERVICE_PATH}
Jerry Flood8a6b0b52017-11-12 15:44:21 -050060 ${dict}= Create Dictionary
DR695Hccff30b2017-02-17 18:44:24 -050061 ${status} ${value}= Run Keyword And Ignore Error Should Be Equal As Strings ${resp.status_code} 200
Jerry Flood8a6b0b52017-11-12 15:44:21 -050062 Run Keyword If '${status}' == 'PASS' Update Service Dictionary ${dict} ${resp.json()}
DR695Hccff30b2017-02-17 18:44:24 -050063 [Return] ${dict}
64
65Update Service Dictionary
66 [Arguments] ${dict} ${json}
67 ${list}= Evaluate ${json}['service']
DR695H910097e2019-05-08 13:55:32 -040068 :FOR ${map} IN @{list}
DR695Hccff30b2017-02-17 18:44:24 -050069 \ ${status} ${service_type}= Run Keyword And Ignore Error Get From Dictionary ${map} service-description
Jerry Flood8a6b0b52017-11-12 15:44:21 -050070 \ Run Keyword If '${status}' == 'PASS' Set To Dictionary ${dict} ${service_type}=${map}
DR695Hccff30b2017-02-17 18:44:24 -050071 Log ${dict}
72
73