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 |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 8 | Library Collections |
DR695H | 18872bc | 2019-06-13 16:16:52 -0400 | [diff] [blame] | 9 | Library ONAPLibrary.Utilities |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 10 | |
| 11 | |
| 12 | |
| 13 | *** Variables *** |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 14 | ${INDEX PATH} /aai/v11 |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 15 | ${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 Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 20 | *** Keywords *** |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 21 | Create Service If Not Exists |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 22 | [Documentation] Creates a service in A&AI if it doesn't exist |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 23 | [Arguments] ${service_type} |
| 24 | ${dict}= Get Services |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 25 | ${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] | 26 | Run Keyword If '${status}' == 'FAIL' Create Service ${service_type} |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 27 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 28 | Create Service |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 29 | [Documentation] Creates a service in A&AI |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 30 | [Arguments] ${service_type} |
DR695H | 18872bc | 2019-06-13 16:16:52 -0400 | [diff] [blame] | 31 | ${uuid}= Generate UUID4 |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 32 | ${arguments}= Create Dictionary service_type=${service_type} UUID=${uuid} |
DR695H | daec16c | 2019-06-19 17:40:26 -0400 | [diff] [blame] | 33 | ${data}= Fill JSON Template File ${AAI_ADD_SERVICE_BODY} ${arguments} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 34 | ${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 Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 39 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 40 | Delete Service If Exists |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 41 | [Documentation] Deletes a service in A&AI if it exists |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 42 | [Arguments] ${service_type} |
| 43 | ${dict}= Get Services |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 44 | ${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] | 45 | Run Keyword If '${status}' == 'PASS' Delete Service ${dict['${service_type}']} |
| 46 | |
| 47 | Delete Service |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 48 | [Documentation] Delete passed service in A&AI |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 49 | [Arguments] ${dict} |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 50 | ${uuid}= Get From Dictionary ${dict} service-id |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 51 | ${resource_version}= Get From Dictionary ${dict} resource-version |
| 52 | ${fullpath}= Catenate ${INDEX PATH}${ROOT_SERVICE_PATH}/service/${uuid} |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 53 | ${resp}= Run A&AI Delete Request ${fullpath} ${resource_version} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 54 | Should Be Equal As Strings ${resp.status_code} 204 |
| 55 | |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 56 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 57 | Get Services |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 58 | [Documentation] Creates a service in A&AI |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 59 | ${resp}= Run A&AI Get Request ${INDEX PATH}${ROOT_SERVICE_PATH} |
Jerry Flood | 8a6b0b5 | 2017-11-12 15:44:21 -0500 | [diff] [blame] | 60 | ${dict}= Create Dictionary |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 61 | ${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] | 62 | Run Keyword If '${status}' == 'PASS' Update Service Dictionary ${dict} ${resp.json()} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 63 | [Return] ${dict} |
| 64 | |
| 65 | Update Service Dictionary |
| 66 | [Arguments] ${dict} ${json} |
| 67 | ${list}= Evaluate ${json}['service'] |
DR695H | 910097e | 2019-05-08 13:55:32 -0400 | [diff] [blame] | 68 | :FOR ${map} IN @{list} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 69 | \ ${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] | 70 | \ Run Keyword If '${status}' == 'PASS' Set To Dictionary ${dict} ${service_type}=${map} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 71 | Log ${dict} |
| 72 | |
| 73 | |