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