3 Library RequestsLibrary
4 Variables ../variables/Variables.py
8 [Arguments] ${controller_ip} ${node} ${first} ${last} ${prefix} ${field bases}
10 [Documentation] POSTs records to a controller's data store. First and last index numbers are specified
11 ... as is a dictionary called field_bases containing the base name for the field contents
12 ... onto which will be appended the index number. Prefix and postfix are used to complete
13 ... the JSON payload. The keyword passes if return code is correct.
14 ${last} Convert to Integer ${last}
15 : FOR ${INDEX} IN RANGE ${first} ${last+1}
16 \ ${payload}= Assemble Payload ${INDEX} ${prefix} ${field bases} ${postfix}
18 \ Create_Session session http://${controller_ip}:${RESTCONFPORT}${CONFIG_API} headers=${HEADERS} auth=${AUTH}
19 \ ${resp} RequestsLibrary.Post Request session ${node} ${payload}
21 \ Should Be Equal As Strings ${resp} <Response [204]>
24 [Arguments] ${controller_ip} ${node}
25 [Documentation] GETs records from a shard on a controller's data store.
26 Create_Session session http://${controller_ip}:${RESTCONFPORT}${CONFIG_API} headers=${HEADERS} auth=${AUTH}
27 ${resp}= RequestsLibrary.Get Request session ${node}
28 [Return] ${resp.json()}
31 [Arguments] ${controller_ip} ${node} ${first} ${last} ${prefix} ${field bases}
33 [Documentation] PUTs records to shard on a controller's data store. First and last index numbers are specified
34 ... as is a dictionary called field_bases containing the base name for the field contents
35 ... onto which will be appended the index number. Prefix and postfix are used to complete
36 ... the JSON payload. The keyword passes if return code is correct.
37 ${last} Convert to Integer ${last}
38 : FOR ${INDEX} IN RANGE ${first} ${last+1}
39 \ ${payload}= Assemble Payload ${INDEX} ${prefix} ${field bases} ${postfix}
41 \ Create_Session session http://${controller_ip}:${RESTCONFPORT}${CONFIG_API} headers=${HEADERS} auth=${AUTH}
42 \ ${resp}= RequestsLibrary.Put Request session ${node}/${INDEX} ${payload}
44 \ Should Be Equal As Strings ${resp} <Response [200]>
47 [Arguments] ${controller_ip} ${node} ${first} ${last}
48 [Documentation] DELETEs specified range of records from a shard on a contrsoller's data store.
49 ${last} Convert to Integer ${last}
50 : FOR ${INDEX} IN RANGE ${first} ${last+1}
51 \ Create_Session session http://${controller_ip}:${RESTCONFPORT}${CONFIG_API} headers=${HEADERS} auth=${AUTH}
52 \ ${resp}= RequestsLibrary.Delete Request session ${node}/${INDEX}
53 \ Should Be Equal As Strings ${resp} <Response [200]>
56 [Arguments] ${controller_ip} ${node}
57 [Documentation] DELETEs all records from a shard on a controller's data store.
58 Create_Session session http://${controller_ip}:${RESTCONFPORT}${CONFIG_API} headers=${HEADERS} auth=${AUTH}
59 ${resp}= RequestsLibrary.Delete Request session ${node}
60 Should Be Equal As Strings ${resp} <Response [200]>
63 [Arguments] ${id} ${prefix} ${field bases} ${postfix}
64 [Documentation] Populates a payload for creating or updating a shard record.
65 ... id: The record number and is also appended onto each field to uniquely identify it.
66 ... prefix: The portion of the json payload before the records.
67 ... field bases: A dictionary of records onto which the id is appended.
68 ... prefix: The portion of the json payload after the records.
69 ${length}= Get Length ${field bases}
70 ${keys}= Get Dictionary Keys ${field bases}
71 ${payload}= Set Variable ${prefix}
72 : FOR ${key string} IN @{keys}
73 \ ${value string}= Get From Dictionary ${field bases} ${key string}
74 \ ${payload}= Catenate ${payload} "${key string}": "${value string}${id}",
75 ${payload}= Get Substring ${payload} ${EMPTY} -1
76 ${payload}= Catenate ${payload} ${postfix}