def update(self, device_keys):
has_devices = self.get_devices()
has_ids = set([dev['id'] for dev in has_devices])
should_ids = has_ids | set(device_keys)
diff_ids = has_ids ^ should_ids
if not diff_ids:
return # nothing to add
# need to append to what's already in the pool,
# since this is a PUT action
for new_id in diff_ids:
has_devices.append(dict(id=new_id))
timeout = 3000
@retrying.retry(wait_fixed=1000, stop_max_delay=timeout)
def put_updated():
got = self.api.requests.put(
self.url, json=dict(display_name='Default Pool',
devices=has_devices))
if not got.ok:
raise SessionRqstError(
message='unable to update approved list: %s' % got.text,
resp=got)
put_updated()
评论列表
文章目录