2 Documentation Keywords for interacting with the A1 interface, including policy creation, instantiaton, and deletion
4 Library RequestsLibrary
6 Resource /robot/resources/global_properties.robot
9 ${A1MEDIATOR_BASE_PATH} /a1-p/policytypes
10 ${A1MEDIATOR_ENDPOINT} ${GLOBAL_A1MEDIATOR_SERVER_PROTOCOL}://${GLOBAL_INJECTED_A1MEDIATOR_IP_ADDR}:${GLOBAL_A1MEDIATOR_SERVER_PORT}
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#
21 ... properties=${properties}
22 ... required=@{required}
23 ${createBody} = Create Dictionary
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}
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}
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}
50 [Documentation] Remove an A1 policy 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}
58 [Documentation] Get a defined policy from A1
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}
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}
73 ... Run A1Mediator GET Request /${type}/policies
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
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}
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}
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}
112 Run A1mediator DELETE Request
113 [Documentation] Make an HTTP DELETE request against the XApp manager
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}