aec16a15b528215a3706e59bd1de7ee1ea4fc2d0
[integration/test.git] / csit / libraries / Restconf.robot
1 *** Settings ***
2
3 *** Variables ***
4 ${USE_RFC8040} =    False
5
6 *** Keywords ***
7
8 Generate URI
9     [Arguments]    ${identifier}    ${datastore_flag}=config    @{node_value_list}
10     [Documentation]    Returns the proper URI to use depending on if RFC8040 is to be used or not. Variable input
11     ...    error checking is done to ensure the ${USE_RFC8040} Flag is one of True or False and the ${datastore_flag} variable
12     ...    must be config, operational or rpc. @{node_value_list} is expected to be in the format of node=value. RFC8040 can
13     ...    use that as is with '=' delimiter, but older restconf URI will convert the '=' to a '/'
14     ${uri} =    Run Keyword If    "${USE_RFC8040}" == "True"    Generate RFC8040 URI    ${identifier}    ${datastore_flag}    @{node_value_list}
15     Return From Keyword If    "${USE_RFC8040}" == "True"    ${uri}
16     Run Keyword If    "${USE_RFC8040}" != "False"    Fail    Invalid Value for RFC8040 Flag: ${USE_RFC8040}
17     Run Keyword If    "${datastore_flag}"!="config" and "${datastore_flag}"!="operational" and "${datastore_flag}"!="rpc"    Fail    Invalid value for datastore: ${datastore_flag}
18     ${uri} =    Run Keyword If    "${datastore_flag}"=="config"    Set Variable    ${CONFIG_API}/${identifier}
19     ...    ELSE IF    "${datastore_flag}"=="operational"    Set Variable    ${OPERATIONAL_API}/${identifier}
20     ...    ELSE    Set Variable    ${OPERATIONS_API}/${identifier}
21     ${node_value_path} =    Set Variable    ${EMPTY}
22     FOR    ${nv}    IN    @{node_value_list}
23         ${nv} =    String.Replace String    ${nv}    =    /
24         ${node_value_path} =    Set Variable    ${node_value_path}/${nv}
25     END
26     [Return]    ${uri}${node_value_path}
27
28 Generate RFC8040 URI
29     [Arguments]    ${identifier}    ${datastore_flag}=config    @{node_value_list}
30     ${node_value_path} =    Set Variable    ${EMPTY}
31     FOR    ${nv}    IN    @{node_value_list}
32         ${node_value_path} =    Set Variable    ${node_value_path}/${nv}
33     END
34     ${uri} =    Run Keyword If    "${datastore_flag}" == "config"    Set Variable    rests/data/${identifier}${node_value_path}?content=config
35     ...    ELSE IF    "${datastore_flag}"=="operational"    Set Variable    rests/data/${identifier}${node_value_path}?content=nonconfig
36     ...    ELSE    Set Variable    rests/operations/${identifier}
37     [Return]    ${uri}