3 Library RequestsLibrary
4 Variables ../variables/Variables.py
9 [Documentation] POSTs records to a controller's data store. First and last index numbers are specified
10 ... as is a dictionary called field_bases containing the base name for the field contents
11 ... onto which will be appended the index number. Prefix and postfix are used to complete
12 ... the JSON payload. The keyword passes if return code is correct.
13 [Arguments] ${controller_ip} ${node} ${first} ${last} ${prefix} ${field bases}
15 ${last}= Convert to Integer ${last}
16 FOR ${INDEX} IN RANGE ${first} ${last+1}
17 ${payload}= Assemble Payload ${INDEX} ${prefix} ${field bases} ${postfix}
21 ... http://${controller_ip}:${RESTCONFPORT}${CONFIG_API}
22 ... headers=${HEADERS}
24 ${resp}= RequestsLibrary.Post Request session ${node} ${payload}
26 Should Be Equal As Strings ${resp} <Response [204]>
30 [Documentation] GETs records from a shard on a controller's data store.
31 [Arguments] ${controller_ip} ${node}
34 ... http://${controller_ip}:${RESTCONFPORT}${CONFIG_API}
35 ... headers=${HEADERS}
37 ${resp}= RequestsLibrary.Get Request session ${node}
41 [Documentation] PUTs records to shard on a controller's data store. First and last index numbers are specified
42 ... as is a dictionary called field_bases containing the base name for the field contents
43 ... onto which will be appended the index number. Prefix and postfix are used to complete
44 ... the JSON payload. The keyword passes if return code is correct.
45 [Arguments] ${controller_ip} ${node} ${first} ${last} ${prefix} ${field bases}
47 ${last}= Convert to Integer ${last}
48 FOR ${INDEX} IN RANGE ${first} ${last+1}
49 ${payload}= Assemble Payload ${INDEX} ${prefix} ${field bases} ${postfix}
53 ... http://${controller_ip}:${RESTCONFPORT}${CONFIG_API}
54 ... headers=${HEADERS}
56 ${resp}= RequestsLibrary.Put Request session ${node}/${INDEX} ${payload}
58 Should Be Equal As Strings ${resp} <Response [200]>
62 [Documentation] DELETEs specified range of records from a shard on a contrsoller's data store.
63 [Arguments] ${controller_ip} ${node} ${first} ${last}
64 ${last}= Convert to Integer ${last}
65 FOR ${INDEX} IN RANGE ${first} ${last+1}
68 ... http://${controller_ip}:${RESTCONFPORT}${CONFIG_API}
69 ... headers=${HEADERS}
71 ${resp}= RequestsLibrary.Delete Request session ${node}/${INDEX}
72 Should Be Equal As Strings ${resp} <Response [200]>
76 [Documentation] DELETEs all records from a shard on a controller's data store.
77 [Arguments] ${controller_ip} ${node}
80 ... http://${controller_ip}:${RESTCONFPORT}${CONFIG_API}
81 ... headers=${HEADERS}
83 ${resp}= RequestsLibrary.Delete Request session ${node}
84 Should Be Equal As Strings ${resp} <Response [200]>
87 [Documentation] Populates a payload for creating or updating a shard record.
88 ... id: The record number and is also appended onto each field to uniquely identify it.
89 ... prefix: The portion of the json payload before the records.
90 ... field bases: A dictionary of records onto which the id is appended.
91 ... prefix: The portion of the json payload after the records.
92 [Arguments] ${id} ${prefix} ${field bases} ${postfix}
93 ${length}= Get Length ${field bases}
94 ${keys}= Get Dictionary Keys ${field bases}
95 ${payload}= Set Variable ${prefix}
96 FOR ${key string} IN @{keys}
97 ${value string}= Get From Dictionary ${field bases} ${key string}
98 ${payload}= Catenate ${payload} "${key string}": "${value string}${id}",
100 ${payload}= Get Substring ${payload} ${EMPTY} -1
101 ${payload}= Catenate ${payload} ${postfix}