blob: cbf04676b5328ec1c59f6e0495ac6a4a8b7cd5c2 [file] [log] [blame]
DR695Hccff30b2017-02-17 18:44:24 -05001*** Settings ***
2Documentation Create A&AI Customer API.
DR695Hccff30b2017-02-17 18:44:24 -05003
DR695Hccff30b2017-02-17 18:44:24 -05004Resource aai_interface.robot
DR695Hccff30b2017-02-17 18:44:24 -05005Library Collections
DR695H3bb6cf42019-06-20 15:04:04 -04006Library ONAPLibrary.Utilities
7Library ONAPLibrary.Templating
DR695Hccff30b2017-02-17 18:44:24 -05008
9
10*** Variables ***
Jerry Flood8a6b0b52017-11-12 15:44:21 -050011${INDEX PATH} /aai/v11
DR695Hccff30b2017-02-17 18:44:24 -050012${ROOT_SERVICE_PATH} /service-design-and-creation/services
13
14${SYSTEM USER} robot-ete
DR695H3bb6cf42019-06-20 15:04:04 -040015${AAI_ADD_SERVICE_BODY}= aai/add_service_body.jinja
DR695Hccff30b2017-02-17 18:44:24 -050016
Jerry Flood8a6b0b52017-11-12 15:44:21 -050017*** Keywords ***
DR695Hccff30b2017-02-17 18:44:24 -050018Create Service If Not Exists
Jerry Flood8a6b0b52017-11-12 15:44:21 -050019 [Documentation] Creates a service in A&AI if it doesn't exist
DR695Hccff30b2017-02-17 18:44:24 -050020 [Arguments] ${service_type}
21 ${dict}= Get Services
Jerry Flood8a6b0b52017-11-12 15:44:21 -050022 ${status} ${value}= Run Keyword And Ignore Error Dictionary Should Contain Key ${dict} ${service_type}
DR695Hccff30b2017-02-17 18:44:24 -050023 Run Keyword If '${status}' == 'FAIL' Create Service ${service_type}
Jerry Flood8a6b0b52017-11-12 15:44:21 -050024
DR695Hccff30b2017-02-17 18:44:24 -050025Create Service
Jerry Flood8a6b0b52017-11-12 15:44:21 -050026 [Documentation] Creates a service in A&AI
DR695Hccff30b2017-02-17 18:44:24 -050027 [Arguments] ${service_type}
DR695H18872bc2019-06-13 16:16:52 -040028 ${uuid}= Generate UUID4
Jerry Flood8a6b0b52017-11-12 15:44:21 -050029 ${arguments}= Create Dictionary service_type=${service_type} UUID=${uuid}
DR695H3bb6cf42019-06-20 15:04:04 -040030 Create Environment aai ${GLOBAL_TEMPLATE_FOLDER}
31 ${data}= Apply Template aai ${AAI_ADD_SERVICE_BODY} ${arguments}
DR695Hccff30b2017-02-17 18:44:24 -050032 ${fullpath}= Catenate ${INDEX PATH}${ROOT_SERVICE_PATH}/service/${uuid}
33 ${put_resp}= Run A&AI Put Request ${fullpath} ${data}
34 Should Be Equal As Strings ${put_resp.status_code} 201
35 [Return] ${put_resp.status_code}
36
Jerry Flood8a6b0b52017-11-12 15:44:21 -050037
DR695Hccff30b2017-02-17 18:44:24 -050038Delete Service If Exists
Jerry Flood8a6b0b52017-11-12 15:44:21 -050039 [Documentation] Deletes a service in A&AI if it exists
DR695Hccff30b2017-02-17 18:44:24 -050040 [Arguments] ${service_type}
41 ${dict}= Get Services
Jerry Flood8a6b0b52017-11-12 15:44:21 -050042 ${status} ${value}= Run Keyword And Ignore Error Dictionary Should Contain Key ${dict} ${service_type}
DR695Hccff30b2017-02-17 18:44:24 -050043 Run Keyword If '${status}' == 'PASS' Delete Service ${dict['${service_type}']}
44
45Delete Service
Jerry Flood8a6b0b52017-11-12 15:44:21 -050046 [Documentation] Delete passed service in A&AI
DR695Hccff30b2017-02-17 18:44:24 -050047 [Arguments] ${dict}
Jerry Flood8a6b0b52017-11-12 15:44:21 -050048 ${uuid}= Get From Dictionary ${dict} service-id
DR695Hccff30b2017-02-17 18:44:24 -050049 ${resource_version}= Get From Dictionary ${dict} resource-version
50 ${fullpath}= Catenate ${INDEX PATH}${ROOT_SERVICE_PATH}/service/${uuid}
Jerry Flood8a6b0b52017-11-12 15:44:21 -050051 ${resp}= Run A&AI Delete Request ${fullpath} ${resource_version}
DR695Hccff30b2017-02-17 18:44:24 -050052 Should Be Equal As Strings ${resp.status_code} 204
53
Jerry Flood8a6b0b52017-11-12 15:44:21 -050054
DR695Hccff30b2017-02-17 18:44:24 -050055Get Services
Jerry Flood8a6b0b52017-11-12 15:44:21 -050056 [Documentation] Creates a service in A&AI
DR695Hccff30b2017-02-17 18:44:24 -050057 ${resp}= Run A&AI Get Request ${INDEX PATH}${ROOT_SERVICE_PATH}
Jerry Flood8a6b0b52017-11-12 15:44:21 -050058 ${dict}= Create Dictionary
DR695Hccff30b2017-02-17 18:44:24 -050059 ${status} ${value}= Run Keyword And Ignore Error Should Be Equal As Strings ${resp.status_code} 200
Jerry Flood8a6b0b52017-11-12 15:44:21 -050060 Run Keyword If '${status}' == 'PASS' Update Service Dictionary ${dict} ${resp.json()}
DR695Hccff30b2017-02-17 18:44:24 -050061 [Return] ${dict}
62
63Update Service Dictionary
64 [Arguments] ${dict} ${json}
65 ${list}= Evaluate ${json}['service']
DR695H910097e2019-05-08 13:55:32 -040066 :FOR ${map} IN @{list}
DR695Hccff30b2017-02-17 18:44:24 -050067 \ ${status} ${service_type}= Run Keyword And Ignore Error Get From Dictionary ${map} service-description
Jerry Flood8a6b0b52017-11-12 15:44:21 -050068 \ Run Keyword If '${status}' == 'PASS' Set To Dictionary ${dict} ${service_type}=${map}
DR695Hccff30b2017-02-17 18:44:24 -050069 Log ${dict}
70
71