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