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