Add client cert to support mTLS
[it/test.git] / ric_robot_suite / robot / resources / appmgr / appmgr_interface.robot
1 *** Settings ***
2 Documentation  Keywords for interacting with the XApp Manager, including listing, deploying, and undeploying XApps
3
4 Library        RequestsLibrary
5
6 Resource       ../global_properties.robot
7
8 Resource       ../ric/ric_utils.robot
9
10 *** Variables ***
11 ${APPMGR_BASE_PATH}  /ric/v1/xapps
12 ${APPMGR_ENDPOINT}   ${GLOBAL_APPMGR_SERVER_PROTOCOL}://${GLOBAL_INJECTED_APPMGR_IP_ADDR}:${GLOBAL_APPMGR_SERVER_PORT}
13
14 *** Keywords ***
15 Run AppMgr Health Check
16      [Documentation]    Runs AppMgr Health check
17      Run Keyword        Get Deployed XApps
18
19 Get Deployed XApps
20      [Documentation]  Obtain the list of deployed XApps from the Appmgr
21      ${resp} =        Run AppMgr GET Request
22      [Return]         ${resp.json()}
23
24 Get Deployable XApps
25      [Documentation]  Obtain the list of deployed XApps from the Appmgr
26      ${resp} =        Run AppMgr GET Request  /search/
27      Should Be True   ${resp}
28      [Return]         ${resp.json()}
29
30 Get XApp By Name
31      [Documentation]  Get installed XApp from Appmgr given name
32      [Arguments]      ${xapp_name}
33      ${resp} =        Run AppMgr GET Request  /${xapp_name}
34      Should Be True   ${resp}
35      [Return]         ${resp.json()}
36
37 Get XApp By Name and ID
38      [Documentation]  Get installed XApp from Appmgr by name and ID
39      [Arguments]      ${xapp_name}  ${xapp_id}
40      ${resp}=         Run AppMgr GET Request  /${xapp_name}/${xapp_id}/
41      Should Be True   ${resp}
42      [Return]         ${resp.json()}
43
44 Deploy XApp
45      [Documentation]  Create Xapp
46      [Arguments]      ${xapp_name}
47      &{dict} =        Create Dictionary        name=${xapp_name}
48      ${data} =        Evaluate                 json.dumps(&{dict})  json
49      ${resp} =        Run AppMgr POST Request  ${EMPTY}             ${data}
50      Should Be True   ${resp}
51      [Return]         ${resp}
52
53 Deploy XApps
54      [Documentation]  Create one or more XApps
55      [Arguments]      @{xapp_names}
56      FOR             ${xapp}  IN             @{xapp_names}
57                      Deploy XApp   ${xapp}
58      END
59      
60 Undeploy XApp
61      [Documentation]  Remove a deployed XApp
62      [Arguments]      ${xapp_name}
63      ${resp} =        Run AppMgr DELETE Request  /${xapp_name}
64      Should Be True   ${resp}
65      [Return]         ${resp}
66
67 Undeploy XApps
68      [Documentation]  Remove one or more deployed XApps
69      [Arguments]      @{xapp_names}
70      FOR             ${xapp}  IN     @{xapp_names}
71                      Undeploy XApp   ${xapp}
72
73 Deploy All Available XApps
74      [Documentation]  Attempt to deploy any not-currently-deployed XApp
75      @{d} =          Get Deployed XApps
76      @{deployed} =   Pluck               name          ${d}
77      @{available} =  Get Deployable XApps
78      @{toDeploy} =   Subtract From List  ${available}  ${deployed}
79      Deploy XApps    @{toDeploy}
80
81 Undeploy All Running XApps
82      [Documentation]  Undeploy any deployed XApps
83      @{d} =           Get Deployed XApps
84      @{deployed} =    Pluck  name  ${d}
85      Run Keyword If   ${deployed}  Undeploy XApps  @{deployed}
86
87 Run AppMgr GET Request
88      [Documentation]  Make an HTTP GET request against the XApp manager
89      [Arguments]   ${path}=${EMPTY}
90      ${session} =  Create Session     roboAppmgrGet                   ${APPMGR_ENDPOINT}
91      ${headers} =  Create Dictionary  Accept=application/json         Content-Type=application/json
92      ${resp} =     Get Request        roboAppmgrGet                   ${APPMGR_BASE_PATH}${path}  headers=${headers}
93      [Return]      ${resp}
94
95 Run AppMgr POST Request
96      [Documentation]    Make an HTTP POST request against the XApp manager
97      [Arguments]   ${path}=${EMPTY}   ${body}=${EMPTY}
98      ${session} =  Create Session     roboAppmgrPost                  ${APPMGR_ENDPOINT}
99      ${headers} =  Create Dictionary  Accept=application/json         Content-Type=application/json
100      ${resp} =     Post Request       roboAppmgrPost                  ${APPMGR_BASE_PATH}${path}  headers=${headers}  data=${body}
101      [Return]      ${resp}
102
103 Run AppMgr DELETE Request
104      [Documentation]  Make an HTTP DELETE request against the XApp manager
105      [Arguments]      ${path}
106      ${session} =     Create Session     roboAppmgrDelete                ${APPMGR_ENDPOINT}
107      ${headers} =     Create Dictionary  Accept=application/json         Content-Type=application/json
108      ${resp} =        Delete Request     roboAppmgrDelete                ${APPMGR_BASE_PATH}${path}  headers=${headers}
109      [Return]         ${resp}