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