DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Create A&AI Customer API. |
| 3 | ... |
| 4 | ... Create A&AI Customer API |
| 5 | |
| 6 | Resource ../json_templater.robot |
| 7 | Resource aai_interface.robot |
| 8 | Library OperatingSystem |
| 9 | Library Collections |
| 10 | Library UUID |
| 11 | |
| 12 | |
| 13 | |
| 14 | *** Variables *** |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 15 | ${INDEX PATH} /aai/v11 |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 16 | ${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 Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 21 | *** Keywords *** |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 22 | Create Service If Not Exists |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 23 | [Documentation] Creates a service in A&AI if it doesn't exist |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 24 | [Arguments] ${service_type} |
| 25 | ${dict}= Get Services |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 26 | ${status} ${value}= Run Keyword And Ignore Error Dictionary Should Contain Key ${dict} ${service_type} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 27 | Run Keyword If '${status}' == 'FAIL' Create Service ${service_type} |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 28 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 29 | Create Service |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 30 | [Documentation] Creates a service in A&AI |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 31 | [Arguments] ${service_type} |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 32 | ${uuid}= Generate UUID |
| 33 | ${data_template}= OperatingSystem.Get File ${AAI_ADD_SERVICE_BODY} |
| 34 | ${arguments}= Create Dictionary service_type=${service_type} UUID=${uuid} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 35 | ${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 Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 41 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 42 | Delete Service If Exists |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 43 | [Documentation] Deletes a service in A&AI if it exists |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 44 | [Arguments] ${service_type} |
| 45 | ${dict}= Get Services |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 46 | ${status} ${value}= Run Keyword And Ignore Error Dictionary Should Contain Key ${dict} ${service_type} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 47 | Run Keyword If '${status}' == 'PASS' Delete Service ${dict['${service_type}']} |
| 48 | |
| 49 | Delete Service |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 50 | [Documentation] Delete passed service in A&AI |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 51 | [Arguments] ${dict} |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 52 | ${uuid}= Get From Dictionary ${dict} service-id |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 53 | ${resource_version}= Get From Dictionary ${dict} resource-version |
| 54 | ${fullpath}= Catenate ${INDEX PATH}${ROOT_SERVICE_PATH}/service/${uuid} |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 55 | ${resp}= Run A&AI Delete Request ${fullpath} ${resource_version} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 56 | Should Be Equal As Strings ${resp.status_code} 204 |
| 57 | |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 58 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 59 | Get Services |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 60 | [Documentation] Creates a service in A&AI |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 61 | ${resp}= Run A&AI Get Request ${INDEX PATH}${ROOT_SERVICE_PATH} |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 62 | ${dict}= Create Dictionary |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 63 | ${status} ${value}= Run Keyword And Ignore Error Should Be Equal As Strings ${resp.status_code} 200 |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 64 | Run Keyword If '${status}' == 'PASS' Update Service Dictionary ${dict} ${resp.json()} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 65 | [Return] ${dict} |
| 66 | |
| 67 | Update 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 Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 72 | \ Run Keyword If '${status}' == 'PASS' Set To Dictionary ${dict} ${service_type}=${map} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 73 | Log ${dict} |
| 74 | |
| 75 | |