ModulesOperations Class

ModulesOperations operations.

Inheritance
builtins.object
ModulesOperations

Constructor

ModulesOperations(client, config, serializer, deserializer)

Parameters

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

api_version

Version of the Api. Constant value: "2021-04-12".

Methods

create_or_update_identity

Creates or updates the module identity for a device in the IoT Hub. The moduleId and generationId cannot be updated by the user.

delete_identity

Deletes the module identity for a device in the IoT Hub.

get_identity

Gets a module identity on the device.

get_modules_on_device

Gets all the module identities on the device.

get_twin

Gets the module 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 module of 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 module 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 module 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 module identity for a device in the IoT Hub. The moduleId and generationId cannot be updated by the user.

create_or_update_identity(id, mid, module, if_match=None, custom_headers=None, raw=False, **operation_config)

Parameters

id
str
Required

The unique identifier of the device.

mid
str
Required

The unique identifier of the module.

module
Module
Required

The module identity.

if_match
str
default value: None

The string representing a weak ETag for the module, as per RFC7232. This should not be set when creating a module, but may be set when updating a module.

custom_headers
dict
default value: None

headers that will be added to the request

raw
bool
default value: False

returns the direct response alongside the deserialized response

operation_config
Required

Operation configuration overrides.

Returns

Module or ClientRawResponse if raw=true

Return type

Exceptions

delete_identity

Deletes the module identity for a device in the IoT Hub.

delete_identity(id, mid, if_match=None, custom_headers=None, raw=False, **operation_config)

Parameters

id
str
Required

The unique identifier of the deivce.

mid
str
Required

The unique identifier of the module.

if_match
str
default value: None

The string representing a weak ETag for the module, as per RFC7232. The delete operation is performed only if this ETag matches the value maintained by the server, indicating that the module has not been modified since it was last retrieved. To force an unconditional delete, set If-Match to the wildcard character (*).

custom_headers
dict
default value: None

headers that will be added to the request

raw
bool
default value: False

returns the direct response alongside the deserialized response

operation_config
Required

Operation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None,

Exceptions

get_identity

Gets a module identity on the device.

get_identity(id, mid, custom_headers=None, raw=False, **operation_config)

Parameters

id
str
Required

The unique identifier of the device.

mid
str
Required

The unique identifier of the module.

custom_headers
dict
default value: None

headers that will be added to the request

raw
bool
default value: False

returns the direct response alongside the deserialized response

operation_config
Required

Operation configuration overrides.

Returns

Module or ClientRawResponse if raw=true

Return type

Exceptions

get_modules_on_device

Gets all the module identities on the device.

get_modules_on_device(id, custom_headers=None, raw=False, **operation_config)

Parameters

id
str
Required

The unique identifier of the device.

custom_headers
dict
default value: None

headers that will be added to the request

raw
bool
default value: False

returns the direct response alongside the deserialized response

operation_config
Required

Operation configuration overrides.

Returns

list or ClientRawResponse if raw=true

Return type

Exceptions

get_twin

Gets the module twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information.

get_twin(id, mid, custom_headers=None, raw=False, **operation_config)

Parameters

id
str
Required

The unique identifier of the device.

mid
str
Required

The unique identifier of the module.

custom_headers
dict
default value: None

headers that will be added to the request

raw
bool
default value: False

returns the direct response alongside the deserialized response

operation_config
Required

Operation configuration overrides.

Returns

Twin or ClientRawResponse if raw=true

Return type

Twin,

Exceptions

invoke_method

Invokes a direct method on a module of a device. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-direct-methods for more information.

invoke_method(device_id, module_id, direct_method_request, custom_headers=None, raw=False, **operation_config)

Parameters

device_id
str
Required

The unique identifier of the device.

module_id
str
Required

The unique identifier of the module.

direct_method_request
CloudToDeviceMethod
Required

The parameters to execute a direct method on the module.

custom_headers
dict
default value: None

headers that will be added to the request

raw
bool
default value: False

returns the direct response alongside the deserialized response

operation_config
Required

Operation configuration overrides.

Returns

CloudToDeviceMethodResult or ClientRawResponse if raw=true

Return type

Exceptions

replace_twin

Replaces the tags and desired properties of a module twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information.

replace_twin(id, mid, device_twin_info, if_match=None, custom_headers=None, raw=False, **operation_config)

Parameters

id
str
Required

The unique identifier of the device.

mid
str
Required

The unique identifier of the module.

device_twin_info
Twin
Required

The module twin info that will replace the existing info.

if_match
str
default value: None

The string representing a weak ETag for the device twin, as per RFC7232. It determines if the replace operation should be carried out.

custom_headers
dict
default value: None

headers that will be added to the request

raw
bool
default value: False

returns the direct response alongside the deserialized response

operation_config
Required

Operation configuration overrides.

Returns

Twin or ClientRawResponse if raw=true

Return type

Twin,

Exceptions

update_twin

Updates the tags and desired properties of a module twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information.

update_twin(id, mid, device_twin_info, if_match=None, custom_headers=None, raw=False, **operation_config)

Parameters

id
str
Required

The unique identifier of the device.

mid
str
Required

The unique identifier of the module.

device_twin_info
Twin
Required

The module twin info containing the tags and desired properties to be updated.

if_match
str
default value: None

The string representing a weak ETag for the device twin, as per RFC7232. It determines if the update operation should be carried out.

custom_headers
dict
default value: None

headers that will be added to the request

raw
bool
default value: False

returns the direct response alongside the deserialized response

operation_config
Required

Operation configuration overrides.

Returns

Twin or ClientRawResponse if raw=true

Return type

Twin,

Exceptions

Attributes

models

models = <module 'azure.iot.hub.protocol.models' from 'C:\\hostedtoolcache\\windows\\Python\\3.9.13\\x64\\lib\\site-packages\\azure\\iot\\hub\\protocol\\models\\__init__.py'>