diff --git a/HISTORY.rst b/HISTORY.rst index de47b7dde..3b4fd2270 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -12,8 +12,14 @@ unreleased **Device Update** -* The Device Update control plane or infrastructure command groups `az iot device-update account` and +* The Device Update control plane (or infrastructure related) command groups `az iot device-update account` and `az iot device-update instance` now use the GA API version of 2022-10-01. +* The Device Update data plane command groups `az iot device-update device` and + `az iot device-update update` now use the GA API version of 2022-10-01. +* The command `az iot device-update device class list` adds support for `--filter` when no `--group-id` is provided. +* The parameters `--account`, `--instance`, and `--resource-group` support setting default overridable values via config. + Use `az config set` i.e. `az config set defaults.adu_account=` or `az configure` i.e. `az configure --defaults adu_account=`. +* Improved built-in documentation. 0.17.0 diff --git a/azext_iot/constants.py b/azext_iot/constants.py index fdae25557..02eab83b0 100644 --- a/azext_iot/constants.py +++ b/azext_iot/constants.py @@ -7,7 +7,7 @@ import os -VERSION = "0.17.0" +VERSION = "0.17.1" EXTENSION_NAME = "azure-iot" EXTENSION_ROOT = os.path.dirname(os.path.abspath(__file__)) EXTENSION_CONFIG_ROOT_KEY = "iotext" diff --git a/azext_iot/deviceupdate/_help.py b/azext_iot/deviceupdate/_help.py index d01d3a819..46d09c9cb 100644 --- a/azext_iot/deviceupdate/_help.py +++ b/azext_iot/deviceupdate/_help.py @@ -421,11 +421,15 @@ def load_deviceupdate_help(): text: > az iot device-update device class list -n {account_name} -i {instance_name} + - name: List instance device classes filtered by friendly name. + text: > + az iot device-update device class list -n {account_name} -i {instance_name} --filter "friendlyName eq 'my-favorite-class'" + - name: List device class subgroups for the group. text: > az iot device-update device class list -n {account_name} -i {instance_name} --group-id {device_group_id} - - name: List device class subgroups for the group, filtered by compatProperties/manufacturer + - name: List device class subgroups for the group, filtered by compatProperties/manufacturer. text: > az iot device-update device class list -n {account_name} -i {instance_name} --group-id {device_group_id} --filter "compatProperties/manufacturer eq 'Contoso'" """ @@ -471,7 +475,7 @@ def load_deviceupdate_help(): type: command short-summary: Delete a device class or device class subgroup. long-summary: > - Device classes are created automatically when Device Update-enabled devices are connected to + Device classes are automatically created when Device Update-enabled devices are connected to the hub but are not automatically cleaned up since they are referenced by device class subgroups. If all device class subgroups for a target device class are deleted then the device class itself can also be deleted to remove the records from the system and to stop checking the compatibility of the device class with new diff --git a/azext_iot/deviceupdate/commands_device.py b/azext_iot/deviceupdate/commands_device.py index fca134529..33f68fee7 100644 --- a/azext_iot/deviceupdate/commands_device.py +++ b/azext_iot/deviceupdate/commands_device.py @@ -133,15 +133,12 @@ def show_update_compliance(cmd, name: str, instance_name: str, resource_group_na handle_service_exception(e) -# @digimaun, pageable but not attributed correctly. def list_device_health(cmd, name: str, instance_name: str, filter: str, resource_group_name: Optional[str] = None): data_manager = DeviceUpdateDataManager( cmd=cmd, account_name=name, instance_name=instance_name, resource_group=resource_group_name ) try: - # "deviceId eq 'd0'" - # "state eq 'Healthy'" - return data_manager.data_client.device_management.list_device_health(filter=filter) + return data_manager.data_client.device_management.list_health_of_devices(filter=filter) except AzureError as e: handle_service_exception(e) diff --git a/azext_iot/deviceupdate/commands_device_class.py b/azext_iot/deviceupdate/commands_device_class.py index d1510251c..88710d746 100644 --- a/azext_iot/deviceupdate/commands_device_class.py +++ b/azext_iot/deviceupdate/commands_device_class.py @@ -28,15 +28,13 @@ def list_device_classes( data_manager = DeviceUpdateDataManager( cmd=cmd, account_name=name, instance_name=instance_name, resource_group=resource_group_name ) - if filter and not device_group_id: - raise ArgumentUsageError("--group-id is required when using --filter") if device_group_id: return data_manager.data_client.device_management.list_device_class_subgroups_for_group( group_id=device_group_id, filter=filter ) try: - return data_manager.data_client.device_management.list_device_classes() + return data_manager.data_client.device_management.list_device_classes(filter=filter) except AzureError as e: handle_service_exception(e) @@ -112,7 +110,6 @@ def update_device_class( logger.warning("No patch body option values provided. Update device class has no work to be done.") -# @digimaun, this operation doesn't work yet. def delete_device_class( cmd, name: str, @@ -129,6 +126,7 @@ def delete_device_class( return data_manager.data_client.device_management.delete_device_class_subgroup( device_class_id=device_class_id, group_id=device_group_id ) + # @digimaun, this operation returns a 404 today. return data_manager.data_client.device_management.delete_device_class(device_class_id=device_class_id) except AzureError as e: handle_service_exception(e) diff --git a/azext_iot/deviceupdate/commands_update.py b/azext_iot/deviceupdate/commands_update.py index 59f999d89..a07097eec 100644 --- a/azext_iot/deviceupdate/commands_update.py +++ b/azext_iot/deviceupdate/commands_update.py @@ -181,6 +181,9 @@ def import_handler(lro: ARMPolling): ) elif lro.status() == "Failed": try: + logger.warning( + "Cached contents (if any) from usage of --defer were not removed. " + "Use 'az cache' command group to manage.") logger.error(lro._pipeline_response.http_response.text()) except Exception: pass @@ -207,30 +210,3 @@ def delete_update( return data_manager.data_client.device_update.begin_delete_update( name=update_name, provider=update_provider, version=update_version ) - - -def list_operations( - cmd, - name: str, - instance_name: str, - filter=None, - top: Optional[int] = None, - resource_group_name: Optional[str] = None, -): - data_manager = DeviceUpdateDataManager( - cmd=cmd, account_name=name, instance_name=instance_name, resource_group=resource_group_name - ) - try: - return data_manager.data_client.device_update.list_operations(filter=filter, top=top) - except AzureError as e: - handle_service_exception(e) - - -def show_operation(cmd, name: str, instance_name: str, operation_id: str, resource_group_name: Optional[str] = None): - data_manager = DeviceUpdateDataManager( - cmd=cmd, account_name=name, instance_name=instance_name, resource_group=resource_group_name - ) - try: - return data_manager.data_client.device_update.get_operation(operation_id=operation_id) - except AzureError as e: - handle_service_exception(e) diff --git a/azext_iot/deviceupdate/params.py b/azext_iot/deviceupdate/params.py index 2fdd728f3..9f301c549 100644 --- a/azext_iot/deviceupdate/params.py +++ b/azext_iot/deviceupdate/params.py @@ -31,17 +31,25 @@ def load_deviceupdate_arguments(self, _): "resource_group_name", arg_type=resource_group_name_type, help="Device Update account resource group name. " - "You can configure the default group using `az configure --defaults group=`.", + "You can configure the default group using `az config set defaults.adu_group=`.", arg_group="Account Identifier", + configured_default="adu_group", ) context.argument( - "name", options_list=["-n", "--account"], help="Device Update account name.", arg_group="Account Identifier" + "name", + options_list=["-n", "--account"], + help="Device Update account name. " + "You can configure the default account name using `az config set defaults.adu_account=`.", + arg_group="Account Identifier", + configured_default="adu_account", ) context.argument( "instance_name", options_list=["-i", "--instance"], - help="Device Update instance name.", + help="Device Update instance name." + "You can configure the default instance name using `az config set defaults.adu_instance=`.", arg_group="Account Identifier", + configured_default="adu_instance", ) context.argument( "public_network_access", @@ -169,14 +177,14 @@ def load_deviceupdate_arguments(self, _): "search", options_list=["--search"], help="Request updates matching a free-text search expression. " - "Supported by list updates with no constraints.", + "Supported when listing updates with no constraints.", arg_group="Filter", ) context.argument( "filter", options_list=["--filter"], help="Restricts the set of updates returned by property values. " - "Supported by list update versions and list updates with no constraints.", + "Supported when listing updates with no constraints or when listing by version.", arg_group="Filter", ) @@ -211,8 +219,18 @@ def load_deviceupdate_arguments(self, _): ) with self.argument_context("iot device-update device") as context: - context.argument("device_group_id", options_list=["--group-id", "--gid"], help="Device group Id.") - context.argument("device_class_id", options_list=["--class-id", "--cid"], help="Device class Id.") + context.argument( + "device_group_id", + options_list=["--group-id", "--gid"], + help="Device group Id. This is created from the value of the ADUGroup tag in the connected IoT Hub's " + "device/module twin or $default for devices with no tag.", + ) + context.argument( + "device_class_id", + options_list=["--class-id", "--cid"], + help="Device class Id. This is generated from the model Id and the compat properties reported by the " + "device update agent in the Device Update PnP interface in IoT Hub. It is a hex-encoded SHA1 hash.", + ) with self.argument_context("iot device-update device list") as context: context.argument( @@ -243,7 +261,7 @@ def load_deviceupdate_arguments(self, _): options_list=["--best-update"], help="Flag indicating the command should fetch the best available update for the device class subgroup including " "a count of how many devices need the update. Group Id is required for this flag. " - "A best update is the lastest update that meets all compatibility specifications of a device class. ", + "A best update is the latest update that meets all compatibility specifications of a device class. ", arg_group="Update", arg_type=get_three_state_flag(), ) @@ -259,15 +277,17 @@ def load_deviceupdate_arguments(self, _): context.argument( "friendly_name", options_list=["--friendly-name"], - help="Friendly name associated with the device class.", + help="The device class friendly name. The friendly name must be 1 - 100 characters and supports " + "alphanumeric, dot and dash values.", ) with self.argument_context("iot device-update device class list") as context: context.argument( "filter", options_list=["--filter"], - help="Filters device class subgroups based on device class compat property names and values. " - "For example \"compatProperties/manufacturer eq 'Contoso'\". --group-id is required to use --filter." + help="If provided with --group-id, supports filtering based on device class compat property names " + "and values. For example \"compatProperties/manufacturer eq 'Contoso'\". " + "Otherwise supports filtering by class friendly name.", ) with self.argument_context("iot device-update device group") as context: @@ -276,7 +296,7 @@ def load_deviceupdate_arguments(self, _): options_list=["--best-updates"], help="Flag indicating the command should fetch the best available updates for the device group including " "a count of how many devices need each update. " - "A best update is the lastest update that meets all compatibility specifications of a device class. ", + "A best update is the latest update that meets all compatibility specifications of a device class. ", arg_group="Update", arg_type=get_three_state_flag(), ) @@ -305,7 +325,13 @@ def load_deviceupdate_arguments(self, _): ) with self.argument_context("iot device-update device deployment") as context: - context.argument("deployment_id", options_list=["--deployment-id", "--did"], help="Deployment Id.") + context.argument( + "deployment_id", + options_list=["--deployment-id", "--did"], + help="The caller-provided deployment Id. This cannot be longer than 73 characters, " + "must be all lower-case, and cannot contain '&', '^', '[', ']', '{', '}', '|', '<', '>', " + "forward slash, backslash, or double quote.", + ) context.argument( "status", options_list=["--status"], diff --git a/azext_iot/sdk/deviceupdate/dataplane/__init__.py b/azext_iot/sdk/deviceupdate/dataplane/__init__.py index 0d8960e0d..31308e71f 100644 --- a/azext_iot/sdk/deviceupdate/dataplane/__init__.py +++ b/azext_iot/sdk/deviceupdate/dataplane/__init__.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.8.4, generator: @autorest/python@5.19.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.2, generator: @autorest/python@5.19.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/azext_iot/sdk/deviceupdate/dataplane/_configuration.py b/azext_iot/sdk/deviceupdate/dataplane/_configuration.py index 01fd879e7..f4634099d 100644 --- a/azext_iot/sdk/deviceupdate/dataplane/_configuration.py +++ b/azext_iot/sdk/deviceupdate/dataplane/_configuration.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.8.4, generator: @autorest/python@5.19.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.2, generator: @autorest/python@5.19.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -24,12 +24,13 @@ class DeviceUpdateClientConfiguration(Configuration): # pylint: disable=too-man :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param endpoint: Account endpoint. Required. + :param endpoint: The Device Update for IoT Hub account endpoint (hostname only, no protocol). + Required. :type endpoint: str - :param instance_id: Account instance identifier. Required. + :param instance_id: The Device Update for IoT Hub account instance identifier. Required. :type instance_id: str - :keyword api_version: Api Version. Default value is "2022-07-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2022-10-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ @@ -41,7 +42,7 @@ def __init__( **kwargs: Any ) -> None: super(DeviceUpdateClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-07-01-preview") # type: str + api_version = kwargs.pop('api_version', "2022-10-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/azext_iot/sdk/deviceupdate/dataplane/_device_update_client.py b/azext_iot/sdk/deviceupdate/dataplane/_device_update_client.py index b734e3ed7..b712f92d1 100644 --- a/azext_iot/sdk/deviceupdate/dataplane/_device_update_client.py +++ b/azext_iot/sdk/deviceupdate/dataplane/_device_update_client.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.8.4, generator: @autorest/python@5.19.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.2, generator: @autorest/python@5.19.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -20,7 +20,7 @@ from azure.core.credentials import TokenCredential class DeviceUpdateClient: # pylint: disable=client-accepts-api-version-keyword - """Device Update for IoT Hub is an Azure service that enables customers to publish update for + """Device Update for IoT Hub is an Azure service that enables customers to publish updates for their IoT devices to the cloud, and then deploy that update to their devices (approve updates to groups of devices managed and provisioned in IoT Hub). It leverages the proven security and reliability of the Windows Update platform, optimized for IoT devices. It works globally and @@ -33,12 +33,13 @@ class DeviceUpdateClient: # pylint: disable=client-accepts-api-version-keyword :vartype device_management: deviceupdateclient.operations.DeviceManagementOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param endpoint: Account endpoint. Required. + :param endpoint: The Device Update for IoT Hub account endpoint (hostname only, no protocol). + Required. :type endpoint: str - :param instance_id: Account instance identifier. Required. + :param instance_id: The Device Update for IoT Hub account instance identifier. Required. :type instance_id: str - :keyword api_version: Api Version. Default value is "2022-07-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2022-10-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. diff --git a/azext_iot/sdk/deviceupdate/dataplane/_vendor.py b/azext_iot/sdk/deviceupdate/dataplane/_vendor.py index 3fd49b10f..9b3eb88e1 100644 --- a/azext_iot/sdk/deviceupdate/dataplane/_vendor.py +++ b/azext_iot/sdk/deviceupdate/dataplane/_vendor.py @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.8.4, generator: @autorest/python@5.19.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.2, generator: @autorest/python@5.19.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/azext_iot/sdk/deviceupdate/dataplane/_version.py b/azext_iot/sdk/deviceupdate/dataplane/_version.py index 23071ad1b..082114a0b 100644 --- a/azext_iot/sdk/deviceupdate/dataplane/_version.py +++ b/azext_iot/sdk/deviceupdate/dataplane/_version.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.8.4, generator: @autorest/python@5.19.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.2, generator: @autorest/python@5.19.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/azext_iot/sdk/deviceupdate/dataplane/aio/__init__.py b/azext_iot/sdk/deviceupdate/dataplane/aio/__init__.py deleted file mode 100644 index 93c68dc1f..000000000 --- a/azext_iot/sdk/deviceupdate/dataplane/aio/__init__.py +++ /dev/null @@ -1,18 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.8.4, generator: @autorest/python@5.19.0) -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._device_update_client import DeviceUpdateClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk -__all__ = ['DeviceUpdateClient'] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/azext_iot/sdk/deviceupdate/dataplane/aio/_configuration.py b/azext_iot/sdk/deviceupdate/dataplane/aio/_configuration.py deleted file mode 100644 index dc13079f5..000000000 --- a/azext_iot/sdk/deviceupdate/dataplane/aio/_configuration.py +++ /dev/null @@ -1,75 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.8.4, generator: @autorest/python@5.19.0) -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class DeviceUpdateClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for DeviceUpdateClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param endpoint: Account endpoint. Required. - :type endpoint: str - :param instance_id: Account instance identifier. Required. - :type instance_id: str - :keyword api_version: Api Version. Default value is "2022-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - endpoint: str, - instance_id: str, - **kwargs: Any - ) -> None: - super(DeviceUpdateClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-07-01-preview") # type: str - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if endpoint is None: - raise ValueError("Parameter 'endpoint' must not be None.") - if instance_id is None: - raise ValueError("Parameter 'instance_id' must not be None.") - - self.credential = credential - self.endpoint = endpoint - self.instance_id = instance_id - self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://api.adu.microsoft.com/.default']) - kwargs.setdefault('sdk_moniker', 'deviceupdateclient/{}'.format(VERSION)) - self._configure(**kwargs) - - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') - if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/azext_iot/sdk/deviceupdate/dataplane/aio/_device_update_client.py b/azext_iot/sdk/deviceupdate/dataplane/aio/_device_update_client.py deleted file mode 100644 index d8af05ee1..000000000 --- a/azext_iot/sdk/deviceupdate/dataplane/aio/_device_update_client.py +++ /dev/null @@ -1,108 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.8.4, generator: @autorest/python@5.19.0) -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core import AsyncPipelineClient -from azure.core.rest import AsyncHttpResponse, HttpRequest - -from .. import models -from .._serialization import Deserializer, Serializer -from ._configuration import DeviceUpdateClientConfiguration -from .operations import DeviceManagementOperations, DeviceUpdateOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - -class DeviceUpdateClient: # pylint: disable=client-accepts-api-version-keyword - """Device Update for IoT Hub is an Azure service that enables customers to publish update for - their IoT devices to the cloud, and then deploy that update to their devices (approve updates - to groups of devices managed and provisioned in IoT Hub). It leverages the proven security and - reliability of the Windows Update platform, optimized for IoT devices. It works globally and - knows when and how to update devices, enabling customers to focus on their business goals and - let Device Update for IoT Hub handle the updates. - - :ivar device_update: DeviceUpdateOperations operations - :vartype device_update: deviceupdateclient.aio.operations.DeviceUpdateOperations - :ivar device_management: DeviceManagementOperations operations - :vartype device_management: deviceupdateclient.aio.operations.DeviceManagementOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param endpoint: Account endpoint. Required. - :type endpoint: str - :param instance_id: Account instance identifier. Required. - :type instance_id: str - :keyword api_version: Api Version. Default value is "2022-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - endpoint: str, - instance_id: str, - **kwargs: Any - ) -> None: - _endpoint = 'https://{endpoint}' - self._config = DeviceUpdateClientConfiguration(credential=credential, endpoint=endpoint, instance_id=instance_id, **kwargs) - self._client = AsyncPipelineClient(base_url=_endpoint, config=self._config, **kwargs) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.device_update = DeviceUpdateOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.device_management = DeviceManagementOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - - request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "DeviceUpdateClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/azext_iot/sdk/deviceupdate/dataplane/aio/_patch.py b/azext_iot/sdk/deviceupdate/dataplane/aio/_patch.py deleted file mode 100644 index 0ad201a8c..000000000 --- a/azext_iot/sdk/deviceupdate/dataplane/aio/_patch.py +++ /dev/null @@ -1,19 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/azext_iot/sdk/deviceupdate/dataplane/aio/operations/__init__.py b/azext_iot/sdk/deviceupdate/dataplane/aio/operations/__init__.py deleted file mode 100644 index 0e1dc7820..000000000 --- a/azext_iot/sdk/deviceupdate/dataplane/aio/operations/__init__.py +++ /dev/null @@ -1,18 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.8.4, generator: @autorest/python@5.19.0) -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._device_update_operations import DeviceUpdateOperations -from ._device_management_operations import DeviceManagementOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk -__all__ = [ - 'DeviceUpdateOperations', - 'DeviceManagementOperations', -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file diff --git a/azext_iot/sdk/deviceupdate/dataplane/aio/operations/_device_management_operations.py b/azext_iot/sdk/deviceupdate/dataplane/aio/operations/_device_management_operations.py deleted file mode 100644 index b385708ad..000000000 --- a/azext_iot/sdk/deviceupdate/dataplane/aio/operations/_device_management_operations.py +++ /dev/null @@ -1,3316 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.8.4, generator: @autorest/python@5.19.0) -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.polling.async_base_polling import AsyncLROBasePolling -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._device_management_operations import build_create_or_update_deployment_request, build_delete_deployment_for_device_class_subgroup_request, build_delete_deployment_request, build_delete_device_class_request, build_delete_device_class_subgroup_request, build_delete_group_request, build_get_best_updates_for_device_class_subgroup_request, build_get_deployment_for_device_class_subgroup_request, build_get_deployment_request, build_get_deployment_status_request, build_get_device_class_request, build_get_device_class_subgroup_deployment_status_request, build_get_device_class_subgroup_request, build_get_device_class_subgroup_update_compliance_request, build_get_device_module_request, build_get_device_request, build_get_group_request, build_get_log_collection_detailed_status_request, build_get_log_collection_request, build_get_operation_request, build_get_update_compliance_for_group_request, build_get_update_compliance_request, build_import_devices_request, build_list_best_updates_for_group_request, build_list_deployments_for_device_class_subgroup_request, build_list_deployments_for_group_request, build_list_device_class_subgroups_for_group_request, build_list_device_classes_request, build_list_device_health_request, build_list_device_states_for_device_class_subgroup_deployment_request, build_list_devices_request, build_list_groups_request, build_list_installable_updates_for_device_class_request, build_list_log_collections_request, build_list_operations_request, build_retry_deployment_request, build_start_log_collection_request, build_stop_deployment_request, build_update_device_class_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class DeviceManagementOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~deviceupdateclient.aio.DeviceUpdateClient`'s - :attr:`device_management` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - - @distributed_trace - def list_device_classes( - self, - **kwargs: Any - ) -> AsyncIterable["_models.DeviceClass"]: - """Gets a list of all device classes (unique combinations of device manufacturer and model) for - all devices connected to Device Update for IoT Hub. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeviceClass or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~deviceupdateclient.models.DeviceClass] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceClassesList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_device_classes_request( - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.list_device_classes.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - else: - - request = build_list_device_classes_request( - instance_id=self._config.instance_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DeviceClassesList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_device_classes.metadata = {'url': "/deviceUpdate/{instanceId}/management/deviceClasses"} # type: ignore - - @distributed_trace_async - async def get_device_class( - self, - device_class_id: str, - **kwargs: Any - ) -> _models.DeviceClass: - """Gets the properties of a device class. - - :param device_class_id: Device class identifier. Required. - :type device_class_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeviceClass or the result of cls(response) - :rtype: ~deviceupdateclient.models.DeviceClass - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceClass] - - - request = build_get_device_class_request( - device_class_id=device_class_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.get_device_class.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('DeviceClass', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_device_class.metadata = {'url': "/deviceUpdate/{instanceId}/management/deviceClasses/{deviceClassId}"} # type: ignore - - - @overload - async def update_device_class( - self, - device_class_id: str, - device_class_patch: _models.PatchBody, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _models.DeviceClass: - """Update device class details. - - :param device_class_id: Device class identifier. Required. - :type device_class_id: str - :param device_class_patch: The device class json merge patch body. Currently only supports - patching friendlyName. Required. - :type device_class_patch: ~deviceupdateclient.models.PatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeviceClass or the result of cls(response) - :rtype: ~deviceupdateclient.models.DeviceClass - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update_device_class( - self, - device_class_id: str, - device_class_patch: IO, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _models.DeviceClass: - """Update device class details. - - :param device_class_id: Device class identifier. Required. - :type device_class_id: str - :param device_class_patch: The device class json merge patch body. Currently only supports - patching friendlyName. Required. - :type device_class_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeviceClass or the result of cls(response) - :rtype: ~deviceupdateclient.models.DeviceClass - :raises ~azure.core.exceptions.HttpResponseError: - """ - - - @distributed_trace_async - async def update_device_class( - self, - device_class_id: str, - device_class_patch: Union[_models.PatchBody, IO], - **kwargs: Any - ) -> _models.DeviceClass: - """Update device class details. - - :param device_class_id: Device class identifier. Required. - :type device_class_id: str - :param device_class_patch: The device class json merge patch body. Currently only supports - patching friendlyName. Is either a model type or a IO type. Required. - :type device_class_patch: ~deviceupdateclient.models.PatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: - 'application/merge-patch+json'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeviceClass or the result of cls(response) - :rtype: ~deviceupdateclient.models.DeviceClass - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceClass] - - content_type = content_type or "application/merge-patch+json" - _json = None - _content = None - if isinstance(device_class_patch, (IO, bytes)): - _content = device_class_patch - else: - _json = self._serialize.body(device_class_patch, 'PatchBody') - - request = build_update_device_class_request( - device_class_id=device_class_id, - instance_id=self._config.instance_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update_device_class.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('DeviceClass', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update_device_class.metadata = {'url': "/deviceUpdate/{instanceId}/management/deviceClasses/{deviceClassId}"} # type: ignore - - - @distributed_trace_async - async def delete_device_class( # pylint: disable=inconsistent-return-statements - self, - device_class_id: str, - **kwargs: Any - ) -> None: - """Deletes a device class. Device classes are created automatically when Device Update-enabled - devices are connected to the hub but are not automatically cleaned up since they are referenced - by DeviceClassSubgroups. If the user has deleted all DeviceClassSubgroups for a device class - they can also delete the device class to remove the records from the system and to stop - checking the compatibility of this device class with new updates. If a device is ever - reconnected for this device class it will be re-created. - - :param device_class_id: Device class identifier. Required. - :type device_class_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_device_class_request( - device_class_id=device_class_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.delete_device_class.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete_device_class.metadata = {'url': "/deviceUpdate/{instanceId}/management/deviceClasses/{deviceClassId}"} # type: ignore - - - @distributed_trace - def list_installable_updates_for_device_class( - self, - device_class_id: str, - **kwargs: Any - ) -> AsyncIterable["_models.UpdateInfo"]: - """Gets a list of installable updates for a device class. - - :param device_class_id: Device class identifier. Required. - :type device_class_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UpdateInfo or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~deviceupdateclient.models.UpdateInfo] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateInfoList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_installable_updates_for_device_class_request( - device_class_id=device_class_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.list_installable_updates_for_device_class.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - else: - - request = build_list_installable_updates_for_device_class_request( - device_class_id=device_class_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("UpdateInfoList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_installable_updates_for_device_class.metadata = {'url': "/deviceUpdate/{instanceId}/management/deviceClasses/{deviceClassId}/installableUpdates"} # type: ignore - - @distributed_trace - def list_devices( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.Device"]: - """Gets a list of devices connected to Device Update for IoT Hub. - - :param filter: Restricts the set of devices returned. You can filter on GroupId, DeviceClassId, - or GroupId and DeploymentStatus. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Device or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~deviceupdateclient.models.Device] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DevicesList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_devices_request( - instance_id=self._config.instance_id, - filter=filter, - api_version=api_version, - template_url=self.list_devices.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - else: - - request = build_list_devices_request( - instance_id=self._config.instance_id, - filter=filter, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DevicesList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_devices.metadata = {'url': "/deviceUpdate/{instanceId}/management/devices"} # type: ignore - - async def _import_devices_initial( # pylint: disable=inconsistent-return-statements - self, - import_type: Union[str, "_models.ImportType"], - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - _json = self._serialize.body(import_type, 'str') - - request = build_import_devices_request( - instance_id=self._config.instance_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._import_devices_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) - - - if cls: - return cls(pipeline_response, None, response_headers) - - _import_devices_initial.metadata = {'url': "/deviceUpdate/{instanceId}/management/devices:import"} # type: ignore - - - @distributed_trace_async - async def begin_import_devices( - self, - import_type: Union[str, "_models.ImportType"], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Import existing devices from IoT Hub. This is a long-running-operation; use Operation-Location - response header value to check for operation status. - - :param import_type: The types of devices to import. Known values are: "Devices", "Modules", and - "All". Required. - :type import_type: str or ~deviceupdateclient.models.ImportType - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncLROBasePolling. Pass in False - for this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._import_devices_initial( # type: ignore - import_type=import_type, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncLROBasePolling( - lro_delay, - - path_format_arguments=path_format_arguments, - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_import_devices.metadata = {'url': "/deviceUpdate/{instanceId}/management/devices:import"} # type: ignore - - @distributed_trace_async - async def get_device( - self, - device_id: str, - **kwargs: Any - ) -> _models.Device: - """Gets the device properties and latest deployment status for a device connected to Device Update - for IoT Hub. - - :param device_id: Device identifier in Azure IoT Hub. Required. - :type device_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Device or the result of cls(response) - :rtype: ~deviceupdateclient.models.Device - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Device] - - - request = build_get_device_request( - device_id=device_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.get_device.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('Device', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_device.metadata = {'url': "/deviceUpdate/{instanceId}/management/devices/{deviceId}"} # type: ignore - - - @distributed_trace_async - async def get_device_module( - self, - device_id: str, - module_id: str, - **kwargs: Any - ) -> _models.Device: - """Gets the device module properties and latest deployment status for a device module connected to - Device Update for IoT Hub. - - :param device_id: Device identifier in Azure IoT Hub. Required. - :type device_id: str - :param module_id: Device module identifier in Azure IoT Hub. Required. - :type module_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Device or the result of cls(response) - :rtype: ~deviceupdateclient.models.Device - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Device] - - - request = build_get_device_module_request( - device_id=device_id, - module_id=module_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.get_device_module.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('Device', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_device_module.metadata = {'url': "/deviceUpdate/{instanceId}/management/devices/{deviceId}/modules/{moduleId}"} # type: ignore - - - @distributed_trace_async - async def get_update_compliance( - self, - **kwargs: Any - ) -> _models.UpdateCompliance: - """Gets the breakdown of how many devices are on their latest update, have new updates available, - or are in progress receiving new updates. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateCompliance or the result of cls(response) - :rtype: ~deviceupdateclient.models.UpdateCompliance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateCompliance] - - - request = build_get_update_compliance_request( - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.get_update_compliance.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('UpdateCompliance', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_update_compliance.metadata = {'url': "/deviceUpdate/{instanceId}/management/updateCompliance"} # type: ignore - - - @distributed_trace - def list_groups( - self, - order_by: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.Group"]: - """Gets a list of all device groups. The $default group will always be returned first. - - :param order_by: Orders the set of groups returned. You can order by any combination of - groupId, device count, created date, subgroupsWithNewUpdatesAvailableCount, - subgroupsWithUpdatesInProgressCount, or subgroupsOnLatestUpdateCount. Default value is None. - :type order_by: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Group or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~deviceupdateclient.models.Group] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GroupsList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_groups_request( - instance_id=self._config.instance_id, - order_by=order_by, - api_version=api_version, - template_url=self.list_groups.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - else: - - request = build_list_groups_request( - instance_id=self._config.instance_id, - order_by=order_by, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GroupsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_groups.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups"} # type: ignore - - @distributed_trace_async - async def get_group( - self, - group_id: str, - **kwargs: Any - ) -> _models.Group: - """Gets the device group properties. - - :param group_id: Group identity. Required. - :type group_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Group or the result of cls(response) - :rtype: ~deviceupdateclient.models.Group - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Group] - - - request = build_get_group_request( - group_id=group_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.get_group.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('Group', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_group.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups/{groupId}"} # type: ignore - - - @distributed_trace_async - async def delete_group( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - **kwargs: Any - ) -> None: - """Deletes a device group. This group is automatically created when a Device Update-enabled device - is connected to the hub and reports its properties. Groups, subgroups, and deployments are not - automatically cleaned up but are retained for history purposes. Users can call this method to - delete a group if they do not need to retain any of the history of the group and no longer need - it. If a device is ever connected again for this group after the group was deleted it will be - automatically re-created but there will be no history. - - :param group_id: Group identity. Required. - :type group_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_group_request( - group_id=group_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.delete_group.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete_group.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups/{groupId}"} # type: ignore - - - @distributed_trace_async - async def get_update_compliance_for_group( - self, - group_id: str, - **kwargs: Any - ) -> _models.UpdateCompliance: - """Get device group update compliance information such as how many devices are on their latest - update, how many need new updates, and how many are in progress on receiving a new update. - - :param group_id: Group identity. Required. - :type group_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateCompliance or the result of cls(response) - :rtype: ~deviceupdateclient.models.UpdateCompliance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateCompliance] - - - request = build_get_update_compliance_for_group_request( - group_id=group_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.get_update_compliance_for_group.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('UpdateCompliance', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_update_compliance_for_group.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups/{groupId}/updateCompliance"} # type: ignore - - - @distributed_trace - def list_best_updates_for_group( - self, - group_id: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeviceClassSubgroupUpdatableDevices"]: - """Get the best available updates for a device group and a count of how many devices need each - update. - - :param group_id: Group identity. Required. - :type group_id: str - :param filter: Restricts the set of bestUpdates returned. You can filter on update Provider, - Name and Version property. This filter is deprecated and should not be used. Default value is - None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeviceClassSubgroupUpdatableDevices or the result - of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~deviceupdateclient.models.DeviceClassSubgroupUpdatableDevices] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceClassSubgroupUpdatableDevicesList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_best_updates_for_group_request( - group_id=group_id, - instance_id=self._config.instance_id, - filter=filter, - api_version=api_version, - template_url=self.list_best_updates_for_group.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - else: - - request = build_list_best_updates_for_group_request( - group_id=group_id, - instance_id=self._config.instance_id, - filter=filter, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DeviceClassSubgroupUpdatableDevicesList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_best_updates_for_group.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups/{groupId}/bestUpdates"} # type: ignore - - @distributed_trace - def list_deployments_for_group( - self, - group_id: str, - order_by: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.Deployment"]: - """Gets a list of deployments for a device group. - - :param group_id: Group identity. Required. - :type group_id: str - :param order_by: Orders the set of deployments returned. You can order by start date. Default - value is None. - :type order_by: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Deployment or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~deviceupdateclient.models.Deployment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeploymentsList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_deployments_for_group_request( - group_id=group_id, - instance_id=self._config.instance_id, - order_by=order_by, - api_version=api_version, - template_url=self.list_deployments_for_group.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - else: - - request = build_list_deployments_for_group_request( - group_id=group_id, - instance_id=self._config.instance_id, - order_by=order_by, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DeploymentsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_deployments_for_group.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups/{groupId}/deployments"} # type: ignore - - @distributed_trace_async - async def get_deployment( - self, - group_id: str, - deployment_id: str, - **kwargs: Any - ) -> _models.Deployment: - """Gets the deployment properties. - - :param group_id: Group identity. Required. - :type group_id: str - :param deployment_id: Deployment identifier. Required. - :type deployment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Deployment or the result of cls(response) - :rtype: ~deviceupdateclient.models.Deployment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Deployment] - - - request = build_get_deployment_request( - group_id=group_id, - deployment_id=deployment_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.get_deployment.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('Deployment', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_deployment.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}"} # type: ignore - - - @overload - async def create_or_update_deployment( - self, - group_id: str, - deployment_id: str, - deployment: _models.Deployment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Deployment: - """Creates or updates a deployment. - - :param group_id: Group identity. Required. - :type group_id: str - :param deployment_id: Deployment identifier. Required. - :type deployment_id: str - :param deployment: The deployment properties. Required. - :type deployment: ~deviceupdateclient.models.Deployment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Deployment or the result of cls(response) - :rtype: ~deviceupdateclient.models.Deployment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update_deployment( - self, - group_id: str, - deployment_id: str, - deployment: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Deployment: - """Creates or updates a deployment. - - :param group_id: Group identity. Required. - :type group_id: str - :param deployment_id: Deployment identifier. Required. - :type deployment_id: str - :param deployment: The deployment properties. Required. - :type deployment: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Deployment or the result of cls(response) - :rtype: ~deviceupdateclient.models.Deployment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - - @distributed_trace_async - async def create_or_update_deployment( - self, - group_id: str, - deployment_id: str, - deployment: Union[_models.Deployment, IO], - **kwargs: Any - ) -> _models.Deployment: - """Creates or updates a deployment. - - :param group_id: Group identity. Required. - :type group_id: str - :param deployment_id: Deployment identifier. Required. - :type deployment_id: str - :param deployment: The deployment properties. Is either a model type or a IO type. Required. - :type deployment: ~deviceupdateclient.models.Deployment or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Deployment or the result of cls(response) - :rtype: ~deviceupdateclient.models.Deployment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Deployment] - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(deployment, (IO, bytes)): - _content = deployment - else: - _json = self._serialize.body(deployment, 'Deployment') - - request = build_create_or_update_deployment_request( - group_id=group_id, - deployment_id=deployment_id, - instance_id=self._config.instance_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update_deployment.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('Deployment', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update_deployment.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}"} # type: ignore - - - @distributed_trace_async - async def delete_deployment( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_id: str, - **kwargs: Any - ) -> None: - """Deletes a deployment. - - :param group_id: Group identity. Required. - :type group_id: str - :param deployment_id: Deployment identifier. Required. - :type deployment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_deployment_request( - group_id=group_id, - deployment_id=deployment_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.delete_deployment.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete_deployment.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}"} # type: ignore - - - @distributed_trace_async - async def get_deployment_status( - self, - group_id: str, - deployment_id: str, - **kwargs: Any - ) -> _models.DeploymentStatus: - """Gets the status of a deployment including a breakdown of how many devices in the deployment are - in progress, completed, or failed. - - :param group_id: Group identity. Required. - :type group_id: str - :param deployment_id: Deployment identifier. Required. - :type deployment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentStatus or the result of cls(response) - :rtype: ~deviceupdateclient.models.DeploymentStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeploymentStatus] - - - request = build_get_deployment_status_request( - group_id=group_id, - deployment_id=deployment_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.get_deployment_status.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('DeploymentStatus', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_deployment_status.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}/status"} # type: ignore - - - @distributed_trace - def list_device_class_subgroups_for_group( - self, - group_id: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeviceClassSubgroup"]: - """Get the device class subgroups for the group. - - :param group_id: Group identity. Required. - :type group_id: str - :param filter: Restricts the set of device class subgroups returned. You can filter on compat - properties by name and value. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeviceClassSubgroup or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~deviceupdateclient.models.DeviceClassSubgroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceClassSubgroupsList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_device_class_subgroups_for_group_request( - group_id=group_id, - instance_id=self._config.instance_id, - filter=filter, - api_version=api_version, - template_url=self.list_device_class_subgroups_for_group.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - else: - - request = build_list_device_class_subgroups_for_group_request( - group_id=group_id, - instance_id=self._config.instance_id, - filter=filter, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DeviceClassSubgroupsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_device_class_subgroups_for_group.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups"} # type: ignore - - @distributed_trace_async - async def get_device_class_subgroup( - self, - group_id: str, - device_class_id: str, - **kwargs: Any - ) -> _models.DeviceClassSubgroup: - """Gets device class subgroup details. - - :param group_id: Group identity. Required. - :type group_id: str - :param device_class_id: Device class identifier. Required. - :type device_class_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeviceClassSubgroup or the result of cls(response) - :rtype: ~deviceupdateclient.models.DeviceClassSubgroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceClassSubgroup] - - - request = build_get_device_class_subgroup_request( - group_id=group_id, - device_class_id=device_class_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.get_device_class_subgroup.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('DeviceClassSubgroup', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_device_class_subgroup.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}"} # type: ignore - - - @distributed_trace_async - async def delete_device_class_subgroup( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - device_class_id: str, - **kwargs: Any - ) -> None: - """Deletes a device class subgroup. - - :param group_id: Group identity. Required. - :type group_id: str - :param device_class_id: Device class identifier. Required. - :type device_class_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_device_class_subgroup_request( - group_id=group_id, - device_class_id=device_class_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.delete_device_class_subgroup.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete_device_class_subgroup.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}"} # type: ignore - - - @distributed_trace_async - async def get_device_class_subgroup_update_compliance( - self, - group_id: str, - device_class_id: str, - **kwargs: Any - ) -> _models.UpdateCompliance: - """Get device class subgroup update compliance information such as how many devices are on their - latest update, how many need new updates, and how many are in progress on receiving a new - update. - - :param group_id: Group identity. Required. - :type group_id: str - :param device_class_id: Device class identifier. Required. - :type device_class_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateCompliance or the result of cls(response) - :rtype: ~deviceupdateclient.models.UpdateCompliance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateCompliance] - - - request = build_get_device_class_subgroup_update_compliance_request( - group_id=group_id, - device_class_id=device_class_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.get_device_class_subgroup_update_compliance.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('UpdateCompliance', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_device_class_subgroup_update_compliance.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/updateCompliance"} # type: ignore - - - @distributed_trace_async - async def get_best_updates_for_device_class_subgroup( - self, - group_id: str, - device_class_id: str, - **kwargs: Any - ) -> _models.DeviceClassSubgroupUpdatableDevices: - """Get the best available update for a device class subgroup and a count of how many devices need - this update. - - :param group_id: Group identity. Required. - :type group_id: str - :param device_class_id: Device class identifier. Required. - :type device_class_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeviceClassSubgroupUpdatableDevices or the result of cls(response) - :rtype: ~deviceupdateclient.models.DeviceClassSubgroupUpdatableDevices - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceClassSubgroupUpdatableDevices] - - - request = build_get_best_updates_for_device_class_subgroup_request( - group_id=group_id, - device_class_id=device_class_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.get_best_updates_for_device_class_subgroup.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('DeviceClassSubgroupUpdatableDevices', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_best_updates_for_device_class_subgroup.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/bestUpdates"} # type: ignore - - - @distributed_trace - def list_deployments_for_device_class_subgroup( - self, - group_id: str, - device_class_id: str, - order_by: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.Deployment"]: - """Gets a list of deployments for a device class subgroup. - - :param group_id: Group identity. Required. - :type group_id: str - :param device_class_id: Device class identifier. Required. - :type device_class_id: str - :param order_by: Orders the set of deployments returned. You can order by start date. Default - value is None. - :type order_by: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Deployment or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~deviceupdateclient.models.Deployment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeploymentsList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_deployments_for_device_class_subgroup_request( - group_id=group_id, - device_class_id=device_class_id, - instance_id=self._config.instance_id, - order_by=order_by, - api_version=api_version, - template_url=self.list_deployments_for_device_class_subgroup.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - else: - - request = build_list_deployments_for_device_class_subgroup_request( - group_id=group_id, - device_class_id=device_class_id, - instance_id=self._config.instance_id, - order_by=order_by, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DeploymentsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_deployments_for_device_class_subgroup.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/deployments"} # type: ignore - - @distributed_trace_async - async def get_deployment_for_device_class_subgroup( - self, - group_id: str, - device_class_id: str, - deployment_id: str, - **kwargs: Any - ) -> _models.Deployment: - """Gets the deployment properties. - - :param group_id: Group identity. Required. - :type group_id: str - :param device_class_id: Device class identifier. Required. - :type device_class_id: str - :param deployment_id: Deployment identifier. Required. - :type deployment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Deployment or the result of cls(response) - :rtype: ~deviceupdateclient.models.Deployment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Deployment] - - - request = build_get_deployment_for_device_class_subgroup_request( - group_id=group_id, - device_class_id=device_class_id, - deployment_id=deployment_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.get_deployment_for_device_class_subgroup.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('Deployment', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_deployment_for_device_class_subgroup.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/deployments/{deploymentId}"} # type: ignore - - - @distributed_trace_async - async def delete_deployment_for_device_class_subgroup( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - device_class_id: str, - deployment_id: str, - **kwargs: Any - ) -> None: - """Deletes a device class subgroup deployment. - - :param group_id: Group identity. Required. - :type group_id: str - :param device_class_id: Device class identifier. Required. - :type device_class_id: str - :param deployment_id: Deployment identifier. Required. - :type deployment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_deployment_for_device_class_subgroup_request( - group_id=group_id, - device_class_id=device_class_id, - deployment_id=deployment_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.delete_deployment_for_device_class_subgroup.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete_deployment_for_device_class_subgroup.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/deployments/{deploymentId}"} # type: ignore - - - @distributed_trace_async - async def stop_deployment( - self, - group_id: str, - device_class_id: str, - deployment_id: str, - **kwargs: Any - ) -> _models.Deployment: - """Stops a deployment. - - :param group_id: Group identity. Required. - :type group_id: str - :param device_class_id: Device class identifier. Required. - :type device_class_id: str - :param deployment_id: Deployment identifier. Required. - :type deployment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Deployment or the result of cls(response) - :rtype: ~deviceupdateclient.models.Deployment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Deployment] - - - request = build_stop_deployment_request( - group_id=group_id, - device_class_id=device_class_id, - deployment_id=deployment_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.stop_deployment.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('Deployment', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - stop_deployment.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/deployments/{deploymentId}:cancel"} # type: ignore - - - @distributed_trace_async - async def retry_deployment( - self, - group_id: str, - device_class_id: str, - deployment_id: str, - **kwargs: Any - ) -> _models.Deployment: - """Retries a deployment with failed devices. - - :param group_id: Group identity. Required. - :type group_id: str - :param device_class_id: Device class identifier. Required. - :type device_class_id: str - :param deployment_id: Deployment identifier. Required. - :type deployment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Deployment or the result of cls(response) - :rtype: ~deviceupdateclient.models.Deployment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Deployment] - - - request = build_retry_deployment_request( - group_id=group_id, - device_class_id=device_class_id, - deployment_id=deployment_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.retry_deployment.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('Deployment', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - retry_deployment.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/deployments/{deploymentId}:retry"} # type: ignore - - - @distributed_trace_async - async def get_device_class_subgroup_deployment_status( - self, - group_id: str, - device_class_id: str, - deployment_id: str, - **kwargs: Any - ) -> _models.DeviceClassSubgroupDeploymentStatus: - """Gets the status of a deployment including a breakdown of how many devices in the deployment are - in progress, completed, or failed. - - :param group_id: Group identity. Required. - :type group_id: str - :param device_class_id: Device class identifier. Required. - :type device_class_id: str - :param deployment_id: Deployment identifier. Required. - :type deployment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeviceClassSubgroupDeploymentStatus or the result of cls(response) - :rtype: ~deviceupdateclient.models.DeviceClassSubgroupDeploymentStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceClassSubgroupDeploymentStatus] - - - request = build_get_device_class_subgroup_deployment_status_request( - group_id=group_id, - device_class_id=device_class_id, - deployment_id=deployment_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.get_device_class_subgroup_deployment_status.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('DeviceClassSubgroupDeploymentStatus', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_device_class_subgroup_deployment_status.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/deployments/{deploymentId}/status"} # type: ignore - - - @distributed_trace - def list_device_states_for_device_class_subgroup_deployment( - self, - group_id: str, - device_class_id: str, - deployment_id: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentDeviceState"]: - """Gets a list of devices in a deployment along with their state. Useful for getting a list of - failed devices. - - :param group_id: Group identity. Required. - :type group_id: str - :param device_class_id: Device class identifier. Required. - :type device_class_id: str - :param deployment_id: Deployment identifier. Required. - :type deployment_id: str - :param filter: Restricts the set of deployment device states returned. You can filter on - deviceId and moduleId and/or deviceState. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentDeviceState or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~deviceupdateclient.models.DeploymentDeviceState] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeploymentDeviceStatesList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_device_states_for_device_class_subgroup_deployment_request( - group_id=group_id, - device_class_id=device_class_id, - deployment_id=deployment_id, - instance_id=self._config.instance_id, - filter=filter, - api_version=api_version, - template_url=self.list_device_states_for_device_class_subgroup_deployment.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - else: - - request = build_list_device_states_for_device_class_subgroup_deployment_request( - group_id=group_id, - device_class_id=device_class_id, - deployment_id=deployment_id, - instance_id=self._config.instance_id, - filter=filter, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DeploymentDeviceStatesList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_device_states_for_device_class_subgroup_deployment.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/deployments/{deploymentId}/devicestates"} # type: ignore - - @distributed_trace_async - async def get_operation( - self, - operation_id: str, - access_condition: Optional[_models.AccessCondition] = None, - **kwargs: Any - ) -> Optional[_models.DeviceOperation]: - """Retrieve operation status. - - :param operation_id: Operation identifier. Required. - :type operation_id: str - :param access_condition: Parameter group. Default value is None. - :type access_condition: ~deviceupdateclient.models.AccessCondition - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeviceOperation or None or the result of cls(response) - :rtype: ~deviceupdateclient.models.DeviceOperation or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.DeviceOperation]] - - _if_none_match = None - if access_condition is not None: - _if_none_match = access_condition.if_none_match - - request = build_get_operation_request( - operation_id=operation_id, - instance_id=self._config.instance_id, - if_none_match=_if_none_match, - api_version=api_version, - template_url=self.get_operation.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 304]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = None - response_headers = {} - if response.status_code == 200: - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - - deserialized = self._deserialize('DeviceOperation', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - get_operation.metadata = {'url': "/deviceUpdate/{instanceId}/management/operations/{operationId}"} # type: ignore - - - @distributed_trace - def list_operations( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeviceOperation"]: - """Get a list of all device import operations. Completed operations are kept for 7 days before - auto-deleted. - - :param filter: Restricts the set of operations returned. Only one specific filter is supported: - "status eq 'NotStarted' or status eq 'Running'". Default value is None. - :type filter: str - :param top: Specifies a non-negative integer n that limits the number of items returned from a - collection. The service returns the number of available items up to but not greater than the - specified value n. Default value is None. - :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeviceOperation or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~deviceupdateclient.models.DeviceOperation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceOperationsList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_operations_request( - instance_id=self._config.instance_id, - filter=filter, - top=top, - api_version=api_version, - template_url=self.list_operations.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - else: - - request = build_list_operations_request( - instance_id=self._config.instance_id, - filter=filter, - top=top, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DeviceOperationsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_operations.metadata = {'url': "/deviceUpdate/{instanceId}/management/operations"} # type: ignore - - @overload - async def start_log_collection( - self, - log_collection_id: str, - log_collection: _models.LogCollection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.LogCollection: - """Start the device diagnostics log collection on specified devices. - - :param log_collection_id: Log collection identifier. Required. - :type log_collection_id: str - :param log_collection: The log collection properties. Required. - :type log_collection: ~deviceupdateclient.models.LogCollection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogCollection or the result of cls(response) - :rtype: ~deviceupdateclient.models.LogCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def start_log_collection( - self, - log_collection_id: str, - log_collection: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.LogCollection: - """Start the device diagnostics log collection on specified devices. - - :param log_collection_id: Log collection identifier. Required. - :type log_collection_id: str - :param log_collection: The log collection properties. Required. - :type log_collection: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogCollection or the result of cls(response) - :rtype: ~deviceupdateclient.models.LogCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - - @distributed_trace_async - async def start_log_collection( - self, - log_collection_id: str, - log_collection: Union[_models.LogCollection, IO], - **kwargs: Any - ) -> _models.LogCollection: - """Start the device diagnostics log collection on specified devices. - - :param log_collection_id: Log collection identifier. Required. - :type log_collection_id: str - :param log_collection: The log collection properties. Is either a model type or a IO type. - Required. - :type log_collection: ~deviceupdateclient.models.LogCollection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogCollection or the result of cls(response) - :rtype: ~deviceupdateclient.models.LogCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LogCollection] - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(log_collection, (IO, bytes)): - _content = log_collection - else: - _json = self._serialize.body(log_collection, 'LogCollection') - - request = build_start_log_collection_request( - log_collection_id=log_collection_id, - instance_id=self._config.instance_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.start_log_collection.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('LogCollection', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - start_log_collection.metadata = {'url': "/deviceUpdate/{instanceId}/management/deviceDiagnostics/logCollections/{operationId}"} # type: ignore - - - @distributed_trace_async - async def get_log_collection( - self, - log_collection_id: str, - **kwargs: Any - ) -> _models.LogCollection: - """Get the device diagnostics log collection. - - :param log_collection_id: Log collection identifier. Required. - :type log_collection_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogCollection or the result of cls(response) - :rtype: ~deviceupdateclient.models.LogCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LogCollection] - - - request = build_get_log_collection_request( - log_collection_id=log_collection_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.get_log_collection.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('LogCollection', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_log_collection.metadata = {'url': "/deviceUpdate/{instanceId}/management/deviceDiagnostics/logCollections/{operationId}"} # type: ignore - - - @distributed_trace - def list_log_collections( - self, - **kwargs: Any - ) -> AsyncIterable["_models.LogCollection"]: - """Get all device diagnostics log collections. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~deviceupdateclient.models.LogCollection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LogCollectionList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_log_collections_request( - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.list_log_collections.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - else: - - request = build_list_log_collections_request( - instance_id=self._config.instance_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("LogCollectionList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_log_collections.metadata = {'url': "/deviceUpdate/{instanceId}/management/deviceDiagnostics/logCollections"} # type: ignore - - @distributed_trace_async - async def get_log_collection_detailed_status( - self, - operation_id: str, - **kwargs: Any - ) -> _models.LogCollectionOperationDetailedStatus: - """Get log collection with detailed status. - - :param operation_id: Operation identifier. Required. - :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogCollectionOperationDetailedStatus or the result of cls(response) - :rtype: ~deviceupdateclient.models.LogCollectionOperationDetailedStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LogCollectionOperationDetailedStatus] - - - request = build_get_log_collection_detailed_status_request( - operation_id=operation_id, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.get_log_collection_detailed_status.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('LogCollectionOperationDetailedStatus', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_log_collection_detailed_status.metadata = {'url': "/deviceUpdate/{instanceId}/management/deviceDiagnostics/logCollections/{operationId}/detailedStatus"} # type: ignore - - - @distributed_trace - def list_device_health( - self, - filter: str, - **kwargs: Any - ) -> AsyncIterable["_models.DeviceHealth"]: - """Get list of device health. - - :param filter: Filter list by specified properties. Required. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeviceHealth or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~deviceupdateclient.models.DeviceHealth] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceHealthList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_device_health_request( - instance_id=self._config.instance_id, - filter=filter, - api_version=api_version, - template_url=self.list_device_health.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - else: - - request = build_list_device_health_request( - instance_id=self._config.instance_id, - filter=filter, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DeviceHealthList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_device_health.metadata = {'url': "/deviceUpdate/{instanceId}/management/deviceDiagnostics/deviceHealth"} # type: ignore diff --git a/azext_iot/sdk/deviceupdate/dataplane/aio/operations/_device_update_operations.py b/azext_iot/sdk/deviceupdate/dataplane/aio/operations/_device_update_operations.py deleted file mode 100644 index 697c86ff4..000000000 --- a/azext_iot/sdk/deviceupdate/dataplane/aio/operations/_device_update_operations.py +++ /dev/null @@ -1,1222 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.8.4, generator: @autorest/python@5.19.0) -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.polling.async_base_polling import AsyncLROBasePolling -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._device_update_operations import build_delete_update_request, build_get_file_request, build_get_operation_request, build_get_update_request, build_import_update_request, build_list_files_request, build_list_names_request, build_list_operations_request, build_list_providers_request, build_list_updates_request, build_list_versions_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class DeviceUpdateOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~deviceupdateclient.aio.DeviceUpdateClient`'s - :attr:`device_update` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - - @distributed_trace - def list_updates( - self, - search: Optional[str] = None, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.Update"]: - """Get a list of all updates that have been imported to Device Update for IoT Hub. - - :param search: Request updates matching a free-text search expression. Default value is None. - :type search: str - :param filter: Filter updates by its properties. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Update or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~deviceupdateclient.models.Update] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_updates_request( - instance_id=self._config.instance_id, - search=search, - filter=filter, - api_version=api_version, - template_url=self.list_updates.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - else: - - request = build_list_updates_request( - instance_id=self._config.instance_id, - search=search, - filter=filter, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("UpdateList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_updates.metadata = {'url': "/deviceUpdate/{instanceId}/updates"} # type: ignore - - async def _import_update_initial( # pylint: disable=inconsistent-return-statements - self, - update_to_import: Union[List[_models.ImportUpdateInputItem], IO], - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(update_to_import, (IO, bytes)): - _content = update_to_import - else: - _json = self._serialize.body(update_to_import, '[ImportUpdateInputItem]') - - request = build_import_update_request( - instance_id=self._config.instance_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._import_update_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) - - - if cls: - return cls(pipeline_response, None, response_headers) - - _import_update_initial.metadata = {'url': "/deviceUpdate/{instanceId}/updates:import"} # type: ignore - - - @overload - async def begin_import_update( - self, - update_to_import: List[_models.ImportUpdateInputItem], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Import new update version. This is a long-running-operation; use Operation-Location response - header value to check for operation status. - - :param update_to_import: The update to be imported. Required. - :type update_to_import: list[~deviceupdateclient.models.ImportUpdateInputItem] - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncLROBasePolling. Pass in False - for this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_import_update( - self, - update_to_import: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Import new update version. This is a long-running-operation; use Operation-Location response - header value to check for operation status. - - :param update_to_import: The update to be imported. Required. - :type update_to_import: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncLROBasePolling. Pass in False - for this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - - @distributed_trace_async - async def begin_import_update( - self, - update_to_import: Union[List[_models.ImportUpdateInputItem], IO], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Import new update version. This is a long-running-operation; use Operation-Location response - header value to check for operation status. - - :param update_to_import: The update to be imported. Is either a list type or a IO type. - Required. - :type update_to_import: list[~deviceupdateclient.models.ImportUpdateInputItem] or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncLROBasePolling. Pass in False - for this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._import_update_initial( # type: ignore - update_to_import=update_to_import, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncLROBasePolling( - lro_delay, - - path_format_arguments=path_format_arguments, - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_import_update.metadata = {'url': "/deviceUpdate/{instanceId}/updates:import"} # type: ignore - - @distributed_trace_async - async def get_update( - self, - provider: str, - name: str, - version: str, - access_condition: Optional[_models.AccessCondition] = None, - **kwargs: Any - ) -> Optional[_models.Update]: - """Get a specific update version. - - :param provider: Update provider. Required. - :type provider: str - :param name: Update name. Required. - :type name: str - :param version: Update version. Required. - :type version: str - :param access_condition: Parameter group. Default value is None. - :type access_condition: ~deviceupdateclient.models.AccessCondition - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Update or None or the result of cls(response) - :rtype: ~deviceupdateclient.models.Update or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Update]] - - _if_none_match = None - if access_condition is not None: - _if_none_match = access_condition.if_none_match - - request = build_get_update_request( - provider=provider, - name=name, - version=version, - instance_id=self._config.instance_id, - if_none_match=_if_none_match, - api_version=api_version, - template_url=self.get_update.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 304]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Update', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_update.metadata = {'url': "/deviceUpdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}"} # type: ignore - - - async def _delete_update_initial( # pylint: disable=inconsistent-return-statements - self, - provider: str, - name: str, - version: str, - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_update_request( - provider=provider, - name=name, - version=version, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self._delete_update_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) - - - if cls: - return cls(pipeline_response, None, response_headers) - - _delete_update_initial.metadata = {'url': "/deviceUpdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}"} # type: ignore - - - @distributed_trace_async - async def begin_delete_update( - self, - provider: str, - name: str, - version: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete a specific update version. This is a long-running-operation; use Operation-Location - response header value to check for operation status. - - :param provider: Update provider. Required. - :type provider: str - :param name: Update name. Required. - :type name: str - :param version: Update version. Required. - :type version: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncLROBasePolling. Pass in False - for this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_update_initial( # type: ignore - provider=provider, - name=name, - version=version, - api_version=api_version, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncLROBasePolling( - lro_delay, - - path_format_arguments=path_format_arguments, - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_update.metadata = {'url': "/deviceUpdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}"} # type: ignore - - @distributed_trace - def list_providers( - self, - **kwargs: Any - ) -> AsyncIterable[str]: - """Get a list of all update providers that have been imported to Device Update for IoT Hub. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either str or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[str] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StringsList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_providers_request( - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.list_providers.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - else: - - request = build_list_providers_request( - instance_id=self._config.instance_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("StringsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_providers.metadata = {'url': "/deviceUpdate/{instanceId}/updates/providers"} # type: ignore - - @distributed_trace - def list_names( - self, - provider: str, - **kwargs: Any - ) -> AsyncIterable[str]: - """Get a list of all update names that match the specified provider. - - :param provider: Update provider. Required. - :type provider: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either str or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[str] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StringsList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_names_request( - provider=provider, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.list_names.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - else: - - request = build_list_names_request( - provider=provider, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("StringsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_names.metadata = {'url': "/deviceUpdate/{instanceId}/updates/providers/{provider}/names"} # type: ignore - - @distributed_trace - def list_versions( - self, - provider: str, - name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable[str]: - """Get a list of all update versions that match the specified provider and name. - - :param provider: Update provider. Required. - :type provider: str - :param name: Update name. Required. - :type name: str - :param filter: Filter updates by its properties. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either str or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[str] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StringsList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_versions_request( - provider=provider, - name=name, - instance_id=self._config.instance_id, - filter=filter, - api_version=api_version, - template_url=self.list_versions.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - else: - - request = build_list_versions_request( - provider=provider, - name=name, - instance_id=self._config.instance_id, - filter=filter, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("StringsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_versions.metadata = {'url': "/deviceUpdate/{instanceId}/updates/providers/{provider}/names/{name}/versions"} # type: ignore - - @distributed_trace - def list_files( - self, - provider: str, - name: str, - version: str, - **kwargs: Any - ) -> AsyncIterable[str]: - """Get a list of all update file identifiers for the specified version. - - :param provider: Update provider. Required. - :type provider: str - :param name: Update name. Required. - :type name: str - :param version: Update version. Required. - :type version: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either str or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[str] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StringsList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_files_request( - provider=provider, - name=name, - version=version, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=self.list_files.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - else: - - request = build_list_files_request( - provider=provider, - name=name, - version=version, - instance_id=self._config.instance_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("StringsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_files.metadata = {'url': "/deviceUpdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}/files"} # type: ignore - - @distributed_trace_async - async def get_file( - self, - provider: str, - name: str, - version: str, - file_id: str, - access_condition: Optional[_models.AccessCondition] = None, - **kwargs: Any - ) -> Optional[_models.UpdateFile]: - """Get a specific update file from the version. - - :param provider: Update provider. Required. - :type provider: str - :param name: Update name. Required. - :type name: str - :param version: Update version. Required. - :type version: str - :param file_id: File identifier. Required. - :type file_id: str - :param access_condition: Parameter group. Default value is None. - :type access_condition: ~deviceupdateclient.models.AccessCondition - :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateFile or None or the result of cls(response) - :rtype: ~deviceupdateclient.models.UpdateFile or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.UpdateFile]] - - _if_none_match = None - if access_condition is not None: - _if_none_match = access_condition.if_none_match - - request = build_get_file_request( - provider=provider, - name=name, - version=version, - file_id=file_id, - instance_id=self._config.instance_id, - if_none_match=_if_none_match, - api_version=api_version, - template_url=self.get_file.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 304]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('UpdateFile', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_file.metadata = {'url': "/deviceUpdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}/files/{fileId}"} # type: ignore - - - @distributed_trace - def list_operations( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.UpdateOperation"]: - """Get a list of all import update operations. Completed operations are kept for 7 days before - auto-deleted. Delete operations are not returned by this API version. - - :param filter: Restricts the set of operations returned. Only one specific filter is supported: - "status eq 'NotStarted' or status eq 'Running'". Default value is None. - :type filter: str - :param top: Specifies a non-negative integer n that limits the number of items returned from a - collection. The service returns the number of available items up to but not greater than the - specified value n. Default value is None. - :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UpdateOperation or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~deviceupdateclient.models.UpdateOperation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateOperationsList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_operations_request( - instance_id=self._config.instance_id, - filter=filter, - top=top, - api_version=api_version, - template_url=self.list_operations.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - else: - - request = build_list_operations_request( - instance_id=self._config.instance_id, - filter=filter, - top=top, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("UpdateOperationsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_operations.metadata = {'url': "/deviceUpdate/{instanceId}/updates/operations"} # type: ignore - - @distributed_trace_async - async def get_operation( - self, - operation_id: str, - access_condition: Optional[_models.AccessCondition] = None, - **kwargs: Any - ) -> Optional[_models.UpdateOperation]: - """Retrieve operation status. - - :param operation_id: Operation identifier. Required. - :type operation_id: str - :param access_condition: Parameter group. Default value is None. - :type access_condition: ~deviceupdateclient.models.AccessCondition - :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateOperation or None or the result of cls(response) - :rtype: ~deviceupdateclient.models.UpdateOperation or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.UpdateOperation]] - - _if_none_match = None - if access_condition is not None: - _if_none_match = access_condition.if_none_match - - request = build_get_operation_request( - operation_id=operation_id, - instance_id=self._config.instance_id, - if_none_match=_if_none_match, - api_version=api_version, - template_url=self.get_operation.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 304]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error) - - deserialized = None - response_headers = {} - if response.status_code == 200: - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - - deserialized = self._deserialize('UpdateOperation', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - get_operation.metadata = {'url': "/deviceUpdate/{instanceId}/updates/operations/{operationId}"} # type: ignore - diff --git a/azext_iot/sdk/deviceupdate/dataplane/aio/operations/_patch.py b/azext_iot/sdk/deviceupdate/dataplane/aio/operations/_patch.py deleted file mode 100644 index 0ad201a8c..000000000 --- a/azext_iot/sdk/deviceupdate/dataplane/aio/operations/_patch.py +++ /dev/null @@ -1,19 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/azext_iot/sdk/deviceupdate/dataplane/models/__init__.py b/azext_iot/sdk/deviceupdate/dataplane/models/__init__.py index dddbb5a82..bbed074cd 100644 --- a/azext_iot/sdk/deviceupdate/dataplane/models/__init__.py +++ b/azext_iot/sdk/deviceupdate/dataplane/models/__init__.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.8.4, generator: @autorest/python@5.19.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.2, generator: @autorest/python@5.19.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -17,6 +17,7 @@ from ._models_py3 import DeploymentsList from ._models_py3 import Device from ._models_py3 import DeviceClass +from ._models_py3 import DeviceClassFilter from ._models_py3 import DeviceClassProperties from ._models_py3 import DeviceClassSubgroup from ._models_py3 import DeviceClassSubgroupDeploymentStatus @@ -73,7 +74,6 @@ from ._device_update_client_enums import DeviceClassSubgroupDeploymentState from ._device_update_client_enums import DeviceDeploymentState from ._device_update_client_enums import DeviceHealthState -from ._device_update_client_enums import DeviceState from ._device_update_client_enums import GroupType from ._device_update_client_enums import HealthCheckResult from ._device_update_client_enums import ImportType @@ -97,6 +97,7 @@ 'DeploymentsList', 'Device', 'DeviceClass', + 'DeviceClassFilter', 'DeviceClassProperties', 'DeviceClassSubgroup', 'DeviceClassSubgroupDeploymentStatus', @@ -151,7 +152,6 @@ 'DeviceClassSubgroupDeploymentState', 'DeviceDeploymentState', 'DeviceHealthState', - 'DeviceState', 'GroupType', 'HealthCheckResult', 'ImportType', diff --git a/azext_iot/sdk/deviceupdate/dataplane/models/_device_update_client_enums.py b/azext_iot/sdk/deviceupdate/dataplane/models/_device_update_client_enums.py index 8ec5ed0b3..bd90f927d 100644 --- a/azext_iot/sdk/deviceupdate/dataplane/models/_device_update_client_enums.py +++ b/azext_iot/sdk/deviceupdate/dataplane/models/_device_update_client_enums.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.8.4, generator: @autorest/python@5.19.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.2, generator: @autorest/python@5.19.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -62,25 +62,6 @@ class DeviceHealthState(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: Agent is in an unhealthy state UNHEALTHY = "unhealthy" -class DeviceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The deployment device state. - """ - - #: Not started (or uninitialized) - NOT_STARTED = "NotStarted" - #: Deployment incompatible for this device. - INCOMPATIBLE = "Incompatible" - #: Another Deployment is underway for this device. - ALREADY_IN_DEPLOYMENT = "AlreadyInDeployment" - #: Deployment has been canceled for this device. - CANCELED = "Canceled" - #: Deployment underway. - IN_PROGRESS = "InProgress" - #: Deployment failed. - FAILED = "Failed" - #: Deployment completed successfully. - SUCCEEDED = "Succeeded" - class GroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Supported group types. """ diff --git a/azext_iot/sdk/deviceupdate/dataplane/models/_models_py3.py b/azext_iot/sdk/deviceupdate/dataplane/models/_models_py3.py index 05d23318d..9f9a13070 100644 --- a/azext_iot/sdk/deviceupdate/dataplane/models/_models_py3.py +++ b/azext_iot/sdk/deviceupdate/dataplane/models/_models_py3.py @@ -1,7 +1,7 @@ # coding=utf-8 # pylint: disable=too-many-lines # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.8.4, generator: @autorest/python@5.19.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.2, generator: @autorest/python@5.19.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -174,7 +174,10 @@ class Deployment(_serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar deployment_id: The caller-provided deployment identifier. Required. + :ivar deployment_id: The caller-provided deployment identifier. This cannot be longer than 73 + characters, must be all lower-case, and cannot contain '&', '^', '[', ']', '{', '}', '|', '<', + '>', forward slash, backslash, or double quote. The Updates view in the Azure Portal IoT Hub + resource generates a GUID for deploymentId when you create a deployment. Required. :vartype deployment_id: str :ivar start_date_time: The deployment start datetime. Required. :vartype start_date_time: ~datetime.datetime @@ -232,7 +235,10 @@ def __init__( **kwargs ): """ - :keyword deployment_id: The caller-provided deployment identifier. Required. + :keyword deployment_id: The caller-provided deployment identifier. This cannot be longer than + 73 characters, must be all lower-case, and cannot contain '&', '^', '[', ']', '{', '}', '|', + '<', '>', forward slash, backslash, or double quote. The Updates view in the Azure Portal IoT + Hub resource generates a GUID for deploymentId when you create a deployment. Required. :paramtype deployment_id: str :keyword start_date_time: The deployment start datetime. Required. :paramtype start_date_time: ~datetime.datetime @@ -342,9 +348,9 @@ class DeploymentDeviceStatesFilter(_serialization.Model): :vartype device_id: str :ivar module_id: Device module Identifier. :vartype module_id: str - :ivar device_state: The deployment device state. Known values are: "NotStarted", - "Incompatible", "AlreadyInDeployment", "Canceled", "InProgress", "Failed", and "Succeeded". - :vartype device_state: str or ~deviceupdateclient.models.DeviceState + :ivar device_state: The deployment device state. Known values are: "Succeeded", "InProgress", + "Canceled", and "Failed". + :vartype device_state: str or ~deviceupdateclient.models.DeviceDeploymentState """ _attribute_map = { @@ -358,7 +364,7 @@ def __init__( *, device_id: Optional[str] = None, module_id: Optional[str] = None, - device_state: Optional[Union[str, "_models.DeviceState"]] = None, + device_state: Optional[Union[str, "_models.DeviceDeploymentState"]] = None, **kwargs ): """ @@ -366,9 +372,9 @@ def __init__( :paramtype device_id: str :keyword module_id: Device module Identifier. :paramtype module_id: str - :keyword device_state: The deployment device state. Known values are: "NotStarted", - "Incompatible", "AlreadyInDeployment", "Canceled", "InProgress", "Failed", and "Succeeded". - :paramtype device_state: str or ~deviceupdateclient.models.DeviceState + :keyword device_state: The deployment device state. Known values are: "Succeeded", + "InProgress", "Canceled", and "Failed". + :paramtype device_state: str or ~deviceupdateclient.models.DeviceDeploymentState """ super().__init__(**kwargs) self.device_id = device_id @@ -556,8 +562,8 @@ class Device(_serialization.Model): :vartype deployment_status: str or ~deviceupdateclient.models.DeviceDeploymentState :ivar installed_update: Currently installed update on device. :vartype installed_update: ~deviceupdateclient.models.UpdateInfo - :ivar on_latest_update: Boolean flag indicating whether the latest update is installed on the - device. Required. + :ivar on_latest_update: Boolean flag indicating whether the latest update (the best compatible + update for the device's device class and group) is installed on the device. Required. :vartype on_latest_update: bool :ivar last_deployment_id: The deployment identifier for the last deployment to the device. :vartype last_deployment_id: str @@ -615,8 +621,9 @@ def __init__( :paramtype deployment_status: str or ~deviceupdateclient.models.DeviceDeploymentState :keyword installed_update: Currently installed update on device. :paramtype installed_update: ~deviceupdateclient.models.UpdateInfo - :keyword on_latest_update: Boolean flag indicating whether the latest update is installed on - the device. Required. + :keyword on_latest_update: Boolean flag indicating whether the latest update (the best + compatible update for the device's device class and group) is installed on the device. + Required. :paramtype on_latest_update: bool :keyword last_deployment_id: The deployment identifier for the last deployment to the device. :paramtype last_deployment_id: str @@ -641,7 +648,9 @@ class DeviceClass(_serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar device_class_id: The device class identifier. Required. + :ivar device_class_id: The device class identifier. This is generated from the model Id and the + compat properties reported by the device update agent in the Device Update PnP interface in IoT + Hub. It is a hex-encoded SHA1 hash. Required. :vartype device_class_id: str :ivar friendly_name: The device class friendly name. This can be updated by callers after the device class has been automatically created. @@ -649,7 +658,8 @@ class DeviceClass(_serialization.Model): :ivar device_class_properties: The device class properties that are used to calculate the device class Id. Required. :vartype device_class_properties: ~deviceupdateclient.models.DeviceClassProperties - :ivar best_compatible_update: Update that is best compatible with this device class. + :ivar best_compatible_update: Update that is the highest version compatible with this device + class. :vartype best_compatible_update: ~deviceupdateclient.models.UpdateInfo """ @@ -675,7 +685,9 @@ def __init__( **kwargs ): """ - :keyword device_class_id: The device class identifier. Required. + :keyword device_class_id: The device class identifier. This is generated from the model Id and + the compat properties reported by the device update agent in the Device Update PnP interface in + IoT Hub. It is a hex-encoded SHA1 hash. Required. :paramtype device_class_id: str :keyword friendly_name: The device class friendly name. This can be updated by callers after the device class has been automatically created. @@ -683,7 +695,8 @@ def __init__( :keyword device_class_properties: The device class properties that are used to calculate the device class Id. Required. :paramtype device_class_properties: ~deviceupdateclient.models.DeviceClassProperties - :keyword best_compatible_update: Update that is best compatible with this device class. + :keyword best_compatible_update: Update that is the highest version compatible with this device + class. :paramtype best_compatible_update: ~deviceupdateclient.models.UpdateInfo """ super().__init__(**kwargs) @@ -731,6 +744,31 @@ def __init__( self.next_link = next_link +class DeviceClassFilter(_serialization.Model): + """Device class filter. Filters device classes based on device class friendly name. + + :ivar friendly_name: The friendly name of the device class to use in the filter. + :vartype friendly_name: str + """ + + _attribute_map = { + "friendly_name": {"key": "friendlyName", "type": "str"}, + } + + def __init__( + self, + *, + friendly_name: Optional[str] = None, + **kwargs + ): + """ + :keyword friendly_name: The friendly name of the device class to use in the filter. + :paramtype friendly_name: str + """ + super().__init__(**kwargs) + self.friendly_name = friendly_name + + class DeviceClassProperties(_serialization.Model): """The device class properties that are used to calculate the device class Id. @@ -780,7 +818,9 @@ class DeviceClassSubgroup(_serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar device_class_id: Device class subgroup identity. Required. + :ivar device_class_id: Device class subgroup identity. This is generated from the model Id and + the compat properties reported by the device update agent in the Device Update PnP interface in + IoT Hub. It is a hex-encoded SHA1 hash. Required. :vartype device_class_id: str :ivar group_id: Group identity. Required. :vartype group_id: str @@ -817,7 +857,9 @@ def __init__( **kwargs ): """ - :keyword device_class_id: Device class subgroup identity. Required. + :keyword device_class_id: Device class subgroup identity. This is generated from the model Id + and the compat properties reported by the device update agent in the Device Update PnP + interface in IoT Hub. It is a hex-encoded SHA1 hash. Required. :paramtype device_class_id: str :keyword group_id: Group identity. Required. :paramtype group_id: str @@ -1626,7 +1668,8 @@ class Group(_serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar group_id: Group identity. Required. + :ivar group_id: Group identity. This is created from the value of the ADUGroup tag in the Iot + Hub's device/module twin or $default for devices with no tag. Required. :vartype group_id: str :ivar group_type: Group type. Required. Known values are: "IoTHubTag" and "DefaultNoTag". :vartype group_type: str or ~deviceupdateclient.models.GroupType @@ -1678,7 +1721,8 @@ def __init__( **kwargs ): """ - :keyword group_id: Group identity. Required. + :keyword group_id: Group identity. This is created from the value of the ADUGroup tag in the + Iot Hub's device/module twin or $default for devices with no tag. Required. :paramtype group_id: str :keyword group_type: Group type. Required. Known values are: "IoTHubTag" and "DefaultNoTag". :paramtype group_type: str or ~deviceupdateclient.models.GroupType @@ -2390,7 +2434,8 @@ class PatchBody(_serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar friendly_name: The device class friendly name. Required. + :ivar friendly_name: The device class friendly name. Friendly name can be 1-100 characters, + alphanumeric, dot, and dash. Required. :vartype friendly_name: str """ @@ -2409,7 +2454,8 @@ def __init__( **kwargs ): """ - :keyword friendly_name: The device class friendly name. Required. + :keyword friendly_name: The device class friendly name. Friendly name can be 1-100 characters, + alphanumeric, dot, and dash. Required. :paramtype friendly_name: str """ super().__init__(**kwargs) diff --git a/azext_iot/sdk/deviceupdate/dataplane/operations/__init__.py b/azext_iot/sdk/deviceupdate/dataplane/operations/__init__.py index 0e1dc7820..6bfcb0899 100644 --- a/azext_iot/sdk/deviceupdate/dataplane/operations/__init__.py +++ b/azext_iot/sdk/deviceupdate/dataplane/operations/__init__.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.8.4, generator: @autorest/python@5.19.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.2, generator: @autorest/python@5.19.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/azext_iot/sdk/deviceupdate/dataplane/operations/_device_management_operations.py b/azext_iot/sdk/deviceupdate/dataplane/operations/_device_management_operations.py index 717c733aa..789422075 100644 --- a/azext_iot/sdk/deviceupdate/dataplane/operations/_device_management_operations.py +++ b/azext_iot/sdk/deviceupdate/dataplane/operations/_device_management_operations.py @@ -1,7 +1,7 @@ # pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.8.4, generator: @autorest/python@5.19.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.2, generator: @autorest/python@5.19.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload @@ -27,12 +27,14 @@ def build_list_device_classes_request( instance_id: str, + *, + filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -45,6 +47,8 @@ def build_list_device_classes_request( # Construct parameters _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _params['filter'] = _SERIALIZER.query("filter", filter, 'str') # Construct headers _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') @@ -66,7 +70,7 @@ def build_get_device_class_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -101,7 +105,7 @@ def build_update_device_class_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] accept = _headers.pop('Accept', "application/json") @@ -139,7 +143,7 @@ def build_delete_device_class_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -174,7 +178,7 @@ def build_list_installable_updates_for_device_class_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -210,7 +214,7 @@ def build_list_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -247,7 +251,7 @@ def build_import_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] accept = _headers.pop('Accept', "application/json") @@ -285,7 +289,7 @@ def build_get_device_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -321,7 +325,7 @@ def build_get_device_module_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -356,7 +360,7 @@ def build_get_update_compliance_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -391,7 +395,7 @@ def build_list_groups_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -427,7 +431,7 @@ def build_get_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -462,7 +466,7 @@ def build_delete_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -497,7 +501,7 @@ def build_get_update_compliance_for_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -527,14 +531,12 @@ def build_get_update_compliance_for_group_request( def build_list_best_updates_for_group_request( group_id: str, instance_id: str, - *, - filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -547,8 +549,6 @@ def build_list_best_updates_for_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - if filter is not None: - _params['filter'] = _SERIALIZER.query("filter", filter, 'str') _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers @@ -573,7 +573,7 @@ def build_list_deployments_for_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -611,7 +611,7 @@ def build_get_deployment_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -648,7 +648,7 @@ def build_create_or_update_deployment_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] accept = _headers.pop('Accept', "application/json") @@ -688,7 +688,7 @@ def build_delete_deployment_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -725,7 +725,7 @@ def build_get_deployment_status_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -763,7 +763,7 @@ def build_list_device_class_subgroups_for_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -801,7 +801,7 @@ def build_get_device_class_subgroup_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -838,7 +838,7 @@ def build_delete_device_class_subgroup_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -875,7 +875,7 @@ def build_get_device_class_subgroup_update_compliance_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -912,7 +912,7 @@ def build_get_best_updates_for_device_class_subgroup_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -951,7 +951,7 @@ def build_list_deployments_for_device_class_subgroup_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -991,7 +991,7 @@ def build_get_deployment_for_device_class_subgroup_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -1030,7 +1030,7 @@ def build_delete_deployment_for_device_class_subgroup_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -1069,7 +1069,7 @@ def build_stop_deployment_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -1108,7 +1108,7 @@ def build_retry_deployment_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -1147,7 +1147,7 @@ def build_get_device_class_subgroup_deployment_status_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -1188,7 +1188,7 @@ def build_list_device_states_for_device_class_subgroup_deployment_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -1219,7 +1219,7 @@ def build_list_device_states_for_device_class_subgroup_deployment_request( ) -def build_get_operation_request( +def build_get_operation_status_request( operation_id: str, instance_id: str, *, @@ -1229,7 +1229,7 @@ def build_get_operation_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -1258,7 +1258,7 @@ def build_get_operation_request( ) -def build_list_operations_request( +def build_list_operation_statuses_request( instance_id: str, *, filter: Optional[str] = None, @@ -1268,7 +1268,7 @@ def build_list_operations_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -1306,7 +1306,7 @@ def build_start_log_collection_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] accept = _headers.pop('Accept', "application/json") @@ -1344,7 +1344,7 @@ def build_get_log_collection_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -1378,7 +1378,7 @@ def build_list_log_collections_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -1405,21 +1405,21 @@ def build_list_log_collections_request( def build_get_log_collection_detailed_status_request( - operation_id: str, + log_collection_id: str, instance_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL _url = kwargs.pop("template_url", "/deviceUpdate/{instanceId}/management/deviceDiagnostics/logCollections/{operationId}/detailedStatus") # pylint: disable=line-too-long path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str', max_length=256, min_length=1), + "operationId": _SERIALIZER.url("log_collection_id", log_collection_id, 'str', max_length=256, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) @@ -1439,7 +1439,7 @@ def build_get_log_collection_detailed_status_request( ) -def build_list_device_health_request( +def build_list_health_of_devices_request( instance_id: str, *, filter: str, @@ -1448,7 +1448,7 @@ def build_list_device_health_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -1497,11 +1497,16 @@ def __init__(self, *args, **kwargs): @distributed_trace def list_device_classes( self, + filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.DeviceClass"]: - """Gets a list of all device classes (unique combinations of device manufacturer and model) for + """Gets a list of all device classes (sets of devices compatible with the same updates based on + the model Id and compat properties reported in the Device Update PnP interface in IoT Hub) for all devices connected to Device Update for IoT Hub. + :param filter: Restricts the set of device classes returned. You can filter on friendly name. + Default value is None. + :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeviceClass or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~deviceupdateclient.models.DeviceClass] @@ -1522,6 +1527,7 @@ def prepare_request(next_link=None): request = build_list_device_classes_request( instance_id=self._config.instance_id, + filter=filter, api_version=api_version, template_url=self.list_device_classes.metadata['url'], headers=_headers, @@ -1537,6 +1543,7 @@ def prepare_request(next_link=None): request = build_list_device_classes_request( instance_id=self._config.instance_id, + filter=filter, api_version=api_version, template_url=next_link, headers=_headers, @@ -1949,7 +1956,8 @@ def list_devices( """Gets a list of devices connected to Device Update for IoT Hub. :param filter: Restricts the set of devices returned. You can filter on GroupId, DeviceClassId, - or GroupId and DeploymentStatus. Default value is None. + or GroupId and DeploymentStatus. Use DeploymentStatus eq null to query for devices with no + deployment status (that have never been deployed to). Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Device or the result of cls(response) @@ -2373,9 +2381,9 @@ def list_groups( ) -> Iterable["_models.Group"]: """Gets a list of all device groups. The $default group will always be returned first. - :param order_by: Orders the set of groups returned. You can order by any combination of - groupId, device count, created date, subgroupsWithNewUpdatesAvailableCount, - subgroupsWithUpdatesInProgressCount, or subgroupsOnLatestUpdateCount. Default value is None. + :param order_by: Orders the set of groups returned. You can order by groupId, deviceCount, + createdDate, subgroupsWithNewUpdatesAvailableCount, subgroupsWithUpdatesInProgressCount, or + subgroupsOnLatestUpdateCount. Default value is None. :type order_by: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Group or the result of cls(response) @@ -2469,7 +2477,7 @@ def get_group( ) -> _models.Group: """Gets the device group properties. - :param group_id: Group identity. Required. + :param group_id: Group identifier. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Group or the result of cls(response) @@ -2538,7 +2546,7 @@ def delete_group( # pylint: disable=inconsistent-return-statements it. If a device is ever connected again for this group after the group was deleted it will be automatically re-created but there will be no history. - :param group_id: Group identity. Required. + :param group_id: Group identifier. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) @@ -2599,7 +2607,7 @@ def get_update_compliance_for_group( """Get device group update compliance information such as how many devices are on their latest update, how many need new updates, and how many are in progress on receiving a new update. - :param group_id: Group identity. Required. + :param group_id: Group identifier. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: UpdateCompliance or the result of cls(response) @@ -2659,18 +2667,13 @@ def get_update_compliance_for_group( def list_best_updates_for_group( self, group_id: str, - filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.DeviceClassSubgroupUpdatableDevices"]: """Get the best available updates for a device group and a count of how many devices need each update. - :param group_id: Group identity. Required. + :param group_id: Group identifier. Required. :type group_id: str - :param filter: Restricts the set of bestUpdates returned. You can filter on update Provider, - Name and Version property. This filter is deprecated and should not be used. Default value is - None. - :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeviceClassSubgroupUpdatableDevices or the result of cls(response) @@ -2694,7 +2697,6 @@ def prepare_request(next_link=None): request = build_list_best_updates_for_group_request( group_id=group_id, instance_id=self._config.instance_id, - filter=filter, api_version=api_version, template_url=self.list_best_updates_for_group.metadata['url'], headers=_headers, @@ -2711,7 +2713,6 @@ def prepare_request(next_link=None): request = build_list_best_updates_for_group_request( group_id=group_id, instance_id=self._config.instance_id, - filter=filter, api_version=api_version, template_url=next_link, headers=_headers, @@ -2768,7 +2769,7 @@ def list_deployments_for_group( ) -> Iterable["_models.Deployment"]: """Gets a list of deployments for a device group. - :param group_id: Group identity. Required. + :param group_id: Group identifier. Required. :type group_id: str :param order_by: Orders the set of deployments returned. You can order by start date. Default value is None. @@ -2868,7 +2869,7 @@ def get_deployment( ) -> _models.Deployment: """Gets the deployment properties. - :param group_id: Group identity. Required. + :param group_id: Group identifier. Required. :type group_id: str :param deployment_id: Deployment identifier. Required. :type deployment_id: str @@ -2939,7 +2940,7 @@ def create_or_update_deployment( ) -> _models.Deployment: """Creates or updates a deployment. - :param group_id: Group identity. Required. + :param group_id: Group identifier. Required. :type group_id: str :param deployment_id: Deployment identifier. Required. :type deployment_id: str @@ -2966,7 +2967,7 @@ def create_or_update_deployment( ) -> _models.Deployment: """Creates or updates a deployment. - :param group_id: Group identity. Required. + :param group_id: Group identifier. Required. :type group_id: str :param deployment_id: Deployment identifier. Required. :type deployment_id: str @@ -2992,7 +2993,7 @@ def create_or_update_deployment( ) -> _models.Deployment: """Creates or updates a deployment. - :param group_id: Group identity. Required. + :param group_id: Group identifier. Required. :type group_id: str :param deployment_id: Deployment identifier. Required. :type deployment_id: str @@ -3076,7 +3077,7 @@ def delete_deployment( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a deployment. - :param group_id: Group identity. Required. + :param group_id: Group identifier. Required. :type group_id: str :param deployment_id: Deployment identifier. Required. :type deployment_id: str @@ -3141,7 +3142,7 @@ def get_deployment_status( """Gets the status of a deployment including a breakdown of how many devices in the deployment are in progress, completed, or failed. - :param group_id: Group identity. Required. + :param group_id: Group identifier. Required. :type group_id: str :param deployment_id: Deployment identifier. Required. :type deployment_id: str @@ -3207,12 +3208,15 @@ def list_device_class_subgroups_for_group( filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.DeviceClassSubgroup"]: - """Get the device class subgroups for the group. + """Get the device class subgroups for the group. A device class subgroup is the set of devices + within the group that share the same device class. All devices within the same device class are + compatible with the same updates. - :param group_id: Group identity. Required. + :param group_id: Group identifier. Required. :type group_id: str :param filter: Restricts the set of device class subgroups returned. You can filter on compat - properties by name and value. Default value is None. + properties by name and value. (i.e. filter=compatProperties/propertyName1 eq 'value1' and + compatProperties/propertyName2 eq 'value2'). Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeviceClassSubgroup or the result of cls(response) @@ -3307,9 +3311,11 @@ def get_device_class_subgroup( device_class_id: str, **kwargs: Any ) -> _models.DeviceClassSubgroup: - """Gets device class subgroup details. + """Gets device class subgroup details. A device class subgroup is the set of devices within the + group that share the same device class. All devices within the same device class are compatible + with the same updates. - :param group_id: Group identity. Required. + :param group_id: Group identifier. Required. :type group_id: str :param device_class_id: Device class identifier. Required. :type device_class_id: str @@ -3375,9 +3381,14 @@ def delete_device_class_subgroup( # pylint: disable=inconsistent-return-stateme device_class_id: str, **kwargs: Any ) -> None: - """Deletes a device class subgroup. - - :param group_id: Group identity. Required. + """Deletes a device class subgroup. This subgroup is automatically created when a Device + Update-enabled device is connected to the hub and reports its properties. Groups, subgroups, + and deployments are not automatically cleaned up but are retained for history purposes. Users + can call this method to delete a subgroup if they do not need to retain any of the history of + the subgroup and no longer need it. If a device is ever connected again for this subgroup after + the subgroup was deleted it will be automatically re-created but there will be no history. + + :param group_id: Group identifier. Required. :type group_id: str :param device_class_id: Device class identifier. Required. :type device_class_id: str @@ -3443,7 +3454,7 @@ def get_device_class_subgroup_update_compliance( latest update, how many need new updates, and how many are in progress on receiving a new update. - :param group_id: Group identity. Required. + :param group_id: Group identifier. Required. :type group_id: str :param device_class_id: Device class identifier. Required. :type device_class_id: str @@ -3512,7 +3523,7 @@ def get_best_updates_for_device_class_subgroup( """Get the best available update for a device class subgroup and a count of how many devices need this update. - :param group_id: Group identity. Required. + :param group_id: Group identifier. Required. :type group_id: str :param device_class_id: Device class identifier. Required. :type device_class_id: str @@ -3581,7 +3592,7 @@ def list_deployments_for_device_class_subgroup( ) -> Iterable["_models.Deployment"]: """Gets a list of deployments for a device class subgroup. - :param group_id: Group identity. Required. + :param group_id: Group identifier. Required. :type group_id: str :param device_class_id: Device class identifier. Required. :type device_class_id: str @@ -3686,7 +3697,7 @@ def get_deployment_for_device_class_subgroup( ) -> _models.Deployment: """Gets the deployment properties. - :param group_id: Group identity. Required. + :param group_id: Group identifier. Required. :type group_id: str :param device_class_id: Device class identifier. Required. :type device_class_id: str @@ -3758,7 +3769,7 @@ def delete_deployment_for_device_class_subgroup( # pylint: disable=inconsistent ) -> None: """Deletes a device class subgroup deployment. - :param group_id: Group identity. Required. + :param group_id: Group identifier. Required. :type group_id: str :param device_class_id: Device class identifier. Required. :type device_class_id: str @@ -3826,7 +3837,7 @@ def stop_deployment( ) -> _models.Deployment: """Stops a deployment. - :param group_id: Group identity. Required. + :param group_id: Group identifier. Required. :type group_id: str :param device_class_id: Device class identifier. Required. :type device_class_id: str @@ -3898,7 +3909,7 @@ def retry_deployment( ) -> _models.Deployment: """Retries a deployment with failed devices. - :param group_id: Group identity. Required. + :param group_id: Group identifier. Required. :type group_id: str :param device_class_id: Device class identifier. Required. :type device_class_id: str @@ -3971,7 +3982,7 @@ def get_device_class_subgroup_deployment_status( """Gets the status of a deployment including a breakdown of how many devices in the deployment are in progress, completed, or failed. - :param group_id: Group identity. Required. + :param group_id: Group identifier. Required. :type group_id: str :param device_class_id: Device class identifier. Required. :type device_class_id: str @@ -4045,7 +4056,7 @@ def list_device_states_for_device_class_subgroup_deployment( """Gets a list of devices in a deployment along with their state. Useful for getting a list of failed devices. - :param group_id: Group identity. Required. + :param group_id: Group identifier. Required. :type group_id: str :param device_class_id: Device class identifier. Required. :type device_class_id: str @@ -4146,12 +4157,12 @@ def get_next(next_link=None): list_device_states_for_device_class_subgroup_deployment.metadata = {'url': "/deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/deployments/{deploymentId}/devicestates"} # type: ignore @distributed_trace - def get_operation( + def get_operation_status( self, operation_id: str, access_condition: Optional[_models.AccessCondition] = None, **kwargs: Any - ) -> Optional[_models.DeviceOperation]: + ) -> _models.DeviceOperation: """Retrieve operation status. :param operation_id: Operation identifier. Required. @@ -4159,8 +4170,8 @@ def get_operation( :param access_condition: Parameter group. Default value is None. :type access_condition: ~deviceupdateclient.models.AccessCondition :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeviceOperation or None or the result of cls(response) - :rtype: ~deviceupdateclient.models.DeviceOperation or None + :return: DeviceOperation or the result of cls(response) + :rtype: ~deviceupdateclient.models.DeviceOperation :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -4172,18 +4183,18 @@ def get_operation( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.DeviceOperation]] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceOperation] _if_none_match = None if access_condition is not None: _if_none_match = access_condition.if_none_match - request = build_get_operation_request( + request = build_get_operation_status_request( operation_id=operation_id, instance_id=self._config.instance_id, if_none_match=_if_none_match, api_version=api_version, - template_url=self.get_operation.metadata['url'], + template_url=self.get_operation_status.metadata['url'], headers=_headers, params=_params, ) @@ -4201,28 +4212,26 @@ def get_operation( response = pipeline_response.http_response - if response.status_code not in [200, 304]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error) - deserialized = None response_headers = {} - if response.status_code == 200: - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - - deserialized = self._deserialize('DeviceOperation', pipeline_response) + response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + + deserialized = self._deserialize('DeviceOperation', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_operation.metadata = {'url': "/deviceUpdate/{instanceId}/management/operations/{operationId}"} # type: ignore + get_operation_status.metadata = {'url': "/deviceUpdate/{instanceId}/management/operations/{operationId}"} # type: ignore @distributed_trace - def list_operations( + def list_operation_statuses( self, filter: Optional[str] = None, top: Optional[int] = None, @@ -4256,12 +4265,12 @@ def list_operations( def prepare_request(next_link=None): if not next_link: - request = build_list_operations_request( + request = build_list_operation_statuses_request( instance_id=self._config.instance_id, filter=filter, top=top, api_version=api_version, - template_url=self.list_operations.metadata['url'], + template_url=self.list_operation_statuses.metadata['url'], headers=_headers, params=_params, ) @@ -4273,7 +4282,7 @@ def prepare_request(next_link=None): else: - request = build_list_operations_request( + request = build_list_operation_statuses_request( instance_id=self._config.instance_id, filter=filter, top=top, @@ -4322,7 +4331,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_operations.metadata = {'url': "/deviceUpdate/{instanceId}/management/operations"} # type: ignore + list_operation_statuses.metadata = {'url': "/deviceUpdate/{instanceId}/management/operations"} # type: ignore @overload def start_log_collection( @@ -4611,13 +4620,13 @@ def get_next(next_link=None): @distributed_trace def get_log_collection_detailed_status( self, - operation_id: str, + log_collection_id: str, **kwargs: Any ) -> _models.LogCollectionOperationDetailedStatus: """Get log collection with detailed status. - :param operation_id: Operation identifier. Required. - :type operation_id: str + :param log_collection_id: Log collection identifier. Required. + :type log_collection_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LogCollectionOperationDetailedStatus or the result of cls(response) :rtype: ~deviceupdateclient.models.LogCollectionOperationDetailedStatus @@ -4636,7 +4645,7 @@ def get_log_collection_detailed_status( request = build_get_log_collection_detailed_status_request( - operation_id=operation_id, + log_collection_id=log_collection_id, instance_id=self._config.instance_id, api_version=api_version, template_url=self.get_log_collection_detailed_status.metadata['url'], @@ -4673,14 +4682,15 @@ def get_log_collection_detailed_status( @distributed_trace - def list_device_health( + def list_health_of_devices( self, filter: str, **kwargs: Any ) -> Iterable["_models.DeviceHealth"]: """Get list of device health. - :param filter: Filter list by specified properties. Required. + :param filter: Restricts the set of devices for which device health is returned. You can filter + on status, device id and module id. Required. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeviceHealth or the result of cls(response) @@ -4700,11 +4710,11 @@ def list_device_health( def prepare_request(next_link=None): if not next_link: - request = build_list_device_health_request( + request = build_list_health_of_devices_request( instance_id=self._config.instance_id, filter=filter, api_version=api_version, - template_url=self.list_device_health.metadata['url'], + template_url=self.list_health_of_devices.metadata['url'], headers=_headers, params=_params, ) @@ -4716,7 +4726,7 @@ def prepare_request(next_link=None): else: - request = build_list_device_health_request( + request = build_list_health_of_devices_request( instance_id=self._config.instance_id, filter=filter, api_version=api_version, @@ -4764,4 +4774,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_device_health.metadata = {'url': "/deviceUpdate/{instanceId}/management/deviceDiagnostics/deviceHealth"} # type: ignore + list_health_of_devices.metadata = {'url': "/deviceUpdate/{instanceId}/management/deviceDiagnostics/deviceHealth"} # type: ignore diff --git a/azext_iot/sdk/deviceupdate/dataplane/operations/_device_update_operations.py b/azext_iot/sdk/deviceupdate/dataplane/operations/_device_update_operations.py index 91ff81af6..18a8b5679 100644 --- a/azext_iot/sdk/deviceupdate/dataplane/operations/_device_update_operations.py +++ b/azext_iot/sdk/deviceupdate/dataplane/operations/_device_update_operations.py @@ -1,7 +1,7 @@ # pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.8.4, generator: @autorest/python@5.19.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.2, generator: @autorest/python@5.19.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, IO, Iterable, List, Optional, TypeVar, Union, cast, overload @@ -35,7 +35,7 @@ def build_list_updates_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -72,7 +72,7 @@ def build_import_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] accept = _headers.pop('Accept', "application/json") @@ -113,7 +113,7 @@ def build_get_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -154,7 +154,7 @@ def build_delete_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -190,7 +190,7 @@ def build_list_providers_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -224,7 +224,7 @@ def build_list_names_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -262,7 +262,7 @@ def build_list_versions_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -302,7 +302,7 @@ def build_list_files_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -344,7 +344,7 @@ def build_get_file_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -376,7 +376,7 @@ def build_get_file_request( ) -def build_list_operations_request( +def build_list_operation_statuses_request( instance_id: str, *, filter: Optional[str] = None, @@ -386,7 +386,7 @@ def build_list_operations_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -416,7 +416,7 @@ def build_list_operations_request( ) -def build_get_operation_request( +def build_get_operation_status_request( operation_id: str, instance_id: str, *, @@ -426,7 +426,7 @@ def build_get_operation_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str accept = _headers.pop('Accept', "application/json") # Construct URL @@ -485,7 +485,7 @@ def list_updates( :param search: Request updates matching a free-text search expression. Default value is None. :type search: str - :param filter: Filter updates by its properties. Default value is None. + :param filter: Optional to filter updates by isDeployable property. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Update or the result of cls(response) @@ -648,7 +648,9 @@ def begin_import_update( """Import new update version. This is a long-running-operation; use Operation-Location response header value to check for operation status. - :param update_to_import: The update to be imported. Required. + :param update_to_import: The update to be imported (see schema + https://json.schemastore.org/azure-deviceupdate-import-manifest-5.0.json for details). + Required. :type update_to_import: list[~deviceupdateclient.models.ImportUpdateInputItem] :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -677,7 +679,9 @@ def begin_import_update( """Import new update version. This is a long-running-operation; use Operation-Location response header value to check for operation status. - :param update_to_import: The update to be imported. Required. + :param update_to_import: The update to be imported (see schema + https://json.schemastore.org/azure-deviceupdate-import-manifest-5.0.json for details). + Required. :type update_to_import: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -705,8 +709,9 @@ def begin_import_update( """Import new update version. This is a long-running-operation; use Operation-Location response header value to check for operation status. - :param update_to_import: The update to be imported. Is either a list type or a IO type. - Required. + :param update_to_import: The update to be imported (see schema + https://json.schemastore.org/azure-deviceupdate-import-manifest-5.0.json for details). Is + either a list type or a IO type. Required. :type update_to_import: list[~deviceupdateclient.models.ImportUpdateInputItem] or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -784,7 +789,7 @@ def get_update( version: str, access_condition: Optional[_models.AccessCondition] = None, **kwargs: Any - ) -> Optional[_models.Update]: + ) -> _models.Update: """Get a specific update version. :param provider: Update provider. Required. @@ -796,8 +801,8 @@ def get_update( :param access_condition: Parameter group. Default value is None. :type access_condition: ~deviceupdateclient.models.AccessCondition :keyword callable cls: A custom type or function that will be passed the direct response - :return: Update or None or the result of cls(response) - :rtype: ~deviceupdateclient.models.Update or None + :return: Update or the result of cls(response) + :rtype: ~deviceupdateclient.models.Update :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -809,7 +814,7 @@ def get_update( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Update]] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Update] _if_none_match = None if access_condition is not None: @@ -840,14 +845,12 @@ def get_update( response = pipeline_response.http_response - if response.status_code not in [200, 304]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Update', pipeline_response) + deserialized = self._deserialize('Update', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -1194,7 +1197,7 @@ def list_versions( :type provider: str :param name: Update name. Required. :type name: str - :param filter: Filter updates by its properties. Default value is None. + :param filter: Optional to filter updates by isDeployable property. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either str or the result of cls(response) @@ -1397,7 +1400,7 @@ def get_file( file_id: str, access_condition: Optional[_models.AccessCondition] = None, **kwargs: Any - ) -> Optional[_models.UpdateFile]: + ) -> _models.UpdateFile: """Get a specific update file from the version. :param provider: Update provider. Required. @@ -1411,8 +1414,8 @@ def get_file( :param access_condition: Parameter group. Default value is None. :type access_condition: ~deviceupdateclient.models.AccessCondition :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateFile or None or the result of cls(response) - :rtype: ~deviceupdateclient.models.UpdateFile or None + :return: UpdateFile or the result of cls(response) + :rtype: ~deviceupdateclient.models.UpdateFile :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -1424,7 +1427,7 @@ def get_file( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.UpdateFile]] + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateFile] _if_none_match = None if access_condition is not None: @@ -1456,14 +1459,12 @@ def get_file( response = pipeline_response.http_response - if response.status_code not in [200, 304]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('UpdateFile', pipeline_response) + deserialized = self._deserialize('UpdateFile', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -1474,7 +1475,7 @@ def get_file( @distributed_trace - def list_operations( + def list_operation_statuses( self, filter: Optional[str] = None, top: Optional[int] = None, @@ -1483,8 +1484,8 @@ def list_operations( """Get a list of all import update operations. Completed operations are kept for 7 days before auto-deleted. Delete operations are not returned by this API version. - :param filter: Restricts the set of operations returned. Only one specific filter is supported: - "status eq 'NotStarted' or status eq 'Running'". Default value is None. + :param filter: Optional to filter operations by status property. Only one specific filter is + supported: "status eq 'NotStarted' or status eq 'Running'". Default value is None. :type filter: str :param top: Specifies a non-negative integer n that limits the number of items returned from a collection. The service returns the number of available items up to but not greater than the @@ -1508,12 +1509,12 @@ def list_operations( def prepare_request(next_link=None): if not next_link: - request = build_list_operations_request( + request = build_list_operation_statuses_request( instance_id=self._config.instance_id, filter=filter, top=top, api_version=api_version, - template_url=self.list_operations.metadata['url'], + template_url=self.list_operation_statuses.metadata['url'], headers=_headers, params=_params, ) @@ -1525,7 +1526,7 @@ def prepare_request(next_link=None): else: - request = build_list_operations_request( + request = build_list_operation_statuses_request( instance_id=self._config.instance_id, filter=filter, top=top, @@ -1574,15 +1575,15 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_operations.metadata = {'url': "/deviceUpdate/{instanceId}/updates/operations"} # type: ignore + list_operation_statuses.metadata = {'url': "/deviceUpdate/{instanceId}/updates/operations"} # type: ignore @distributed_trace - def get_operation( + def get_operation_status( self, operation_id: str, access_condition: Optional[_models.AccessCondition] = None, **kwargs: Any - ) -> Optional[_models.UpdateOperation]: + ) -> _models.UpdateOperation: """Retrieve operation status. :param operation_id: Operation identifier. Required. @@ -1590,8 +1591,8 @@ def get_operation( :param access_condition: Parameter group. Default value is None. :type access_condition: ~deviceupdateclient.models.AccessCondition :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateOperation or None or the result of cls(response) - :rtype: ~deviceupdateclient.models.UpdateOperation or None + :return: UpdateOperation or the result of cls(response) + :rtype: ~deviceupdateclient.models.UpdateOperation :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -1603,18 +1604,18 @@ def get_operation( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.UpdateOperation]] + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateOperation] _if_none_match = None if access_condition is not None: _if_none_match = access_condition.if_none_match - request = build_get_operation_request( + request = build_get_operation_status_request( operation_id=operation_id, instance_id=self._config.instance_id, if_none_match=_if_none_match, api_version=api_version, - template_url=self.get_operation.metadata['url'], + template_url=self.get_operation_status.metadata['url'], headers=_headers, params=_params, ) @@ -1632,22 +1633,20 @@ def get_operation( response = pipeline_response.http_response - if response.status_code not in [200, 304]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error) - deserialized = None response_headers = {} - if response.status_code == 200: - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - - deserialized = self._deserialize('UpdateOperation', pipeline_response) + response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + + deserialized = self._deserialize('UpdateOperation', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_operation.metadata = {'url': "/deviceUpdate/{instanceId}/updates/operations/{operationId}"} # type: ignore + get_operation_status.metadata = {'url': "/deviceUpdate/{instanceId}/updates/operations/{operationId}"} # type: ignore diff --git a/azext_iot/tests/deviceupdate/conftest.py b/azext_iot/tests/deviceupdate/conftest.py index 389764c5f..67c35cd7f 100644 --- a/azext_iot/tests/deviceupdate/conftest.py +++ b/azext_iot/tests/deviceupdate/conftest.py @@ -22,8 +22,10 @@ ACCOUNT_RG = settings.env.azext_iot_testrg VALID_IDENTITY_MAP = {"system": 1, "user": 1} -DEFAULT_ADU_RBAC_SLEEP_SEC = 90 -ADU_CLIENT_DTMI = "dtmi:azure:iot:deviceUpdateModel;1" +DEFAULT_ADU_RBAC_SLEEP_SEC = 105 + +# Manifest v4 will work with deviceUpdateModel;[1|2] but v5 only with deviceUpdateModel;2 +ADU_CLIENT_DTMI = "dtmi:azure:iot:deviceUpdateModel;2" def generate_account_id() -> str: diff --git a/azext_iot/tests/deviceupdate/manifests/libcurl4-doc-apt-manifest.json b/azext_iot/tests/deviceupdate/manifests/libcurl4-doc-apt-manifest.json index 2e573ce29..b8a137852 100644 --- a/azext_iot/tests/deviceupdate/manifests/libcurl4-doc-apt-manifest.json +++ b/azext_iot/tests/deviceupdate/manifests/libcurl4-doc-apt-manifest.json @@ -5,4 +5,4 @@ "name": "libcurl4-doc", "version": "7.58.0-2ubuntu3.12" }] -} \ No newline at end of file +} diff --git a/azext_iot/tests/deviceupdate/manifests/simple_apt_manifest_v5.json b/azext_iot/tests/deviceupdate/manifests/simple_apt_manifest_v5.json index df46ac321..aefb5dbf6 100644 --- a/azext_iot/tests/deviceupdate/manifests/simple_apt_manifest_v5.json +++ b/azext_iot/tests/deviceupdate/manifests/simple_apt_manifest_v5.json @@ -2,7 +2,7 @@ "updateId": { "provider": "digimaun", "name": "simpleaptupdate", - "version": "1.0.0.0" + "version": "1.0.0" }, "compatibility": [{ "deviceManufacturer": "Contoso", @@ -27,11 +27,11 @@ }, "files": [{ "filename": "libcurl4-doc-apt-manifest.json", - "sizeInBytes": 169, + "sizeInBytes": 163, "hashes": { - "sha256": "cYhedpblfuRmq0fM7jbzBiI6FjDTqVb+U0qkdgd9+fk=" + "sha256": "iFWTIaxp33tf5BR1w0fMmnnHpjsUjLRQ9eZFjw74LbU=" } }], "createdDateTime": "2022-07-12T00:02:41.2100526Z", "manifestVersion": "5.0" -} \ No newline at end of file +} diff --git a/azext_iot/tests/deviceupdate/test_adu_update_int.py b/azext_iot/tests/deviceupdate/test_adu_update_int.py index 3fea0acaa..cefb25cae 100644 --- a/azext_iot/tests/deviceupdate/test_adu_update_int.py +++ b/azext_iot/tests/deviceupdate/test_adu_update_int.py @@ -10,7 +10,7 @@ from azext_iot.common.embedded_cli import EmbeddedCLI from azext_iot.common.utility import process_json_arg from azext_iot.tests.conftest import get_context_path -from azext_iot.tests.deviceupdate.conftest import DEFAULT_ADU_RBAC_SLEEP_SEC, ADU_CLIENT_DTMI +from azext_iot.tests.deviceupdate.conftest import DEFAULT_ADU_RBAC_SLEEP_SEC, ADU_CLIENT_DTMI, ACCOUNT_RG from azext_iot.tests.generators import generate_generic_id from time import sleep from datetime import datetime, timedelta, timezone @@ -170,25 +170,21 @@ def test_instance_update_lifecycle(provisioned_instances_module: Dict[str, dict] f"iot device-update device health list -n {account_name} -i {instance_name} " f"--filter \"state eq '{desired_health_state}'\"" ).as_json() - assert ( - len(list_device_health) == 1 - and list_device_health[0]["deviceId"] == device_id - and list_device_health[0]["state"] == desired_health_state - ) + assert len(list_device_health) == 1 + assert list_device_health[0]["deviceId"] == device_id + assert list_device_health[0]["state"] == desired_health_state # Device Classes list_device_classes = cli.invoke( f"iot device-update device class list -n {account_name} -i {instance_name}" ).as_json() - assert ( - len(list_device_classes) == 1 - and list_device_classes[0]["deviceClassId"] == device_class_id - and list_device_classes[0]["bestCompatibleUpdate"]["updateId"]["name"] == show_simple_update["updateId"]["name"] - and list_device_classes[0]["bestCompatibleUpdate"]["updateId"]["provider"] == show_simple_update["updateId"]["provider"] - and list_device_classes[0]["bestCompatibleUpdate"]["updateId"]["version"] == show_simple_update["updateId"]["version"] - and list_device_classes[0]["bestCompatibleUpdate"]["friendlyName"] == show_simple_update["friendlyName"] - ) + assert len(list_device_classes) == 1 + assert list_device_classes[0]["deviceClassId"] == device_class_id + assert list_device_classes[0]["bestCompatibleUpdate"]["updateId"]["name"] == show_simple_update["updateId"]["name"] + assert list_device_classes[0]["bestCompatibleUpdate"]["updateId"]["provider"] == show_simple_update["updateId"]["provider"] + assert list_device_classes[0]["bestCompatibleUpdate"]["updateId"]["version"] == show_simple_update["updateId"]["version"] + assert list_device_classes[0]["bestCompatibleUpdate"]["friendlyName"] == show_simple_update["friendlyName"] list_device_class_subgroups = cli.invoke( f"iot device-update device class list -n {account_name} -i {instance_name} --group-id {device_group_id}" @@ -215,6 +211,13 @@ def test_instance_update_lifecycle(provisioned_instances_module: Dict[str, dict] f"--friendly-name {class_friendly_name}" ).as_json() assert update_device_class["friendlyName"] == class_friendly_name + # Currently only friendlyName can be filtered on. + list_device_class_filter = cli.invoke( + f"iot device-update device class list -n {account_name} -i {instance_name} " + f"--filter \"friendlyName eq '{class_friendly_name}'\"" + ).as_json() + assert len(list_device_class_filter) == 1 + assert list_device_class_filter[0]["friendlyName"] == class_friendly_name device_class_subgroup_show_flags = ["--best-update", "--update-compliance"] show_device_class_template_cmd = ( @@ -407,22 +410,36 @@ def test_instance_update_lifecycle(provisioned_instances_module: Dict[str, dict] f"iot device-update device deployment delete -n {account_name} -i {instance_name} " f"--deployment-id {rollback_deployment_id} --group-id {device_group_id} --class-id {device_class_id} -y").success() - # Clean-up class and group - # TODO : Deleting a class Id does not work today. - # assert cli.invoke( - # f"iot device-update device class delete -n {account_name} -i {instance_name} --class-id {device_class_id} -y").success() - # list_device_classes = cli.invoke( - # f"iot device-update device class list -n {account_name} -i {instance_name}" - # ).as_json() - # assert len(list_device_classes) == 0 + # Clean-up device class subgroup and group + # TODO : Deleting a class Id does not work today, but you are able to delete a class subgroup. + + # First reset device state + assert cli.invoke( + f"iot hub device-twin update -n {iothub_name} -d {device_id} --tags '{json.dumps({'ADUGroup': None})}'" + ).success() + reset_device_state = {"deviceUpdate": None, "deviceInformation": None} + assert cli.invoke( + f"iot device simulate -n {iothub_name} -d {device_id} --irp '{json.dumps(reset_device_state)}' --mi 1 --mc 1" + ).success() + + # Re-import device state + assert cli.invoke(f"iot device-update device import -n {account_name} -i {instance_name}").success() + + # Delete device class subgroup + assert cli.invoke( + f"iot device-update device class delete -n {account_name} -i {instance_name} " + f"--class-id {device_class_id} --group-id {device_group_id} -y" + ).success() - # TODO: You can't delete a device group that contains classes. Since we cannot delete the class we cannot delete the group :( - # assert cli.invoke( - # f"iot device-update device group delete -n {account_name} -i {instance_name} --group-id {device_group_id} -y").success() - # list_device_groups = cli.invoke( - # f"iot device-update device group list -n {account_name} -i {instance_name}" - # ).as_json() - # assert len(list_device_groups) == 0 + # Delete device group, assert fallback to $default + assert cli.invoke( + f"iot device-update device group delete -n {account_name} -i {instance_name} --group-id {device_group_id} -y").success() + list_device_groups = cli.invoke( + f"iot device-update device group list -n {account_name} -i {instance_name}" + ).as_json() + if list_device_groups: + assert len(list_device_groups) == 1 + assert list_device_groups[0]["groupId"] == "$default" def test_instance_update_nested(provisioned_instances_module: Dict[str, dict]): @@ -521,3 +538,26 @@ def _assign_rbac_if_needed(account_name: str): f"--assignee '{principal['user']['name']}' --scope '{account['id']}'" ).success() sleep(DEFAULT_ADU_RBAC_SLEEP_SEC) + + +def test_adu_set_config_defaults(provisioned_instances_module: Dict[str, dict]): + account_name = list(provisioned_instances_module.keys())[0] + instance_name = list(provisioned_instances_module[account_name].keys())[0] + _assign_rbac_if_needed(account_name) + + # Set defaults. + assert cli.invoke(f"config set defaults.adu_account={account_name} defaults.adu_instance={instance_name}").success() + + # Assert prior required params use defaults. + account_result = cli.invoke("iot device-update account show").as_json() + assert account_result["name"] == account_name + assert cli.invoke("iot device-update device group list").success() + assert cli.invoke(f"config set defaults.adu_group={ACCOUNT_RG}").success() + assert cli.invoke("iot device-update device class list").success() + + # Unset defaults + assert cli.invoke("config set defaults.adu_account='' defaults.adu_instance='' defaults.adu_group=''").success() + + # Expect failure due to missing required param value. + assert not cli.invoke("iot device-update account show").success() + assert not cli.invoke("iot device-update device group list").success()