blob: bcf14e3d09fdb458aaf26a0c23263ae468337504 [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
8Library OperatingSystem
9Library Collections
10Library UUID
11
12
13
14*** Variables ***
Jerry Flood8a6b0b52017-11-12 15:44:21 -050015${INDEX PATH} /aai/v11
DR695Hccff30b2017-02-17 18:44:24 -050016${ROOT_SERVICE_PATH} /service-design-and-creation/services
17
18${SYSTEM USER} robot-ete
19${AAI_ADD_SERVICE_BODY}= robot/assets/templates/aai/add_service_body.template
20
Jerry Flood8a6b0b52017-11-12 15:44:21 -050021*** Keywords ***
DR695Hccff30b2017-02-17 18:44:24 -050022Create Service If Not Exists
Jerry Flood8a6b0b52017-11-12 15:44:21 -050023 [Documentation] Creates a service in A&AI if it doesn't exist
DR695Hccff30b2017-02-17 18:44:24 -050024 [Arguments] ${service_type}
25 ${dict}= Get Services
Jerry Flood8a6b0b52017-11-12 15:44:21 -050026 ${status} ${value}= Run Keyword And Ignore Error Dictionary Should Contain Key ${dict} ${service_type}
DR695Hccff30b2017-02-17 18:44:24 -050027 Run Keyword If '${status}' == 'FAIL' Create Service ${service_type}
Jerry Flood8a6b0b52017-11-12 15:44:21 -050028
DR695Hccff30b2017-02-17 18:44:24 -050029Create Service
Jerry Flood8a6b0b52017-11-12 15:44:21 -050030 [Documentation] Creates a service in A&AI
DR695Hccff30b2017-02-17 18:44:24 -050031 [Arguments] ${service_type}
Jerry Flood8a6b0b52017-11-12 15:44:21 -050032 ${uuid}= Generate UUID
33 ${data_template}= OperatingSystem.Get File ${AAI_ADD_SERVICE_BODY}
34 ${arguments}= Create Dictionary service_type=${service_type} UUID=${uuid}
DR695Hccff30b2017-02-17 18:44:24 -050035 ${data}= Fill JSON Template ${data_template} ${arguments}
36 ${fullpath}= Catenate ${INDEX PATH}${ROOT_SERVICE_PATH}/service/${uuid}
37 ${put_resp}= Run A&AI Put Request ${fullpath} ${data}
38 Should Be Equal As Strings ${put_resp.status_code} 201
39 [Return] ${put_resp.status_code}
40
Jerry Flood8a6b0b52017-11-12 15:44:21 -050041
DR695Hccff30b2017-02-17 18:44:24 -050042Delete Service If Exists
Jerry Flood8a6b0b52017-11-12 15:44:21 -050043 [Documentation] Deletes a service in A&AI if it exists
DR695Hccff30b2017-02-17 18:44:24 -050044 [Arguments] ${service_type}
45 ${dict}= Get Services
Jerry Flood8a6b0b52017-11-12 15:44:21 -050046 ${status} ${value}= Run Keyword And Ignore Error Dictionary Should Contain Key ${dict} ${service_type}
DR695Hccff30b2017-02-17 18:44:24 -050047 Run Keyword If '${status}' == 'PASS' Delete Service ${dict['${service_type}']}
48
49Delete Service
Jerry Flood8a6b0b52017-11-12 15:44:21 -050050 [Documentation] Delete passed service in A&AI
DR695Hccff30b2017-02-17 18:44:24 -050051 [Arguments] ${dict}
Jerry Flood8a6b0b52017-11-12 15:44:21 -050052 ${uuid}= Get From Dictionary ${dict} service-id
DR695Hccff30b2017-02-17 18:44:24 -050053 ${resource_version}= Get From Dictionary ${dict} resource-version
54 ${fullpath}= Catenate ${INDEX PATH}${ROOT_SERVICE_PATH}/service/${uuid}
Jerry Flood8a6b0b52017-11-12 15:44:21 -050055 ${resp}= Run A&AI Delete Request ${fullpath} ${resource_version}
DR695Hccff30b2017-02-17 18:44:24 -050056 Should Be Equal As Strings ${resp.status_code} 204
57
Jerry Flood8a6b0b52017-11-12 15:44:21 -050058
DR695Hccff30b2017-02-17 18:44:24 -050059Get Services
Jerry Flood8a6b0b52017-11-12 15:44:21 -050060 [Documentation] Creates a service in A&AI
DR695Hccff30b2017-02-17 18:44:24 -050061 ${resp}= Run A&AI Get Request ${INDEX PATH}${ROOT_SERVICE_PATH}
Jerry Flood8a6b0b52017-11-12 15:44:21 -050062 ${dict}= Create Dictionary
DR695Hccff30b2017-02-17 18:44:24 -050063 ${status} ${value}= Run Keyword And Ignore Error Should Be Equal As Strings ${resp.status_code} 200
Jerry Flood8a6b0b52017-11-12 15:44:21 -050064 Run Keyword If '${status}' == 'PASS' Update Service Dictionary ${dict} ${resp.json()}
DR695Hccff30b2017-02-17 18:44:24 -050065 [Return] ${dict}
66
67Update Service Dictionary
68 [Arguments] ${dict} ${json}
69 ${list}= Evaluate ${json}['service']
70 :for ${map} in @{list}
71 \ ${status} ${service_type}= Run Keyword And Ignore Error Get From Dictionary ${map} service-description
Jerry Flood8a6b0b52017-11-12 15:44:21 -050072 \ Run Keyword If '${status}' == 'PASS' Set To Dictionary ${dict} ${service_type}=${map}
DR695Hccff30b2017-02-17 18:44:24 -050073 Log ${dict}
74
75