DevicesOperations Class
DevicesOperations operations.
- Inheritance
-
builtins.objectDevicesOperations
Constructor
DevicesOperations(client, config, serializer, deserializer)
Parameters
Name | Description |
---|---|
client
Required
|
Client for service requests. |
config
Required
|
Configuration of service client. |
serializer
Required
|
An object model serializer. |
deserializer
Required
|
An object model deserializer. |
Variables
Name | Description |
---|---|
api_version
|
Version of the Api. Constant value: "2021-04-12". |
Methods
create_or_update_identity |
Creates or updates the identity of a device in the identity registry of the IoT Hub. |
delete_identity |
Deletes the identity of a device from the identity registry of the IoT Hub. |
get_devices |
Gets the identities of multiple devices from the IoT Hub identity registry. Not recommended. Use the IoT Hub query API to retrieve device twin and device identity information. See https://docs.microsoft.com/en-us/rest/api/iothub/service/queryiothub and https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-query-language for more information. |
get_identity |
Gets a device from the identity registry of the IoT Hub. |
get_twin |
Gets the device twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information. |
invoke_method |
Invokes a direct method on a device. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-direct-methods for more information. |
replace_twin |
Replaces the tags and desired properties of a device twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information. |
update_twin |
Updates the tags and desired properties of a device twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information. |
create_or_update_identity
Creates or updates the identity of a device in the identity registry of the IoT Hub.
create_or_update_identity(id, device, if_match=None, custom_headers=None, raw=False, **operation_config)
Parameters
Name | Description |
---|---|
id
Required
|
The unique identifier of the device. |
device
Required
|
The contents of the device identity. |
if_match
|
The string representing a weak ETag for the device identity, as per RFC7232. This should not be set when creating a device, but may be set when updating a device. Default value: None
|
custom_headers
|
headers that will be added to the request Default value: None
|
raw
|
returns the direct response alongside the deserialized response Default value: False
|
operation_config
Required
|
Operation configuration overrides. |
Returns
Type | Description |
---|---|
<xref:msrest.pipeline.ClientRawResponse>
|
Device or ClientRawResponse if raw=true |
Exceptions
Type | Description |
---|---|
msrest.exceptions.HttpOperationError
|
delete_identity
Deletes the identity of a device from the identity registry of the IoT Hub.
delete_identity(id, if_match=None, custom_headers=None, raw=False, **operation_config)
Parameters
Name | Description |
---|---|
id
Required
|
The unique identifier of the device. |
if_match
|
The string representing a weak ETag for the device identity, as per RFC7232. The delete operation is performed only if this ETag matches the value maintained by the server, indicating that the device identity has not been modified since it was last retrieved. To force an unconditional delete, set If-Match to the wildcard character (*). Default value: None
|
custom_headers
|
headers that will be added to the request Default value: None
|
raw
|
returns the direct response alongside the deserialized response Default value: False
|
operation_config
Required
|
Operation configuration overrides. |
Returns
Type | Description |
---|---|
None,
<xref:msrest.pipeline.ClientRawResponse>
|
None or ClientRawResponse if raw=true |
Exceptions
Type | Description |
---|---|
msrest.exceptions.HttpOperationError
|
get_devices
Gets the identities of multiple devices from the IoT Hub identity registry. Not recommended. Use the IoT Hub query API to retrieve device twin and device identity information. See https://docs.microsoft.com/en-us/rest/api/iothub/service/queryiothub and https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-query-language for more information.
get_devices(top=None, custom_headers=None, raw=False, **operation_config)
Parameters
Name | Description |
---|---|
top
|
The maximum number of device identities returned by the query. Any value outside the range of 1-1000 is considered to be 1000. Default value: None
|
custom_headers
|
headers that will be added to the request Default value: None
|
raw
|
returns the direct response alongside the deserialized response Default value: False
|
operation_config
Required
|
Operation configuration overrides. |
Returns
Type | Description |
---|---|
<xref:msrest.pipeline.ClientRawResponse>
|
list or ClientRawResponse if raw=true |
Exceptions
Type | Description |
---|---|
msrest.exceptions.HttpOperationError
|
get_identity
Gets a device from the identity registry of the IoT Hub.
get_identity(id, custom_headers=None, raw=False, **operation_config)
Parameters
Name | Description |
---|---|
id
Required
|
The unique identifier of the device. |
custom_headers
|
headers that will be added to the request Default value: None
|
raw
|
returns the direct response alongside the deserialized response Default value: False
|
operation_config
Required
|
Operation configuration overrides. |
Returns
Type | Description |
---|---|
<xref:msrest.pipeline.ClientRawResponse>
|
Device or ClientRawResponse if raw=true |
Exceptions
Type | Description |
---|---|
msrest.exceptions.HttpOperationError
|
get_twin
Gets the device twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information.
get_twin(id, custom_headers=None, raw=False, **operation_config)
Parameters
Name | Description |
---|---|
id
Required
|
The unique identifier of the device. |
custom_headers
|
headers that will be added to the request Default value: None
|
raw
|
returns the direct response alongside the deserialized response Default value: False
|
operation_config
Required
|
Operation configuration overrides. |
Returns
Type | Description |
---|---|
Twin,
<xref:msrest.pipeline.ClientRawResponse>
|
Twin or ClientRawResponse if raw=true |
Exceptions
Type | Description |
---|---|
msrest.exceptions.HttpOperationError
|
invoke_method
Invokes a direct method on a device. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-direct-methods for more information.
invoke_method(device_id, direct_method_request, custom_headers=None, raw=False, **operation_config)
Parameters
Name | Description |
---|---|
device_id
Required
|
The unique identifier of the device. |
direct_method_request
Required
|
The parameters to execute a direct method on the device. |
custom_headers
|
headers that will be added to the request Default value: None
|
raw
|
returns the direct response alongside the deserialized response Default value: False
|
operation_config
Required
|
Operation configuration overrides. |
Returns
Type | Description |
---|---|
<xref:msrest.pipeline.ClientRawResponse>
|
CloudToDeviceMethodResult or ClientRawResponse if raw=true |
Exceptions
Type | Description |
---|---|
msrest.exceptions.HttpOperationError
|
replace_twin
Replaces the tags and desired properties of a device twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information.
replace_twin(id, device_twin_info, if_match=None, custom_headers=None, raw=False, **operation_config)
Parameters
Name | Description |
---|---|
id
Required
|
The unique identifier of the device. |
device_twin_info
Required
|
The device twin info that will replace the existing info. |
if_match
|
The string representing a weak ETag for the device twin, as per RFC7232. It determines if the replace operation should be carried out. Default value: None
|
custom_headers
|
headers that will be added to the request Default value: None
|
raw
|
returns the direct response alongside the deserialized response Default value: False
|
operation_config
Required
|
Operation configuration overrides. |
Returns
Type | Description |
---|---|
Twin,
<xref:msrest.pipeline.ClientRawResponse>
|
Twin or ClientRawResponse if raw=true |
Exceptions
Type | Description |
---|---|
msrest.exceptions.HttpOperationError
|
update_twin
Updates the tags and desired properties of a device twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information.
update_twin(id, device_twin_info, if_match=None, custom_headers=None, raw=False, **operation_config)
Parameters
Name | Description |
---|---|
id
Required
|
The unique identifier of the device. |
device_twin_info
Required
|
The device twin info containing the tags and desired properties to be updated. |
if_match
|
The string representing a weak ETag for the device twin, as per RFC7232. It determines if the update operation should be carried out. Default value: None
|
custom_headers
|
headers that will be added to the request Default value: None
|
raw
|
returns the direct response alongside the deserialized response Default value: False
|
operation_config
Required
|
Operation configuration overrides. |
Returns
Type | Description |
---|---|
Twin,
<xref:msrest.pipeline.ClientRawResponse>
|
Twin or ClientRawResponse if raw=true |
Exceptions
Type | Description |
---|---|
msrest.exceptions.HttpOperationError
|
Attributes
models
models = <module 'azure.iot.hub.protocol.models' from 'C:\\hostedtoolcache\\windows\\Python\\3.11.9\\x64\\Lib\\site-packages\\azure\\iot\\hub\\protocol\\models\\__init__.py'>
Azure SDK for Python