Best Python code snippet using tempest_python
v1_api_client.py
Source:v1_api_client.py
...74 'topology',75 'inventory_id',76 ])77def list_device(**kwargs):78 response = util.unpaginate(util.get_url(), '', util.get_verify(), util.get_auth(), kwargs)79 return response80def get_device(device_id):81 response = requests.get(util.get_url() + "" + str(device_id), verify=util.get_verify(), auth=util.get_auth())82 return response.json()83def create_device(topology, name, x, y, id, device_type, interface_id_seq=0, process_id_seq=0, host_id=0,):84 headers = {'content-type': 'application/json'}85 response = requests.post(util.get_url() + "", data=json.dumps(dict(topology=topology,86 name=name,87 x=x,88 y=y,89 id=id,90 device_type=device_type,91 interface_id_seq=interface_id_seq,92 process_id_seq=process_id_seq,93 host_id=host_id,94 )),95 verify=util.get_verify(),96 auth=util.get_auth(),97 headers=headers)98 return response.json()99def update_device(device_id, topology=None, name=None, x=None, y=None, id=None, device_type=None, interface_id_seq=None, process_id_seq=None, host_id=None,):100 headers = {'content-type': 'application/json'}101 data = dict(topology=topology,102 name=name,103 x=x,104 y=y,105 id=id,106 device_type=device_type,107 interface_id_seq=interface_id_seq,108 process_id_seq=process_id_seq,109 host_id=host_id,110 )111 data = {x: y for x, y in data.items() if y is not None}112 response = requests.patch(util.get_url() + "" + str(device_id) + "/",113 data=json.dumps(data),114 verify=util.get_verify(),115 auth=util.get_auth(),116 headers=headers)117 return response118def delete_device(device_id):119 response = requests.delete(util.get_url() + "" + str(device_id), verify=util.get_verify(), auth=util.get_auth())120 return response121def list_link(**kwargs):122 response = util.unpaginate(util.get_url(), '', util.get_verify(), util.get_auth(), kwargs)123 return response124def get_link(link_id):125 response = requests.get(util.get_url() + "" + str(link_id), verify=util.get_verify(), auth=util.get_auth())126 return response.json()127def create_link(from_device, to_device, from_interface, to_interface, id, name,):128 headers = {'content-type': 'application/json'}129 response = requests.post(util.get_url() + "", data=json.dumps(dict(from_device=from_device,130 to_device=to_device,131 from_interface=from_interface,132 to_interface=to_interface,133 id=id,134 name=name,135 )),136 verify=util.get_verify(),137 auth=util.get_auth(),138 headers=headers)139 return response.json()140def update_link(link_id, from_device=None, to_device=None, from_interface=None, to_interface=None, id=None, name=None,):141 headers = {'content-type': 'application/json'}142 data = dict(from_device=from_device,143 to_device=to_device,144 from_interface=from_interface,145 to_interface=to_interface,146 id=id,147 name=name,148 )149 data = {x: y for x, y in data.items() if y is not None}150 response = requests.patch(util.get_url() + "" + str(link_id) + "/",151 data=json.dumps(data),152 verify=util.get_verify(),153 auth=util.get_auth(),154 headers=headers)155 return response156def delete_link(link_id):157 response = requests.delete(util.get_url() + "" + str(link_id), verify=util.get_verify(), auth=util.get_auth())158 return response159def list_topology(**kwargs):160 response = util.unpaginate(util.get_url(), '', util.get_verify(), util.get_auth(), kwargs)161 return response162def get_topology(topology_id):163 response = requests.get(util.get_url() + "" + str(topology_id), verify=util.get_verify(), auth=util.get_auth())164 return response.json()165def create_topology(name, scale, panX, panY, device_id_seq=0, link_id_seq=0, group_id_seq=0, stream_id_seq=0,):166 headers = {'content-type': 'application/json'}167 response = requests.post(util.get_url() + "", data=json.dumps(dict(name=name,168 scale=scale,169 panX=panX,170 panY=panY,171 device_id_seq=device_id_seq,172 link_id_seq=link_id_seq,173 group_id_seq=group_id_seq,174 stream_id_seq=stream_id_seq,175 )),176 verify=util.get_verify(),177 auth=util.get_auth(),178 headers=headers)179 return response.json()180def update_topology(topology_id, name=None, scale=None, panX=None, panY=None, device_id_seq=None, link_id_seq=None, group_id_seq=None, stream_id_seq=None,):181 headers = {'content-type': 'application/json'}182 data = dict(name=name,183 scale=scale,184 panX=panX,185 panY=panY,186 device_id_seq=device_id_seq,187 link_id_seq=link_id_seq,188 group_id_seq=group_id_seq,189 stream_id_seq=stream_id_seq,190 )191 data = {x: y for x, y in data.items() if y is not None}192 response = requests.patch(util.get_url() + "" + str(topology_id) + "/",193 data=json.dumps(data),194 verify=util.get_verify(),195 auth=util.get_auth(),196 headers=headers)197 return response198def delete_topology(topology_id):199 response = requests.delete(util.get_url() + "" + str(topology_id), verify=util.get_verify(), auth=util.get_auth())200 return response201def list_interface(**kwargs):202 response = util.unpaginate(util.get_url(), '', util.get_verify(), util.get_auth(), kwargs)203 return response204def get_interface(interface_id):205 response = requests.get(util.get_url() + "" + str(interface_id), verify=util.get_verify(), auth=util.get_auth())206 return response.json()207def create_interface(device, name, id,):208 headers = {'content-type': 'application/json'}209 response = requests.post(util.get_url() + "", data=json.dumps(dict(device=device,210 name=name,211 id=id,212 )),213 verify=util.get_verify(),214 auth=util.get_auth(),215 headers=headers)216 return response.json()217def update_interface(interface_id, device=None, name=None, id=None,):218 headers = {'content-type': 'application/json'}219 data = dict(device=device,220 name=name,221 id=id,222 )223 data = {x: y for x, y in data.items() if y is not None}224 response = requests.patch(util.get_url() + "" + str(interface_id) + "/",225 data=json.dumps(data),226 verify=util.get_verify(),227 auth=util.get_auth(),228 headers=headers)229 return response230def delete_interface(interface_id):231 response = requests.delete(util.get_url() + "" + str(interface_id), verify=util.get_verify(), auth=util.get_auth())232 return response233def list_group(**kwargs):234 response = util.unpaginate(util.get_url(), '', util.get_verify(), util.get_auth(), kwargs)235 return response236def get_group(group_id):237 response = requests.get(util.get_url() + "" + str(group_id), verify=util.get_verify(), auth=util.get_auth())238 return response.json()239def create_group(id, name, x1, y1, x2, y2, topology, group_type, inventory_group_id=0,):240 headers = {'content-type': 'application/json'}241 response = requests.post(util.get_url() + "", data=json.dumps(dict(id=id,242 name=name,243 x1=x1,244 y1=y1,245 x2=x2,246 y2=y2,247 topology=topology,248 group_type=group_type,249 inventory_group_id=inventory_group_id,250 )),251 verify=util.get_verify(),252 auth=util.get_auth(),253 headers=headers)254 return response.json()255def update_group(group_id, id=None, name=None, x1=None, y1=None, x2=None, y2=None, topology=None, group_type=None, inventory_group_id=None,):256 headers = {'content-type': 'application/json'}257 data = dict(id=id,258 name=name,259 x1=x1,260 y1=y1,261 x2=x2,262 y2=y2,263 topology=topology,264 group_type=group_type,265 inventory_group_id=inventory_group_id,266 )267 data = {x: y for x, y in data.items() if y is not None}268 response = requests.patch(util.get_url() + "" + str(group_id) + "/",269 data=json.dumps(data),270 verify=util.get_verify(),271 auth=util.get_auth(),272 headers=headers)273 return response274def delete_group(group_id):275 response = requests.delete(util.get_url() + "" + str(group_id), verify=util.get_verify(), auth=util.get_auth())276 return response277def list_groupdevice(**kwargs):278 response = util.unpaginate(util.get_url(), '', util.get_verify(), util.get_auth(), kwargs)279 return response280def get_groupdevice(group_device_id):281 response = requests.get(util.get_url() + "" + str(group_device_id), verify=util.get_verify(), auth=util.get_auth())282 return response.json()283def create_groupdevice(group, device,):284 headers = {'content-type': 'application/json'}285 response = requests.post(util.get_url() + "", data=json.dumps(dict(group=group,286 device=device,287 )),288 verify=util.get_verify(),289 auth=util.get_auth(),290 headers=headers)291 return response.json()292def update_groupdevice(group_device_id, group=None, device=None,):293 headers = {'content-type': 'application/json'}294 data = dict(group=group,295 device=device,296 )297 data = {x: y for x, y in data.items() if y is not None}298 response = requests.patch(util.get_url() + "" + str(group_device_id) + "/",299 data=json.dumps(data),300 verify=util.get_verify(),301 auth=util.get_auth(),302 headers=headers)303 return response304def delete_groupdevice(group_device_id):305 response = requests.delete(util.get_url() + "" + str(group_device_id), verify=util.get_verify(), auth=util.get_auth())306 return response307def list_stream(**kwargs):308 response = util.unpaginate(util.get_url(), '', util.get_verify(), util.get_auth(), kwargs)309 return response310def get_stream(stream_id):311 response = requests.get(util.get_url() + "" + str(stream_id), verify=util.get_verify(), auth=util.get_auth())312 return response.json()313def create_stream(from_device, to_device, label, id=0,):314 headers = {'content-type': 'application/json'}315 response = requests.post(util.get_url() + "", data=json.dumps(dict(from_device=from_device,316 to_device=to_device,317 label=label,318 id=id,319 )),320 verify=util.get_verify(),321 auth=util.get_auth(),322 headers=headers)323 return response.json()324def update_stream(stream_id, from_device=None, to_device=None, label=None, id=None,):325 headers = {'content-type': 'application/json'}326 data = dict(from_device=from_device,327 to_device=to_device,328 label=label,329 id=id,330 )331 data = {x: y for x, y in data.items() if y is not None}332 response = requests.patch(util.get_url() + "" + str(stream_id) + "/",333 data=json.dumps(data),334 verify=util.get_verify(),335 auth=util.get_auth(),336 headers=headers)337 return response338def delete_stream(stream_id):339 response = requests.delete(util.get_url() + "" + str(stream_id), verify=util.get_verify(), auth=util.get_auth())340 return response341def list_process(**kwargs):342 response = util.unpaginate(util.get_url(), '', util.get_verify(), util.get_auth(), kwargs)343 return response344def get_process(process_id):345 response = requests.get(util.get_url() + "" + str(process_id), verify=util.get_verify(), auth=util.get_auth())346 return response.json()347def create_process(device, name, process_type, id=0,):348 headers = {'content-type': 'application/json'}349 response = requests.post(util.get_url() + "", data=json.dumps(dict(device=device,350 name=name,351 process_type=process_type,352 id=id,353 )),354 verify=util.get_verify(),355 auth=util.get_auth(),356 headers=headers)357 return response.json()358def update_process(process_id, device=None, name=None, process_type=None, id=None,):359 headers = {'content-type': 'application/json'}360 data = dict(device=device,361 name=name,362 process_type=process_type,363 id=id,364 )365 data = {x: y for x, y in data.items() if y is not None}366 response = requests.patch(util.get_url() + "" + str(process_id) + "/",367 data=json.dumps(data),368 verify=util.get_verify(),369 auth=util.get_auth(),370 headers=headers)371 return response372def delete_process(process_id):373 response = requests.delete(util.get_url() + "" + str(process_id), verify=util.get_verify(), auth=util.get_auth())374 return response375def list_toolbox(**kwargs):376 response = util.unpaginate(util.get_url(), '', util.get_verify(), util.get_auth(), kwargs)377 return response378def get_toolbox(toolbox_id):379 response = requests.get(util.get_url() + "" + str(toolbox_id), verify=util.get_verify(), auth=util.get_auth())380 return response.json()381def create_toolbox(name,):382 headers = {'content-type': 'application/json'}383 response = requests.post(util.get_url() + "", data=json.dumps(dict(name=name,384 )),385 verify=util.get_verify(),386 auth=util.get_auth(),387 headers=headers)388 return response.json()389def update_toolbox(toolbox_id, name=None,):390 headers = {'content-type': 'application/json'}391 data = dict(name=name,392 )393 data = {x: y for x, y in data.items() if y is not None}394 response = requests.patch(util.get_url() + "" + str(toolbox_id) + "/",395 data=json.dumps(data),396 verify=util.get_verify(),397 auth=util.get_auth(),398 headers=headers)399 return response400def delete_toolbox(toolbox_id):401 response = requests.delete(util.get_url() + "" + str(toolbox_id), verify=util.get_verify(), auth=util.get_auth())402 return response403def list_toolboxitem(**kwargs):404 response = util.unpaginate(util.get_url(), '', util.get_verify(), util.get_auth(), kwargs)405 return response406def get_toolboxitem(toolbox_item_id):407 response = requests.get(util.get_url() + "" + str(toolbox_item_id), verify=util.get_verify(), auth=util.get_auth())408 return response.json()409def create_toolboxitem(toolbox, data,):410 headers = {'content-type': 'application/json'}411 response = requests.post(util.get_url() + "", data=json.dumps(dict(toolbox=toolbox,412 data=data,413 )),414 verify=util.get_verify(),415 auth=util.get_auth(),416 headers=headers)417 return response.json()418def update_toolboxitem(toolbox_item_id, toolbox=None, data=None,):419 headers = {'content-type': 'application/json'}420 data = dict(toolbox=toolbox,421 data=data,422 )423 data = {x: y for x, y in data.items() if y is not None}424 response = requests.patch(util.get_url() + "" + str(toolbox_item_id) + "/",425 data=json.dumps(data),426 verify=util.get_verify(),427 auth=util.get_auth(),428 headers=headers)429 return response430def delete_toolboxitem(toolbox_item_id):431 response = requests.delete(util.get_url() + "" + str(toolbox_item_id), verify=util.get_verify(), auth=util.get_auth())432 return response433def list_topologyinventory(**kwargs):434 response = util.unpaginate(util.get_url(), '', util.get_verify(), util.get_auth(), kwargs)435 return response436def get_topologyinventory(topology_inventory_id):437 response = requests.get(util.get_url() + "" + str(topology_inventory_id), verify=util.get_verify(), auth=util.get_auth())438 return response.json()439def create_topologyinventory(topology, inventory_id,):440 headers = {'content-type': 'application/json'}441 response = requests.post(util.get_url() + "", data=json.dumps(dict(topology=topology,442 inventory_id=inventory_id,443 )),444 verify=util.get_verify(),445 auth=util.get_auth(),446 headers=headers)447 return response.json()448def update_topologyinventory(topology_inventory_id, topology=None, inventory_id=None,):449 headers = {'content-type': 'application/json'}450 data = dict(topology=topology,451 inventory_id=inventory_id,452 )453 data = {x: y for x, y in data.items() if y is not None}454 response = requests.patch(util.get_url() + "" + str(topology_inventory_id) + "/",455 data=json.dumps(data),456 verify=util.get_verify(),457 auth=util.get_auth(),458 headers=headers)459 return response460def delete_topologyinventory(topology_inventory_id):461 response = requests.delete(util.get_url() + "" + str(topology_inventory_id), verify=util.get_verify(), auth=util.get_auth())...
v2_api_client.py
Source:v2_api_client.py
1import requests2import util3import json4def list_device(**kwargs):5 response = util.unpaginate(util.get_url(), '/api/v2/canvas/device/', util.get_verify(), util.get_auth(), kwargs)6 return response7def get_device(device_id):8 response = requests.get(util.get_url() + "/api/v2/canvas/device/" + str(device_id), verify=util.get_verify(), auth=util.get_auth())9 return response.json()10def create_device(topology, name, x, y, id, device_type, interface_id_seq=0, process_id_seq=0, host_id=0,):11 headers = {'content-type': 'application/json'}12 response = requests.post(util.get_url() + "/api/v2/canvas/device/", data=json.dumps(dict(topology=topology,13 name=name,14 x=x,15 y=y,16 id=id,17 device_type=device_type,18 interface_id_seq=interface_id_seq,19 process_id_seq=process_id_seq,20 host_id=host_id,21 )),22 verify=util.get_verify(),23 auth=util.get_auth(),24 headers=headers)25 return response.json()26def update_device(device_id, topology=None, name=None, x=None, y=None, id=None, device_type=None, interface_id_seq=None, process_id_seq=None, host_id=None,):27 headers = {'content-type': 'application/json'}28 data = dict(topology=topology,29 name=name,30 x=x,31 y=y,32 id=id,33 device_type=device_type,34 interface_id_seq=interface_id_seq,35 process_id_seq=process_id_seq,36 host_id=host_id,37 )38 data = {x: y for x, y in data.items() if y is not None}39 response = requests.patch(util.get_url() + "/api/v2/canvas/device/" + str(device_id) + "/",40 data=json.dumps(data),41 verify=util.get_verify(),42 auth=util.get_auth(),43 headers=headers)44 return response45def delete_device(device_id):46 response = requests.delete(util.get_url() + "/api/v2/canvas/device/" + str(device_id), verify=util.get_verify(), auth=util.get_auth())47 return response48def list_link(**kwargs):49 response = util.unpaginate(util.get_url(), '/api/v2/canvas/link/', util.get_verify(), util.get_auth(), kwargs)50 return response51def get_link(link_id):52 response = requests.get(util.get_url() + "/api/v2/canvas/link/" + str(link_id), verify=util.get_verify(), auth=util.get_auth())53 return response.json()54def create_link(from_device, to_device, from_interface, to_interface, id, name,):55 headers = {'content-type': 'application/json'}56 response = requests.post(util.get_url() + "/api/v2/canvas/link/", data=json.dumps(dict(from_device=from_device,57 to_device=to_device,58 from_interface=from_interface,59 to_interface=to_interface,60 id=id,61 name=name,62 )),63 verify=util.get_verify(),64 auth=util.get_auth(),65 headers=headers)66 return response.json()67def update_link(link_id, from_device=None, to_device=None, from_interface=None, to_interface=None, id=None, name=None,):68 headers = {'content-type': 'application/json'}69 data = dict(from_device=from_device,70 to_device=to_device,71 from_interface=from_interface,72 to_interface=to_interface,73 id=id,74 name=name,75 )76 data = {x: y for x, y in data.items() if y is not None}77 response = requests.patch(util.get_url() + "/api/v2/canvas/link/" + str(link_id) + "/",78 data=json.dumps(data),79 verify=util.get_verify(),80 auth=util.get_auth(),81 headers=headers)82 return response83def delete_link(link_id):84 response = requests.delete(util.get_url() + "/api/v2/canvas/link/" + str(link_id), verify=util.get_verify(), auth=util.get_auth())85 return response86def list_topology(**kwargs):87 response = util.unpaginate(util.get_url(), '/api/v2/canvas/topology/', util.get_verify(), util.get_auth(), kwargs)88 return response89def get_topology(topology_id):90 response = requests.get(util.get_url() + "/api/v2/canvas/topology/" + str(topology_id), verify=util.get_verify(), auth=util.get_auth())91 return response.json()92def create_topology(name, scale, panX, panY, device_id_seq=0, link_id_seq=0, group_id_seq=0, stream_id_seq=0,):93 headers = {'content-type': 'application/json'}94 response = requests.post(util.get_url() + "/api/v2/canvas/topology/", data=json.dumps(dict(name=name,95 scale=scale,96 panX=panX,97 panY=panY,98 device_id_seq=device_id_seq,99 link_id_seq=link_id_seq,100 group_id_seq=group_id_seq,101 stream_id_seq=stream_id_seq,102 )),103 verify=util.get_verify(),104 auth=util.get_auth(),105 headers=headers)106 return response.json()107def update_topology(topology_id, name=None, scale=None, panX=None, panY=None, device_id_seq=None, link_id_seq=None, group_id_seq=None, stream_id_seq=None,):108 headers = {'content-type': 'application/json'}109 data = dict(name=name,110 scale=scale,111 panX=panX,112 panY=panY,113 device_id_seq=device_id_seq,114 link_id_seq=link_id_seq,115 group_id_seq=group_id_seq,116 stream_id_seq=stream_id_seq,117 )118 data = {x: y for x, y in data.items() if y is not None}119 response = requests.patch(util.get_url() + "/api/v2/canvas/topology/" + str(topology_id) + "/",120 data=json.dumps(data),121 verify=util.get_verify(),122 auth=util.get_auth(),123 headers=headers)124 return response125def delete_topology(topology_id):126 response = requests.delete(util.get_url() + "/api/v2/canvas/topology/" + str(topology_id), verify=util.get_verify(), auth=util.get_auth())127 return response128def list_interface(**kwargs):129 response = util.unpaginate(util.get_url(), '/api/v2/canvas/interface/', util.get_verify(), util.get_auth(), kwargs)130 return response131def get_interface(interface_id):132 response = requests.get(util.get_url() + "/api/v2/canvas/interface/" + str(interface_id), verify=util.get_verify(), auth=util.get_auth())133 return response.json()134def create_interface(device, name, id,):135 headers = {'content-type': 'application/json'}136 response = requests.post(util.get_url() + "/api/v2/canvas/interface/", data=json.dumps(dict(device=device,137 name=name,138 id=id,139 )),140 verify=util.get_verify(),141 auth=util.get_auth(),142 headers=headers)143 return response.json()144def update_interface(interface_id, device=None, name=None, id=None,):145 headers = {'content-type': 'application/json'}146 data = dict(device=device,147 name=name,148 id=id,149 )150 data = {x: y for x, y in data.items() if y is not None}151 response = requests.patch(util.get_url() + "/api/v2/canvas/interface/" + str(interface_id) + "/",152 data=json.dumps(data),153 verify=util.get_verify(),154 auth=util.get_auth(),155 headers=headers)156 return response157def delete_interface(interface_id):158 response = requests.delete(util.get_url() + "/api/v2/canvas/interface/" + str(interface_id), verify=util.get_verify(), auth=util.get_auth())159 return response160def list_group(**kwargs):161 response = util.unpaginate(util.get_url(), '/api/v2/canvas/group/', util.get_verify(), util.get_auth(), kwargs)162 return response163def get_group(group_id):164 response = requests.get(util.get_url() + "/api/v2/canvas/group/" + str(group_id), verify=util.get_verify(), auth=util.get_auth())165 return response.json()166def create_group(id, name, x1, y1, x2, y2, topology, group_type, inventory_group_id=0,):167 headers = {'content-type': 'application/json'}168 response = requests.post(util.get_url() + "/api/v2/canvas/group/", data=json.dumps(dict(id=id,169 name=name,170 x1=x1,171 y1=y1,172 x2=x2,173 y2=y2,174 topology=topology,175 group_type=group_type,176 inventory_group_id=inventory_group_id,177 )),178 verify=util.get_verify(),179 auth=util.get_auth(),180 headers=headers)181 return response.json()182def update_group(group_id, id=None, name=None, x1=None, y1=None, x2=None, y2=None, topology=None, group_type=None, inventory_group_id=None,):183 headers = {'content-type': 'application/json'}184 data = dict(id=id,185 name=name,186 x1=x1,187 y1=y1,188 x2=x2,189 y2=y2,190 topology=topology,191 group_type=group_type,192 inventory_group_id=inventory_group_id,193 )194 data = {x: y for x, y in data.items() if y is not None}195 response = requests.patch(util.get_url() + "/api/v2/canvas/group/" + str(group_id) + "/",196 data=json.dumps(data),197 verify=util.get_verify(),198 auth=util.get_auth(),199 headers=headers)200 return response201def delete_group(group_id):202 response = requests.delete(util.get_url() + "/api/v2/canvas/group/" + str(group_id), verify=util.get_verify(), auth=util.get_auth())203 return response204def list_groupdevice(**kwargs):205 response = util.unpaginate(util.get_url(), '/api/v2/canvas/groupdevice/', util.get_verify(), util.get_auth(), kwargs)206 return response207def get_groupdevice(group_device_id):208 response = requests.get(util.get_url() + "/api/v2/canvas/groupdevice/" + str(group_device_id), verify=util.get_verify(), auth=util.get_auth())209 return response.json()210def create_groupdevice(group, device,):211 headers = {'content-type': 'application/json'}212 response = requests.post(util.get_url() + "/api/v2/canvas/groupdevice/", data=json.dumps(dict(group=group,213 device=device,214 )),215 verify=util.get_verify(),216 auth=util.get_auth(),217 headers=headers)218 return response.json()219def update_groupdevice(group_device_id, group=None, device=None,):220 headers = {'content-type': 'application/json'}221 data = dict(group=group,222 device=device,223 )224 data = {x: y for x, y in data.items() if y is not None}225 response = requests.patch(util.get_url() + "/api/v2/canvas/groupdevice/" + str(group_device_id) + "/",226 data=json.dumps(data),227 verify=util.get_verify(),228 auth=util.get_auth(),229 headers=headers)230 return response231def delete_groupdevice(group_device_id):232 response = requests.delete(util.get_url() + "/api/v2/canvas/groupdevice/" + str(group_device_id), verify=util.get_verify(), auth=util.get_auth())233 return response234def list_stream(**kwargs):235 response = util.unpaginate(util.get_url(), '/api/v2/canvas/stream/', util.get_verify(), util.get_auth(), kwargs)236 return response237def get_stream(stream_id):238 response = requests.get(util.get_url() + "/api/v2/canvas/stream/" + str(stream_id), verify=util.get_verify(), auth=util.get_auth())239 return response.json()240def create_stream(from_device, to_device, label, id=0,):241 headers = {'content-type': 'application/json'}242 response = requests.post(util.get_url() + "/api/v2/canvas/stream/", data=json.dumps(dict(from_device=from_device,243 to_device=to_device,244 label=label,245 id=id,246 )),247 verify=util.get_verify(),248 auth=util.get_auth(),249 headers=headers)250 return response.json()251def update_stream(stream_id, from_device=None, to_device=None, label=None, id=None,):252 headers = {'content-type': 'application/json'}253 data = dict(from_device=from_device,254 to_device=to_device,255 label=label,256 id=id,257 )258 data = {x: y for x, y in data.items() if y is not None}259 response = requests.patch(util.get_url() + "/api/v2/canvas/stream/" + str(stream_id) + "/",260 data=json.dumps(data),261 verify=util.get_verify(),262 auth=util.get_auth(),263 headers=headers)264 return response265def delete_stream(stream_id):266 response = requests.delete(util.get_url() + "/api/v2/canvas/stream/" + str(stream_id), verify=util.get_verify(), auth=util.get_auth())267 return response268def list_process(**kwargs):269 response = util.unpaginate(util.get_url(), '/api/v2/canvas/process/', util.get_verify(), util.get_auth(), kwargs)270 return response271def get_process(process_id):272 response = requests.get(util.get_url() + "/api/v2/canvas/process/" + str(process_id), verify=util.get_verify(), auth=util.get_auth())273 return response.json()274def create_process(device, name, process_type, id=0,):275 headers = {'content-type': 'application/json'}276 response = requests.post(util.get_url() + "/api/v2/canvas/process/", data=json.dumps(dict(device=device,277 name=name,278 process_type=process_type,279 id=id,280 )),281 verify=util.get_verify(),282 auth=util.get_auth(),283 headers=headers)284 return response.json()285def update_process(process_id, device=None, name=None, process_type=None, id=None,):286 headers = {'content-type': 'application/json'}287 data = dict(device=device,288 name=name,289 process_type=process_type,290 id=id,291 )292 data = {x: y for x, y in data.items() if y is not None}293 response = requests.patch(util.get_url() + "/api/v2/canvas/process/" + str(process_id) + "/",294 data=json.dumps(data),295 verify=util.get_verify(),296 auth=util.get_auth(),297 headers=headers)298 return response299def delete_process(process_id):300 response = requests.delete(util.get_url() + "/api/v2/canvas/process/" + str(process_id), verify=util.get_verify(), auth=util.get_auth())301 return response302def list_toolbox(**kwargs):303 response = util.unpaginate(util.get_url(), '/api/v2/canvas/toolbox/', util.get_verify(), util.get_auth(), kwargs)304 return response305def get_toolbox(toolbox_id):306 response = requests.get(util.get_url() + "/api/v2/canvas/toolbox/" + str(toolbox_id), verify=util.get_verify(), auth=util.get_auth())307 return response.json()308def create_toolbox(name,):309 headers = {'content-type': 'application/json'}310 response = requests.post(util.get_url() + "/api/v2/canvas/toolbox/", data=json.dumps(dict(name=name,311 )),312 verify=util.get_verify(),313 auth=util.get_auth(),314 headers=headers)315 return response.json()316def update_toolbox(toolbox_id, name=None,):317 headers = {'content-type': 'application/json'}318 data = dict(name=name,319 )320 data = {x: y for x, y in data.items() if y is not None}321 response = requests.patch(util.get_url() + "/api/v2/canvas/toolbox/" + str(toolbox_id) + "/",322 data=json.dumps(data),323 verify=util.get_verify(),324 auth=util.get_auth(),325 headers=headers)326 return response327def delete_toolbox(toolbox_id):328 response = requests.delete(util.get_url() + "/api/v2/canvas/toolbox/" + str(toolbox_id), verify=util.get_verify(), auth=util.get_auth())329 return response330def list_toolboxitem(**kwargs):331 response = util.unpaginate(util.get_url(), '/api/v2/canvas/toolboxitem/', util.get_verify(), util.get_auth(), kwargs)332 return response333def get_toolboxitem(toolbox_item_id):334 response = requests.get(util.get_url() + "/api/v2/canvas/toolboxitem/" + str(toolbox_item_id), verify=util.get_verify(), auth=util.get_auth())335 return response.json()336def create_toolboxitem(toolbox, data,):337 headers = {'content-type': 'application/json'}338 response = requests.post(util.get_url() + "/api/v2/canvas/toolboxitem/", data=json.dumps(dict(toolbox=toolbox,339 data=data,340 )),341 verify=util.get_verify(),342 auth=util.get_auth(),343 headers=headers)344 return response.json()345def update_toolboxitem(toolbox_item_id, toolbox=None, data=None,):346 headers = {'content-type': 'application/json'}347 data = dict(toolbox=toolbox,348 data=data,349 )350 data = {x: y for x, y in data.items() if y is not None}351 response = requests.patch(util.get_url() + "/api/v2/canvas/toolboxitem/" + str(toolbox_item_id) + "/",352 data=json.dumps(data),353 verify=util.get_verify(),354 auth=util.get_auth(),355 headers=headers)356 return response357def delete_toolboxitem(toolbox_item_id):358 response = requests.delete(util.get_url() + "/api/v2/canvas/toolboxitem/" + str(toolbox_item_id), verify=util.get_verify(), auth=util.get_auth())359 return response360def list_topologyinventory(**kwargs):361 response = util.unpaginate(util.get_url(), '/api/v2/canvas/topologyinventory/', util.get_verify(), util.get_auth(), kwargs)362 return response363def get_topologyinventory(topology_inventory_id):364 response = requests.get(util.get_url() + "/api/v2/canvas/topologyinventory/" + str(topology_inventory_id), verify=util.get_verify(), auth=util.get_auth())365 return response.json()366def create_topologyinventory(topology, inventory_id,):367 headers = {'content-type': 'application/json'}368 response = requests.post(util.get_url() + "/api/v2/canvas/topologyinventory/", data=json.dumps(dict(topology=topology,369 inventory_id=inventory_id,370 )),371 verify=util.get_verify(),372 auth=util.get_auth(),373 headers=headers)374 return response.json()375def update_topologyinventory(topology_inventory_id, topology=None, inventory_id=None,):376 headers = {'content-type': 'application/json'}377 data = dict(topology=topology,378 inventory_id=inventory_id,379 )380 data = {x: y for x, y in data.items() if y is not None}381 response = requests.patch(util.get_url() + "/api/v2/canvas/topologyinventory/" + str(topology_inventory_id) + "/",382 data=json.dumps(data),383 verify=util.get_verify(),384 auth=util.get_auth(),385 headers=headers)386 return response387def delete_topologyinventory(topology_inventory_id):388 response = requests.delete(util.get_url() + "/api/v2/canvas/topologyinventory/" +389 str(topology_inventory_id), verify=util.get_verify(), auth=util.get_auth())...
test_get_all_repos.py
Source:test_get_all_repos.py
...103. JSON Schema Validation.11'''12class TestFunctional(object):13 def test_verify_get_all_response(self):14 data = get_data(get_repos_url(username=get_auth()[0]), auth=get_auth(), in_json=True)15 verify_common.verify_repo_data(data, 'Demo11236')16 def test_verify_get_all_http_code(self):17 data = get_data(get_repos_url(username=get_auth()[0]), auth=get_auth(), in_json=False)18 verify_common.verify_http_code(data, '200')19 def test_verify_get_all_important_keys(self):20 data = get_data(get_repos_url(username=get_auth()[0]), auth=get_auth(), in_json=True)21 verify_common.verify_important_keys(data, 'id,,name,html_url')22 def test_verify_get_all_headers(self):23 data = get_data(get_repos_url(username=get_auth()[0]), auth=get_auth(), in_json=False)24 verify_common.verify_headers(data, 'application/json; charset=utf-8')25 def test_verify_get_all_id_exist(self):26 data = get_data(get_repos_url(username=get_auth()[0]), auth=get_auth(), in_json=True)27 verify_common.verify_id_exist(data, 'id')28class TestContract(object):29 def test_contract_get_all(self):30 data = get_data(get_repos_url(username=get_auth()[0]), auth=get_auth(), in_json=True)...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!