a215eb11c641c0f4b4f2608656c3110a8ba5be53
[it/test.git] / ric_robot_suite / robot / resources / appmgr / appmgr_interface.robot
1 *** Settings ***
2 Documentation     The main interface for interacting with RIC Applications Manager (AppMgr) . It handles low level stuff like managing the http request library and AppMgr required fields
3 Library           RequestsLibrary
4 Library           UUID
5
6 Resource          ../global_properties.robot
7 Resource          ../json_templater.robot
8
9 *** Variables ***
10 ${APPMGR_BASE_PATH}        /ric/v1/xapps/   
11 ${APPMGR_ENDPOINT}     ${GLOBAL_APPMGR_SERVER_PROTOCOL}://${GLOBAL_INJECTED_APPMGR_IP_ADDR}:${GLOBAL_APPMGR_SERVER_PORT}
12 ${APPMGR_CREATE_XAPP_TEMPLATE}     robot/assets/templates/appmgr_create_xapp.template
13
14
15 *** Keywords ***
16 Run AppMgr Health Check
17      [Documentation]    Runs AppMgr Health check
18      Run Keyword   Run AppMgr Get All Request
19
20 Run AppMgr Get All Request 
21      [Documentation]    Runs AppMgr Get List of Xapps Request
22      ${resp}=    Run Keyword    Run AppMgr Get Request    ${APPMGR_BASE_PATH}
23      Should Be Equal As Strings        ${resp.status_code}     200
24
25 Run AppMgr Get By XappName and XappId
26      [documentation]     Get Xapp data by XappName and XappId
27      [Arguments]      ${xapp_name}  ${xapp_id}
28      ${data_path}=    Set Variable    ${APPMGR_BASE_PATH}${xapp_name}/${xapp_id}
29      ${resp}=   Run Keyword   Run AppMgr Get Request    ${data_path}
30      Should Be Equal As Strings        ${resp.status_code}     200
31
32 Run AppMgr Get By XappName 
33      [documentation]     Get List of Xapp data by XappName
34      [Arguments]      ${xapp_name}
35      ${data_path}=    Set Variable    ${APPMGR_BASE_PATH}${xapp_name}
36      ${resp}=   Run Keyword   Run AppMgr Get Request    ${data_path}
37      Should Be Equal As Strings        ${resp.status_code}     200
38
39 Run Create Xapp
40      [documentation]     Create Xapp 
41      [Arguments]      ${xapp_name}   ${xapp_id}  
42      ${data_path}=    Set Variable    ${APPMGR_BASE_PATH}
43      ${dict}=    Create Dictionary    xapp_name=${xapp_name}    xapp_id=${xapp_id}
44      ${data}=   Fill JSON Template File    ${APPMGR_CREATE_XAPP_TEMPLATE}    ${dict}
45      ${auth}=  Create List  ${GLOBAL_INJECTED_APPMGR_USER}    ${GLOBAL_INJECTED_APPMGR_PASSWORD}
46      ${session}=    Create Session      appmgr      ${APPMGR_ENDPOINT}   auth=${auth}
47      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    
48      ${resp}=   Post Request     appmgr     ${data_path}     data=${data}   headers=${headers}
49      Log    Received response from AppMgr ${resp.text}
50      Should Be Equal As Strings        ${resp.status_code}     200
51      [Return]    ${resp}
52
53
54 Run AppMgr Get Request
55      [Documentation]    Runs AppMgr Get request
56      [Arguments]    ${data_path}
57      ${auth}=  Create List  ${GLOBAL_INJECTED_APPMGR_USER}    ${GLOBAL_INJECTED_APPMGR_PASSWORD}
58      ${session}=    Create Session      appmgr      ${APPMGR_ENDPOINT}   auth=${auth}
59      ${uuid}=    Generate UUID
60      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    
61      ${resp}=   Get Request     appmgr     ${data_path}     headers=${headers}
62      Log    Received response from AppMgr ${resp.text}
63      Should Be Equal As Strings        ${resp.status_code}     200
64      [Return]    ${resp}
65
66 Run AppMgr Delete Request
67      [documentation]     Delete Xapp data by XappId
68      [Arguments]      ${xapp_id}
69      ${data_path}=    Set Variable    ${APPMGR_BASE_PATH}/${xapp_id}
70      ${auth}=  Create List  ${GLOBAL_INJECTED_APPMGR_USER}    ${GLOBAL_INJECTED_APPMGR_PASSWORD}
71      ${session}=    Create Session      appmgr      ${APPMGR_ENDPOINT}   auth=${auth}
72      ${uuid}=    Generate UUID
73      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    
74      ${resp}=   Delete Request     appmgr     ${data_path}     headers=${headers}
75      Log    Received response from AppMgr ${resp.text}
76      Should Be Equal As Strings        ${resp.status_code}     200