Skip to content

Commit

Permalink
fix device update (#271)
Browse files Browse the repository at this point in the history
  • Loading branch information
YingXue authored Nov 10, 2020
1 parent 9f77b9a commit 89e0fb9
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions azext_iot/operations/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def iot_device_create(

try:
device = _assemble_device(
False,
device_id,
auth_method,
edge_enabled,
Expand All @@ -194,6 +195,7 @@ def iot_device_create(


def _assemble_device(
is_update,
device_id,
auth_method,
edge_enabled,
Expand All @@ -207,6 +209,16 @@ def _assemble_device(

auth = _assemble_auth(auth_method, pk, sk)
cap = DeviceCapabilities(iot_edge=edge_enabled)
if is_update:
device = Device(
device_id=device_id,
authentication=auth,
capabilities=cap,
status=status,
status_reason=status_reason,
device_scope=device_scope,
)
return device
if edge_enabled:
parent_scope = []
if device_scope:
Expand Down Expand Up @@ -324,12 +336,15 @@ def iot_device_update(

auth, pk, sk = _parse_auth(parameters)
updated_device = _assemble_device(
True,
parameters['deviceId'],
auth, parameters['capabilities']['iotEdge'],
auth,
parameters['capabilities']['iotEdge'],
pk,
sk,
parameters['status'].lower(),
parameters.get('statusReason')
parameters.get('statusReason'),
parameters.get('deviceScope')
)
updated_device.etag = parameters.get("etag", "*")
return _iot_device_update(target, device_id, updated_device)
Expand Down

0 comments on commit 89e0fb9

Please sign in to comment.