IMPL: A1 <-> XApp Message Flow Testing
[it/test.git] / ric_robot_suite / robot / resources / a1mediator / a1mediator_interface.robot
1 *** Settings ***
2 Documentation  Keywords for interacting with the A1 interface, including policy creation, instantiaton, and deletion
3
4 Library        RequestsLibrary
5
6 Resource       /robot/resources/global_properties.robot
7
8 *** Variables ***
9 ${A1MEDIATOR_BASE_PATH}  /a1-p/policytypes
10 ${A1MEDIATOR_ENDPOINT}   ${GLOBAL_A1MEDIATOR_SERVER_PROTOCOL}://${GLOBAL_INJECTED_A1MEDIATOR_IP_ADDR}:${GLOBAL_A1MEDIATOR_SERVER_PORT}
11
12 *** Keywords ***
13 Create A1 Policy Type
14      [Documentation]  Create a new policy via the A1 Mediator.
15      [Arguments]      ${type}  ${name}  ${description}  ${properties}  ${required}=@{EMPTY}
16      ${typeID} =        Convert To Integer  ${type}
17      Should Be True     ${type} > 0         Policy type must be an integer > 0
18      ${createSchema} =  Create Dictionary
19      ...                $schema=http://json-schema.org/draft-07/schema#
20      ...                type=object
21      ...                properties=${properties}
22      ...                required=@{required}
23      ${createBody} =    Create Dictionary
24      ...                name=${name}
25      ...                policy_type_id=${typeID}
26      ...                description=${description}
27      ...                create_schema=${createSchema}
28      ${createJSON} =    Evaluate                    json.dumps(&{createBody})  json,uuid
29      ${resp} =          Run A1Mediator PUT Request  /${type}  body=${createJSON}
30      [Return]           ${resp}
31      
32 Instantiate A1 Policy
33      [Documentation]  Create a new instance of an A1 policy
34      [Arguments]      ${type}  ${instance}  ${properties}=${EMPTY}
35      ${typeID} =        Convert To Integer  ${type}
36      Should Be True     ${type} > 0         Policy type must be an integer > 0
37      ${instanceJSON} =  Evaluate            json.dumps(&{properties})  json,uuid
38      ${resp} =          Run A1Mediator PUT Request  /${type}/policies/${instance}  body=${instanceJSON}
39      [Return]           ${resp}
40
41 Delete A1 Instance
42      [Documentation]  Remove an A1 policy instance
43      [Arguments]      ${type}  ${instance}
44      ${typeID} =        Convert To Integer  ${type}
45      Should Be True     ${type} > 0         Policy type must be an integer > 0
46      ${resp} =          Run A1Mediator DELETE Request  /${type}/policies/${instance}
47      [Return]           ${resp}
48
49 Delete A1 Policy
50      [Documentation]  Remove an A1 policy type
51      [Arguments]      ${type}
52      ${typeID} =        Convert To Integer  ${type}
53      Should Be True     ${type} > 0         Policy type must be an integer > 0
54      ${resp} =          Run A1Mediator DELETE Request  /${type}
55      [Return]           ${resp}
56
57 Retrieve A1 Policy
58      [Documentation]  Get a defined policy from A1
59      [Arguments]      ${type}
60      ${typeID} =        Convert To Integer  ${type}
61      Should Be True     ${type} > 0         Policy type must be an integer > 0
62      ${resp} =          Run A1Mediator GET Request  /${type}
63      [Return]           ${resp}
64
65 Retrieve A1 Instance
66      [Documentation]  Get a defined policy from A1.  If no instance is specified, retrieve all instances.
67      [Arguments]      ${type}  ${instance}=${EMPTY}
68      ${typeID} =        Convert To Integer  ${type}
69      Should Be True     ${type} > 0         Policy type must be an integer > 0
70      ${resp} =          Run Keyword If              "${instance}" != "${EMPTY}"
71      ...                Run A1Mediator GET Request  /${type}/policies/${instance}
72      ...                ELSE
73      ...                Run A1Mediator GET Request  /${type}/policies
74      [Return]           ${resp}
75
76 Retrieve A1 Instance Status
77      [Documentation]  Get policy instance status
78      [Arguments]      ${type}  ${instance}=${EMPTY}
79      ${typeID} =        Convert To Integer  ${type}
80      Should Be True     ${type} > 0         Policy type must be an integer > 0
81      ${resp} =          Run A1Mediator GET Request                /${type}/policies/${instance}/status
82      [Return]           ${resp}
83
84 Run A1mediator GET Request
85      [Documentation]  Make an HTTP GET request against the XApp manager
86      [Arguments]   ${path}=${EMPTY}
87      ${session} =  Create Session     roboA1mediatorGet           ${A1MEDIATOR_ENDPOINT}
88      ${headers} =  Create Dictionary  Accept=application/json     Content-Type=application/json
89      ${resp} =     Get Request        roboA1mediatorGet           ${A1MEDIATOR_BASE_PATH}${path}  headers=${headers}
90      [Return]      ${resp}
91
92 Run A1mediator PUT Request
93      [Documentation]    Make an HTTP PUT request against the XApp manager
94      [Arguments]   ${path}=${EMPTY}   ${body}=${EMPTY}
95      ${session} =  Create Session     roboA1mediatorPut           ${A1MEDIATOR_ENDPOINT}
96      ${headers} =  Create Dictionary  Accept=application/json     Content-Type=application/json
97      ${resp} =     PUT Request        roboA1mediatorPut           ${A1MEDIATOR_BASE_PATH}${path}
98      ...                                                           headers=${headers}
99      ...                                                           data=${body}
100      [Return]      ${resp}
101
102 Run A1mediator POST Request
103      [Documentation]    Make an HTTP POST request against the XApp manager
104      [Arguments]   ${path}=${EMPTY}   ${body}=${EMPTY}
105      ${session} =  Create Session     roboA1mediatorPost          ${A1MEDIATOR_ENDPOINT}
106      ${headers} =  Create Dictionary  Accept=application/json     Content-Type=application/json
107      ${resp} =     POST Request       roboA1mediatorPost          ${A1MEDIATOR_BASE_PATH}${path}
108      ...                                                           headers=${headers}
109      ...                                                           data=${body}
110      [Return]      ${resp}
111
112 Run A1mediator DELETE Request
113      [Documentation]  Make an HTTP DELETE request against the XApp manager
114      [Arguments]      ${path}
115      ${session} =     Create Session     roboA1mediatorDelete     ${A1MEDIATOR_ENDPOINT}
116      ${headers} =     Create Dictionary  Accept=application/json  Content-Type=application/json
117      ${resp} =        Delete Request     roboA1mediatorDelete     ${A1MEDIATOR_BASE_PATH}${path}  headers=${headers}
118      [Return]         ${resp}