Lines Matching +full:data +full:- +full:timeout

7 SPDX-License-Identifier: Apache-2.0
25 self.timeout = 10
42 - response: The response object received from the server.
45 - dict: The parsed JSON response as a dictionary.
48 - Exception: If the response indicates an error condition.
59 params = {'timeout': self.timeout}
62 resp = self._s.get(f'{self.api_url}{path}', params=params, timeout=self.timeout)
65 …def put_raw(self, path: str, data: str | dict | None = None, headers: dict | None = None, params: …
67 …resp = self._s.put(f'{self.api_url}{path}', data=data, headers=headers, params=params, timeout=sel…
70 def put(self, path: str, data: str | dict, uri_options: str = ''):
72 if isinstance(data, dict):
73 data = json.dumps(data)
74 …return self.put_raw(f'{path}?timeout={self.timeout}&format={self.format}' + uri_options, data=data
76 def post(self, path: str, data: str | dict | None = None):
78 if isinstance(data, dict):
79 data = json.dumps(data)
80 if data is not None:
81 headers={'content-type': 'application/json'}
82 uri_options = f'?timeout={self.timeout}&format={self.format}'
86 …self._s.post(f'{self.api_url}{path}' + uri_options, data=data, headers=headers, timeout=self.timeo…
91 resp = self._s.delete(f'{self.api_url}{path}', timeout=self.timeout)
108 rid = path.split('/')[-1]
112 """Send LwM2M Write-Attributes to given path
119 """Send LwM2M Write-Attributes to given path
128 data = self._define_obj_inst(path, resources)
129 return self.put(f'/clients/{endpoint}/{path}', data, uri_options='&replace=false')
133 data = self._define_obj_inst(path, resources)
134 return self.put(f'/clients/{endpoint}/{path}', data, uri_options='&replace=true')
138 data = self._define_obj_inst(path, resources)
139 path = '/'.join(path.split('/')[:-1]) # Create call should not have instance ID in path
140 return self.post(f'/clients/{endpoint}/{path}', data)
148 - value: The value to be converted.
151 - str: The string representation of the value.
176 data = {
178 "id": int(path.split('/')[-1]), # ID is last element of path
186 data['resources'].append(cls._define_resource(key, value, kind))
187 return data
272 data = {}
280 data.update(cls._decode_obj(obj))
284 data.update(cls._decode_obj(content))
286 if keys[0] not in data:
287 data[keys[0]] = {}
288 data[keys[0]].update(cls._decode_obj_inst(content))
290 if keys[0] not in data:
291 data[keys[0]] = {}
292 if keys[1] not in data[keys[0]]:
293 data[keys[0]][keys[1]] = {}
294 data[keys[0]][keys[1]].update(cls._decode_resource(content))
296 if keys[0] not in data:
297 data[keys[0]] = {}
298 if keys[1] not in data[keys[0]]:
299 data[keys[0]][keys[1]] = {}
300 if keys[2] not in data[keys[0]][keys[1]]:
301 data[keys[0]][keys[1]][keys[2]] = {}
302 data[keys[0]][keys[1]][keys[2]].update(cls._decode_resource(content))
305 return data
312 'timeout': self.timeout
321 """Send LwM2M Composite-Read command and decode the response to a Python dictionary"""
323 …elf._s.get(f'{self.api_url}/clients/{endpoint}/composite', params=parameters, timeout=self.timeout)
329 Send LwM2m Composite-Write operation.
345 data = { }
349 level = len(path.split('/')) - 1
350 rid = int(path.split('/')[-1])
360 data[path] = value
362 …f'{self.api_url}/clients/{endpoint}/composite', params=parameters, json=data, timeout=self.timeout)
366 …e_response(self._s.get(f'{self.api_url}/clients/{endpoint}/{path}/discover', timeout=self.timeout))
367 data = {}
369 data[obj['url']] = obj['attributes']
370 return data
381data = f'{{"tls":{{"mode":"psk","details":{{"identity":"{endpoint}","key":"{psk}"}}}},"endpoint":"…
382 self.put('/security/clients/', data)
393 return self.post(f'/clients/{endpoint}/{path}/observe', data="")
403 …st(f'{self.api_url}/clients/{endpoint}/composite/observe', params=parameters, timeout=self.timeout)
416 def get_event_stream(self, endpoint: str, timeout: int = None):
424 data = events.next_event('SEND')
426 If timeout happens, the event streams returns None.
428 if timeout is None:
429 timeout = self.timeout
430 ….api_url}/event?{endpoint}', stream=True, headers={'Accept': 'text/event-stream'}, timeout=timeout)
432 r.encoding = 'utf-8'
434 yield LeshanEventsIterator(r, timeout)
440 def __init__(self, req: requests.Response, timeout: int):
443 self._timeout = timeout
449 If timeout happens, the returns None.
451 timeout = time.time() + self._timeout
456 if not line.startswith('data: '):
458 data = json.loads(line.removeprefix('data: '))
459 … if event == 'SEND' or (event == 'NOTIFICATION' and data['kind'] == 'composite'):
460 return Leshan.parse_composite(data['val'])
462 d = {data['res']: data['val']}
464 return data
465 if time.time() > timeout:
467 except requests.exceptions.Timeout: