From b11d87dad8f17144308e203b07c45964a2b67cd5 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 9 May 2022 06:43:55 +0000 Subject: [PATCH] CodeGen from PR 3112 in openapi-env-test/azure-rest-api-specs Merge e1c11a0fb7b1f627ff005e3ac37fab857db30f39 into dd528db889505ce821d95459404aba16870aef24 --- .../azure-iot-deviceupdate/MANIFEST.in | 1 + .../azure-iot-deviceupdate/_meta.json | 11 + .../azure/iot/deviceupdate/__init__.py | 15 +- .../{_device_update_client.py => _client.py} | 26 +- .../azure/iot/deviceupdate/_configuration.py | 5 +- .../azure/iot/deviceupdate/_version.py | 2 +- .../azure/iot/deviceupdate/aio/__init__.py | 15 +- .../{_device_update_client.py => _client.py} | 24 +- .../iot/deviceupdate/aio/_configuration.py | 5 +- .../deviceupdate/aio/operations/__init__.py | 5 + .../aio/operations/_operations.py | 2127 ++++++----- .../iot/deviceupdate/aio/operations/_patch.py | 19 + .../iot/deviceupdate/operations/__init__.py | 5 + .../deviceupdate/operations/_operations.py | 3143 ++++++++++------- .../iot/deviceupdate/operations/_patch.py | 19 + 15 files changed, 3259 insertions(+), 2163 deletions(-) create mode 100644 sdk/deviceupdate/azure-iot-deviceupdate/_meta.json rename sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/{_device_update_client.py => _client.py} (79%) rename sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/{_device_update_client.py => _client.py} (80%) create mode 100644 sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/operations/_patch.py create mode 100644 sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/operations/_patch.py diff --git a/sdk/deviceupdate/azure-iot-deviceupdate/MANIFEST.in b/sdk/deviceupdate/azure-iot-deviceupdate/MANIFEST.in index cbcfcd5c3706..20d39f2d958b 100644 --- a/sdk/deviceupdate/azure-iot-deviceupdate/MANIFEST.in +++ b/sdk/deviceupdate/azure-iot-deviceupdate/MANIFEST.in @@ -1,3 +1,4 @@ +include _meta.json recursive-include tests *.py recursive-include samples *.py *.md include LICENSE diff --git a/sdk/deviceupdate/azure-iot-deviceupdate/_meta.json b/sdk/deviceupdate/azure-iot-deviceupdate/_meta.json new file mode 100644 index 000000000000..2acc209aea03 --- /dev/null +++ b/sdk/deviceupdate/azure-iot-deviceupdate/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.16.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "a69b4cc9bbf5e152f6253cbb878b266b1e1636e3", + "repository_url": "https://github.com/openapi-env-test/azure-rest-api-specs", + "autorest_command": "autorest specification/deviceupdate/data-plane/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2 --version-tolerant", + "readme": "specification/deviceupdate/data-plane/readme.md" +} \ No newline at end of file diff --git a/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/__init__.py b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/__init__.py index 198b31043021..42b0cbae4757 100644 --- a/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/__init__.py +++ b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/__init__.py @@ -6,13 +6,18 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._device_update_client import DeviceUpdateClient +from ._client import DeviceUpdateClient from ._version import VERSION __version__ = VERSION + +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.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/_device_update_client.py b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/_client.py similarity index 79% rename from sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/_device_update_client.py rename to sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/_client.py index 5d108daa8072..8c6379c3279e 100644 --- a/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/_device_update_client.py +++ b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core import PipelineClient from azure.core.rest import HttpRequest, HttpResponse -from msrest import Deserializer, Serializer from ._configuration import DeviceUpdateClientConfiguration from .operations import DeviceManagementOperations, DeviceUpdateOperations @@ -23,7 +24,12 @@ from azure.core.credentials import TokenCredential class DeviceUpdateClient: - """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. + """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: azure.iot.deviceupdate.operations.DeviceUpdateOperations @@ -35,8 +41,8 @@ class DeviceUpdateClient: :type instance_id: str :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2021-06-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. @@ -56,13 +62,17 @@ def __init__( self._serialize = Serializer() self._deserialize = Deserializer() 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) + 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, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/_configuration.py b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/_configuration.py index caeac512979a..b5053ae2298f 100644 --- a/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/_configuration.py +++ b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/_configuration.py @@ -18,7 +18,7 @@ from azure.core.credentials import TokenCredential -class DeviceUpdateClientConfiguration(Configuration): +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 @@ -30,7 +30,8 @@ class DeviceUpdateClientConfiguration(Configuration): :type instance_id: str :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that overriding this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str """ diff --git a/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/_version.py b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/_version.py index dfa6ee022f15..5819b888fe6e 100644 --- a/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/_version.py +++ b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b2" +VERSION = "3.0.0b1" diff --git a/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/__init__.py b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/__init__.py index b24f5490bb69..fc222df4b589 100644 --- a/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/__init__.py +++ b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/__init__.py @@ -6,10 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._device_update_client import DeviceUpdateClient +from ._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.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/_device_update_client.py b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/_client.py similarity index 80% rename from sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/_device_update_client.py rename to sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/_client.py index f2bca67ae39f..82539487e2a6 100644 --- a/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/_device_update_client.py +++ b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core import AsyncPipelineClient from azure.core.rest import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer from ._configuration import DeviceUpdateClientConfiguration from .operations import DeviceManagementOperations, DeviceUpdateOperations @@ -23,7 +24,12 @@ from azure.core.credentials_async import AsyncTokenCredential class DeviceUpdateClient: - """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. + """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: azure.iot.deviceupdate.aio.operations.DeviceUpdateOperations @@ -35,8 +41,8 @@ class DeviceUpdateClient: :type instance_id: str :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2021-06-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. @@ -56,8 +62,12 @@ def __init__( self._serialize = Serializer() self._deserialize = Deserializer() 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) + 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( diff --git a/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/_configuration.py b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/_configuration.py index c61830d23659..74cfd1314c70 100644 --- a/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/_configuration.py +++ b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/_configuration.py @@ -18,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class DeviceUpdateClientConfiguration(Configuration): +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 @@ -30,7 +30,8 @@ class DeviceUpdateClientConfiguration(Configuration): :type instance_id: str :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that overriding this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str """ diff --git a/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/operations/__init__.py b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/operations/__init__.py index 12ed68c85ea9..0c0112ed2670 100644 --- a/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/operations/__init__.py +++ b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/operations/__init__.py @@ -9,7 +9,12 @@ from ._operations import DeviceUpdateOperations from ._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/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/operations/_operations.py b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/operations/_operations.py index 53e91bae8daa..86f949467cdb 100644 --- a/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/operations/_operations.py +++ b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,10 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from json import loads as _loads -from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, List, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -19,45 +18,53 @@ 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 ...operations._operations import build_device_management_collect_logs_request, build_device_management_create_or_update_deployment_request, build_device_management_create_or_update_group_request, build_device_management_delete_deployment_request, build_device_management_delete_group_request, build_device_management_get_deployment_request, build_device_management_get_deployment_status_request, build_device_management_get_device_class_request, build_device_management_get_device_module_request, build_device_management_get_device_request, build_device_management_get_device_tag_request, build_device_management_get_group_request, build_device_management_get_group_update_compliance_request, build_device_management_get_log_collection_operation_detailed_status_request, build_device_management_get_log_collection_operation_request, build_device_management_get_operation_request, build_device_management_get_update_compliance_request, build_device_management_import_devices_request_initial, build_device_management_list_best_updates_for_group_request, build_device_management_list_deployment_devices_request, build_device_management_list_deployments_for_group_request, build_device_management_list_device_classes_request, build_device_management_list_device_tags_request, build_device_management_list_devices_request, build_device_management_list_groups_request, build_device_management_list_installable_updates_for_device_class_request, build_device_management_list_log_collection_operations_request, build_device_management_list_operations_request, build_device_management_retry_deployment_request, build_device_management_stop_deployment_request, build_device_update_delete_update_request_initial, build_device_update_get_file_request, build_device_update_get_operation_request, build_device_update_get_update_request, build_device_update_import_update_request_initial, build_device_update_list_files_request, build_device_update_list_names_request, build_device_update_list_operations_request, build_device_update_list_providers_request, build_device_update_list_updates_request, build_device_update_list_versions_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DeviceUpdateOperations: - """DeviceUpdateOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.iot.deviceupdate.aio.DeviceUpdateClient`'s + :attr:`device_update` attribute. """ - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") + async def _import_update_initial( self, - update_to_import: List[JSONType], + update_to_import: List[JSON], *, action: str, **kwargs: Any - ) -> JSONType: - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] + ) -> JSON: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[JSON] _json = update_to_import @@ -67,13 +74,19 @@ async def _import_update_initial( content_type=content_type, action=action, json=_json, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -89,30 +102,26 @@ async def _import_update_initial( deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, cast(JSON, deserialized), response_headers) - return deserialized + return cast(JSON, deserialized) - _import_update_initial.metadata = {'url': '/deviceupdate/{instanceId}/updates'} # type: ignore @distributed_trace_async async def begin_import_update( self, - update_to_import: List[JSONType], + update_to_import: List[JSON], *, action: str, **kwargs: Any - ) -> AsyncLROPoller[JSONType]: + ) -> AsyncLROPoller[JSON]: """Import new update version. :param update_to_import: The update to be imported. - :type update_to_import: list[JSONType] + :type update_to_import: list[JSON] :keyword action: Import update action. "import" :paramtype action: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :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 @@ -121,7 +130,7 @@ async def begin_import_update( :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 JSON object - :rtype: ~azure.core.polling.AsyncLROPoller[JSONType] + :rtype: ~azure.core.polling.AsyncLROPoller[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -132,17 +141,29 @@ async def begin_import_update( { "files": [ { - "filename": "str", # Required. Update file name as specified inside import manifest. - "url": "str" # Required. Azure Blob location from which the update file can be downloaded by Device Update for IoT Hub. This is typically a read-only SAS-protected blob URL with an expiration set to at least 4 hours. + "filename": "str", # Required. Update file name as + specified inside import manifest. + "url": "str" # Required. Azure Blob location from + which the update file can be downloaded by Device Update for IoT Hub. + This is typically a read-only SAS-protected blob URL with an + expiration set to at least 4 hours. } ], "friendlyName": "str", # Optional. Friendly update name. "importManifest": { "hashes": { - "str": "str" # Required. A JSON object containing the hash(es) of the file. At least SHA256 hash is required. This object can be thought of as a set of key-value pairs where the key is the hash algorithm, and the value is the hash of the file calculated using that algorithm. + "str": "str" # Required. A JSON object containing + the hash(es) of the file. At least SHA256 hash is required. This + object can be thought of as a set of key-value pairs where the key is + the hash algorithm, and the value is the hash of the file calculated + using that algorithm. }, - "sizeInBytes": 0.0, # Required. File size in number of bytes. - "url": "str" # Required. Azure Blob location from which the import manifest can be downloaded by Device Update for IoT Hub. This is typically a read-only SAS-protected blob URL with an expiration set to at least 4 hours. + "sizeInBytes": 0.0, # Required. File size in number of + bytes. + "url": "str" # Required. Azure Blob location from which the + import manifest can be downloaded by Device Update for IoT Hub. This is + typically a read-only SAS-protected blob URL with an expiration set to at + least 4 hours. } } ] @@ -151,35 +172,50 @@ async def begin_import_update( response.json() == { "compatibility": [ { - "str": "str" # Required. List of update compatibility information. + "str": "str" # Required. List of update compatibility + information. } ], - "createdDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the update was created. + "createdDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC + when the update was created. "description": "str", # Optional. Update description specified by creator. "etag": "str", # Optional. Update ETag. - "friendlyName": "str", # Optional. Friendly update name specified by importer. - "importedDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the update was imported. - "installedCriteria": "str", # Optional. String interpreted by Device Update client to determine if the update is installed on the device. Deprecated in latest import manifest schema. + "friendlyName": "str", # Optional. Friendly update name specified by + importer. + "importedDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC + when the update was imported. + "installedCriteria": "str", # Optional. String interpreted by Device Update + client to determine if the update is installed on the device. Deprecated in + latest import manifest schema. "instructions": { "steps": [ { "description": "str", # Optional. Step description. "files": [ - "str" # Optional. Collection of file names to be passed to handler during execution. Required if step type is inline. + "str" # Optional. Collection of file names + to be passed to handler during execution. Required if step type + is inline. ], - "handler": "str", # Optional. Identity of handler that will execute this step. Required if step type is inline. - "handlerProperties": {}, # Optional. Parameters to be passed to handler during execution. - "type": "inline", # Optional. Default value is "inline". Step type. Possible values include: "Inline", "Reference". Default value: "inline". + "handler": "str", # Optional. Identity of handler + that will execute this step. Required if step type is inline. + "handlerProperties": {}, # Optional. Parameters to + be passed to handler during execution. + "type": "inline", # Optional. Default value is + "inline". Step type. Known values are: "Inline", "Reference". Default + value: "inline". "updateId": { "name": "str", # Required. Update name. - "provider": "str", # Required. Update provider. + "provider": "str", # Required. Update + provider. "version": "str" # Required. Update version. } } ] }, - "isDeployable": True, # Optional. Default value is True. Whether the update can be deployed to a device on its own. - "manifestVersion": "str", # Required. Schema version of manifest used to import the update. + "isDeployable": True, # Optional. Default value is True. Whether the update + can be deployed to a device on its own. + "manifestVersion": "str", # Required. Schema version of manifest used to + import the update. "referencedBy": [ { "name": "str", # Required. Update name. @@ -187,31 +223,38 @@ async def begin_import_update( "version": "str" # Required. Update version. } ], - "scanResult": "str", # Optional. Update aggregate scan result (calculated from payload file scan results). + "scanResult": "str", # Optional. Update aggregate scan result (calculated + from payload file scan results). "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. "version": "str" # Required. Update version. }, - "updateType": "str" # Optional. Update type. Deprecated in latest import manifest schema. + "updateType": "str" # Optional. Update type. Deprecated in latest import + manifest schema. } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] + _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', "2021-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + 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( + raw_result = await self._import_update_initial( # type: ignore update_to_import=update_to_import, action=action, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -234,8 +277,14 @@ def get_long_running_output(pipeline_response): "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - if polling is True: polling_method = AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -244,10 +293,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + - begin_import_update.metadata = {'url': '/deviceupdate/{instanceId}/updates'} # type: ignore @distributed_trace def list_updates( @@ -256,18 +304,15 @@ def list_updates( search: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[JSONType]: + ) -> AsyncIterable[JSON]: """Get a list of all updates that have been imported to Device Update for IoT Hub. - :keyword search: Request updates matching a free-text search expression. + :keyword search: Request updates matching a free-text search expression. Default value is None. :paramtype search: str - :keyword filter: Filter updates by its properties. + :keyword filter: Filter updates by its properties. Default value is None. :paramtype filter: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.async_paging.AsyncItemPaged[JSONType] + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -280,60 +325,86 @@ def list_updates( { "compatibility": [ { - "str": "str" # Required. List of update compatibility information. + "str": "str" # Required. List of update + compatibility information. } ], - "createdDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the update was created. - "description": "str", # Optional. Update description specified by creator. + "createdDateTime": "2020-02-20 00:00:00", # Required. Date + and time in UTC when the update was created. + "description": "str", # Optional. Update description + specified by creator. "etag": "str", # Optional. Update ETag. - "friendlyName": "str", # Optional. Friendly update name specified by importer. - "importedDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the update was imported. - "installedCriteria": "str", # Optional. String interpreted by Device Update client to determine if the update is installed on the device. Deprecated in latest import manifest schema. + "friendlyName": "str", # Optional. Friendly update name + specified by importer. + "importedDateTime": "2020-02-20 00:00:00", # Required. Date + and time in UTC when the update was imported. + "installedCriteria": "str", # Optional. String interpreted + by Device Update client to determine if the update is installed on the + device. Deprecated in latest import manifest schema. "instructions": { "steps": [ { - "description": "str", # Optional. Step description. + "description": "str", # Optional. + Step description. "files": [ - "str" # Optional. Collection of file names to be passed to handler during execution. Required if step type is inline. + "str" # Optional. Collection + of file names to be passed to handler during execution. + Required if step type is inline. ], - "handler": "str", # Optional. Identity of handler that will execute this step. Required if step type is inline. - "handlerProperties": {}, # Optional. Parameters to be passed to handler during execution. - "type": "inline", # Optional. Default value is "inline". Step type. Possible values include: "Inline", "Reference". Default value: "inline". + "handler": "str", # Optional. + Identity of handler that will execute this step. Required if + step type is inline. + "handlerProperties": {}, # Optional. + Parameters to be passed to handler during execution. + "type": "inline", # Optional. + Default value is "inline". Step type. Known values are: + "Inline", "Reference". Default value: "inline". "updateId": { - "name": "str", # Required. Update name. - "provider": "str", # Required. Update provider. - "version": "str" # Required. Update version. + "name": "str", # Required. + Update name. + "provider": "str", # + Required. Update provider. + "version": "str" # Required. + Update version. } } ] }, - "isDeployable": True, # Optional. Default value is True. Whether the update can be deployed to a device on its own. - "manifestVersion": "str", # Required. Schema version of manifest used to import the update. + "isDeployable": True, # Optional. Default value is True. + Whether the update can be deployed to a device on its own. + "manifestVersion": "str", # Required. Schema version of + manifest used to import the update. "referencedBy": [ { "name": "str", # Required. Update name. - "provider": "str", # Required. Update provider. + "provider": "str", # Required. Update + provider. "version": "str" # Required. Update version. } ], - "scanResult": "str", # Optional. Update aggregate scan result (calculated from payload file scan results). + "scanResult": "str", # Optional. Update aggregate scan + result (calculated from payload file scan results). "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. "version": "str" # Required. Update version. }, - "updateType": "str" # Optional. Update type. Deprecated in latest import manifest schema. + "updateType": "str" # Optional. Update type. Deprecated in + latest import manifest schema. } ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -342,24 +413,25 @@ def prepare_request(next_link=None): api_version=api_version, search=search, filter=filter, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_update_list_updates_request( instance_id=self._config.instance_id, - api_version=api_version, - search=search, - filter=filter, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -368,7 +440,7 @@ def prepare_request(next_link=None): return request async def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -377,7 +449,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -390,7 +466,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_updates.metadata = {'url': '/deviceupdate/{instanceId}/updates'} # type: ignore + @distributed_trace_async async def get_update( @@ -401,7 +477,7 @@ async def get_update( *, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional[JSONType]: + ) -> Optional[JSON]: """Get a specific update version. :param provider: Update provider. @@ -411,13 +487,10 @@ async def get_update( :param version: Update version. :type version: str :keyword if_none_match: Defines the If-None-Match condition. The operation will be performed - only if the ETag on the server does not match this value. + only if the ETag on the server does not match this value. Default value is None. :paramtype if_none_match: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType or None + :rtype: JSON or None :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -427,35 +500,50 @@ async def get_update( response.json() == { "compatibility": [ { - "str": "str" # Required. List of update compatibility information. + "str": "str" # Required. List of update compatibility + information. } ], - "createdDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the update was created. + "createdDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC + when the update was created. "description": "str", # Optional. Update description specified by creator. "etag": "str", # Optional. Update ETag. - "friendlyName": "str", # Optional. Friendly update name specified by importer. - "importedDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the update was imported. - "installedCriteria": "str", # Optional. String interpreted by Device Update client to determine if the update is installed on the device. Deprecated in latest import manifest schema. + "friendlyName": "str", # Optional. Friendly update name specified by + importer. + "importedDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC + when the update was imported. + "installedCriteria": "str", # Optional. String interpreted by Device Update + client to determine if the update is installed on the device. Deprecated in + latest import manifest schema. "instructions": { "steps": [ { "description": "str", # Optional. Step description. "files": [ - "str" # Optional. Collection of file names to be passed to handler during execution. Required if step type is inline. + "str" # Optional. Collection of file names + to be passed to handler during execution. Required if step type + is inline. ], - "handler": "str", # Optional. Identity of handler that will execute this step. Required if step type is inline. - "handlerProperties": {}, # Optional. Parameters to be passed to handler during execution. - "type": "inline", # Optional. Default value is "inline". Step type. Possible values include: "Inline", "Reference". Default value: "inline". + "handler": "str", # Optional. Identity of handler + that will execute this step. Required if step type is inline. + "handlerProperties": {}, # Optional. Parameters to + be passed to handler during execution. + "type": "inline", # Optional. Default value is + "inline". Step type. Known values are: "Inline", "Reference". Default + value: "inline". "updateId": { "name": "str", # Required. Update name. - "provider": "str", # Required. Update provider. + "provider": "str", # Required. Update + provider. "version": "str" # Required. Update version. } } ] }, - "isDeployable": True, # Optional. Default value is True. Whether the update can be deployed to a device on its own. - "manifestVersion": "str", # Required. Schema version of manifest used to import the update. + "isDeployable": True, # Optional. Default value is True. Whether the update + can be deployed to a device on its own. + "manifestVersion": "str", # Required. Schema version of manifest used to + import the update. "referencedBy": [ { "name": "str", # Required. Update name. @@ -463,22 +551,27 @@ async def get_update( "version": "str" # Required. Update version. } ], - "scanResult": "str", # Optional. Update aggregate scan result (calculated from payload file scan results). + "scanResult": "str", # Optional. Update aggregate scan result (calculated + from payload file scan results). "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. "version": "str" # Required. Update version. }, - "updateType": "str" # Optional. Update type. Deprecated in latest import manifest schema. + "updateType": "str" # Optional. Update type. Deprecated in latest import + manifest schema. } """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[JSONType]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[JSON]] request = build_device_update_get_update_request( @@ -488,13 +581,19 @@ async def get_update( version=version, api_version=api_version, if_none_match=if_none_match, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -513,23 +612,25 @@ async def get_update( return deserialized - get_update.metadata = {'url': '/deviceupdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}'} # type: ignore - async def _delete_update_initial( + async def _delete_update_initial( # pylint: disable=inconsistent-return-statements self, provider: str, name: str, version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_device_update_delete_update_request_initial( @@ -538,13 +639,19 @@ async def _delete_update_initial( name=name, version=version, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -558,11 +665,10 @@ async def _delete_update_initial( 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( + async def begin_delete_update( # pylint: disable=inconsistent-return-statements self, provider: str, name: str, @@ -577,9 +683,6 @@ async def begin_delete_update( :type name: str :param version: Update version. :type version: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :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 @@ -591,21 +694,26 @@ async def begin_delete_update( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # 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( + 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) @@ -619,8 +727,14 @@ def get_long_running_output(pipeline_response): "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - if polling is True: polling_method = AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -629,23 +743,19 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + 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[JSONType]: + ) -> AsyncIterable[JSON]: """Get a list of all update providers that have been imported to Device Update for IoT Hub. - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.async_paging.AsyncItemPaged[JSONType] + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -659,35 +769,41 @@ def list_providers( ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_device_update_list_providers_request( instance_id=self._config.instance_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_update_list_providers_request( instance_id=self._config.instance_id, - api_version=api_version, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -696,7 +812,7 @@ def prepare_request(next_link=None): return request async def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -705,7 +821,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -718,23 +838,20 @@ async def get_next(next_link=None): 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[JSONType]: + ) -> AsyncIterable[JSON]: """Get a list of all update names that match the specified provider. :param provider: Update provider. :type provider: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.async_paging.AsyncItemPaged[JSONType] + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -748,13 +865,16 @@ def list_names( ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -762,23 +882,26 @@ def prepare_request(next_link=None): instance_id=self._config.instance_id, provider=provider, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_update_list_names_request( instance_id=self._config.instance_id, provider=provider, - api_version=api_version, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -787,7 +910,7 @@ def prepare_request(next_link=None): return request async def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -796,7 +919,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -809,7 +936,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_names.metadata = {'url': '/deviceupdate/{instanceId}/updates/providers/{provider}/names'} # type: ignore + @distributed_trace def list_versions( @@ -819,20 +946,17 @@ def list_versions( *, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[JSONType]: + ) -> AsyncIterable[JSON]: """Get a list of all update versions that match the specified provider and name. :param provider: Update provider. :type provider: str :param name: Update name. :type name: str - :keyword filter: Filter updates by its properties. + :keyword filter: Filter updates by its properties. Default value is None. :paramtype filter: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.async_paging.AsyncItemPaged[JSONType] + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -846,13 +970,16 @@ def list_versions( ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -862,11 +989,13 @@ def prepare_request(next_link=None): name=name, api_version=api_version, filter=filter, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: @@ -874,13 +1003,13 @@ def prepare_request(next_link=None): instance_id=self._config.instance_id, provider=provider, name=name, - api_version=api_version, - filter=filter, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -889,7 +1018,7 @@ def prepare_request(next_link=None): return request async def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -898,7 +1027,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -911,7 +1044,7 @@ async def get_next(next_link=None): 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( @@ -920,7 +1053,7 @@ def list_files( name: str, version: str, **kwargs: Any - ) -> AsyncIterable[JSONType]: + ) -> AsyncIterable[JSON]: """Get a list of all update file identifiers for the specified version. :param provider: Update provider. @@ -929,11 +1062,8 @@ def list_files( :type name: str :param version: Update version. :type version: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.async_paging.AsyncItemPaged[JSONType] + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -947,13 +1077,16 @@ def list_files( ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -963,11 +1096,13 @@ def prepare_request(next_link=None): name=name, version=version, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: @@ -976,12 +1111,13 @@ def prepare_request(next_link=None): provider=provider, name=name, version=version, - api_version=api_version, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -990,7 +1126,7 @@ def prepare_request(next_link=None): return request async def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -999,7 +1135,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1012,7 +1152,7 @@ async def get_next(next_link=None): 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( @@ -1024,7 +1164,7 @@ async def get_file( *, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional[JSONType]: + ) -> Optional[JSON]: """Get a specific update file from the version. :param provider: Update provider. @@ -1036,13 +1176,10 @@ async def get_file( :param file_id: File identifier. :type file_id: str :keyword if_none_match: Defines the If-None-Match condition. The operation will be performed - only if the ETag on the server does not match this value. + only if the ETag on the server does not match this value. Default value is None. :paramtype if_none_match: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType or None + :rtype: JSON or None :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -1051,10 +1188,12 @@ async def get_file( # response body for status code(s): 200 response.json() == { "etag": "str", # Optional. File ETag. - "fileId": "str", # Required. File identity, generated by server at import time. + "fileId": "str", # Required. File identity, generated by server at import + time. "fileName": "str", # Required. File name. "hashes": { - "str": "str" # Required. Mapping of hashing algorithm to base64 encoded hash values. + "str": "str" # Required. Mapping of hashing algorithm to base64 + encoded hash values. }, "mimeType": "str", # Optional. File MIME type. "scanDetails": "str", # Optional. Anti-malware scan details. @@ -1062,13 +1201,16 @@ async def get_file( "sizeInBytes": 0.0 # Required. File size in number of bytes. } """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[JSONType]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[JSON]] request = build_device_update_get_file_request( @@ -1079,13 +1221,19 @@ async def get_file( file_id=file_id, api_version=api_version, if_none_match=if_none_match, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -1104,7 +1252,6 @@ async def get_file( return deserialized - get_file.metadata = {'url': '/deviceupdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}/files/{fileId}'} # type: ignore @distributed_trace @@ -1114,22 +1261,19 @@ def list_operations( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[JSONType]: + ) -> AsyncIterable[JSON]: """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. :keyword filter: Restricts the set of operations returned. Only one specific filter is - supported: "status eq 'NotStarted' or status eq 'Running'". + supported: "status eq 'NotStarted' or status eq 'Running'". Default value is None. :paramtype filter: str :keyword 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. + specified value n. Default value is None. :paramtype top: int - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.async_paging.AsyncItemPaged[JSONType] + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -1140,28 +1284,39 @@ def list_operations( "nextLink": "str", # Optional. The link to the next page of items. "value": [ { - "createdDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the operation was created. + "createdDateTime": "2020-02-20 00:00:00", # Required. Date + and time in UTC when the operation was created. "error": { - "code": "str", # Required. Server defined error code. + "code": "str", # Required. Server defined error + code. "details": [ ... ], "innererror": { - "code": "str", # Required. A more specific error code than what was provided by the containing error. - "errorDetail": "str", # Optional. The internal error or exception message. + "code": "str", # Required. A more specific + error code than what was provided by the containing error. + "errorDetail": "str", # Optional. The + internal error or exception message. "innerError": ..., - "message": "str" # Optional. A human-readable representation of the error. + "message": "str" # Optional. A + human-readable representation of the error. }, - "message": "str", # Required. A human-readable representation of the error. - "occurredDateTime": "2020-02-20 00:00:00", # Optional. Date and time in UTC when the error occurred. + "message": "str", # Required. A human-readable + representation of the error. + "occurredDateTime": "2020-02-20 00:00:00", # + Optional. Date and time in UTC when the error occurred. "target": "str" # Optional. The target of the error. }, "etag": "str", # Optional. Operation ETag. - "lastActionDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the operation status was last updated. + "lastActionDateTime": "2020-02-20 00:00:00", # Required. + Date and time in UTC when the operation status was last updated. "operationId": "str", # Required. Operation Id. - "resourceLocation": "str", # Optional. Location of the imported update when operation is successful. - "status": "str", # Required. Operation status. Possible values include: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". - "traceId": "str", # Optional. Operation correlation identity that can used by Microsoft Support for troubleshooting. + "resourceLocation": "str", # Optional. Location of the + imported update when operation is successful. + "status": "str", # Required. Operation status. Known values + are: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". + "traceId": "str", # Optional. Operation correlation identity + that can used by Microsoft Support for troubleshooting. "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. @@ -1171,13 +1326,16 @@ def list_operations( ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1186,24 +1344,25 @@ def prepare_request(next_link=None): api_version=api_version, filter=filter, top=top, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_update_list_operations_request( instance_id=self._config.instance_id, - api_version=api_version, - filter=filter, - top=top, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -1212,7 +1371,7 @@ def prepare_request(next_link=None): return request async def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -1221,7 +1380,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1234,7 +1397,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_operations.metadata = {'url': '/deviceupdate/{instanceId}/updates/operations'} # type: ignore + @distributed_trace_async async def get_operation( @@ -1243,19 +1406,16 @@ async def get_operation( *, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional[JSONType]: + ) -> Optional[JSON]: """Retrieve operation status. :param operation_id: Operation identifier. :type operation_id: str :keyword if_none_match: Defines the If-None-Match condition. The operation will be performed - only if the ETag on the server does not match this value. + only if the ETag on the server does not match this value. Default value is None. :paramtype if_none_match: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType or None + :rtype: JSON or None :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -1263,28 +1423,38 @@ async def get_operation( # response body for status code(s): 200 response.json() == { - "createdDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the operation was created. + "createdDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC + when the operation was created. "error": { "code": "str", # Required. Server defined error code. "details": [ ... ], "innererror": { - "code": "str", # Required. A more specific error code than what was provided by the containing error. - "errorDetail": "str", # Optional. The internal error or exception message. + "code": "str", # Required. A more specific error code than + what was provided by the containing error. + "errorDetail": "str", # Optional. The internal error or + exception message. "innerError": ..., - "message": "str" # Optional. A human-readable representation of the error. + "message": "str" # Optional. A human-readable representation + of the error. }, - "message": "str", # Required. A human-readable representation of the error. - "occurredDateTime": "2020-02-20 00:00:00", # Optional. Date and time in UTC when the error occurred. + "message": "str", # Required. A human-readable representation of the + error. + "occurredDateTime": "2020-02-20 00:00:00", # Optional. Date and time + in UTC when the error occurred. "target": "str" # Optional. The target of the error. }, "etag": "str", # Optional. Operation ETag. - "lastActionDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the operation status was last updated. + "lastActionDateTime": "2020-02-20 00:00:00", # Required. Date and time in + UTC when the operation status was last updated. "operationId": "str", # Required. Operation Id. - "resourceLocation": "str", # Optional. Location of the imported update when operation is successful. - "status": "str", # Required. Operation status. Possible values include: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". - "traceId": "str", # Optional. Operation correlation identity that can used by Microsoft Support for troubleshooting. + "resourceLocation": "str", # Optional. Location of the imported update when + operation is successful. + "status": "str", # Required. Operation status. Known values are: + "Undefined", "NotStarted", "Running", "Succeeded", "Failed". + "traceId": "str", # Optional. Operation correlation identity that can used + by Microsoft Support for troubleshooting. "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. @@ -1292,13 +1462,16 @@ async def get_operation( } } """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[JSONType]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[JSON]] request = build_device_update_get_operation_request( @@ -1306,13 +1479,19 @@ async def get_operation( operation_id=operation_id, api_version=api_version, if_none_match=if_none_match, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -1334,39 +1513,35 @@ async def get_operation( return deserialized - get_operation.metadata = {'url': '/deviceupdate/{instanceId}/updates/operations/{operationId}'} # type: ignore -class DeviceManagementOperations: - """DeviceManagementOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeviceManagementOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.iot.deviceupdate.aio.DeviceUpdateClient`'s + :attr:`device_management` attribute. """ - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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[JSONType]: + ) -> AsyncIterable[JSON]: """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 api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.async_paging.AsyncItemPaged[JSONType] + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -1383,42 +1558,53 @@ def list_device_classes( "version": "str" # Required. Update version. }, "compatProperties": { - "str": "str" # Required. The compat properties of the device class. This object can be thought of as a set of key-value pairs where the key is the name of the compatibility property and the value is the value of the compatibility property. There will always be at least 1 compat property. + "str": "str" # Required. The compat properties of + the device class. This object can be thought of as a set of key-value + pairs where the key is the name of the compatibility property and the + value is the value of the compatibility property. There will always + be at least 1 compat property. }, - "deviceClassId": "str" # Required. The device class identifier. + "deviceClassId": "str" # Required. The device class + identifier. } ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_device_management_list_device_classes_request( instance_id=self._config.instance_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_management_list_device_classes_request( instance_id=self._config.instance_id, - api_version=api_version, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -1427,7 +1613,7 @@ def prepare_request(next_link=None): return request async def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -1436,7 +1622,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1449,23 +1639,20 @@ async def get_next(next_link=None): 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 - ) -> JSONType: + ) -> JSON: """Gets the properties of a device class. :param device_class_id: Device class identifier. :type device_class_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -1479,31 +1666,43 @@ async def get_device_class( "version": "str" # Required. Update version. }, "compatProperties": { - "str": "str" # Required. The compat properties of the device class. This object can be thought of as a set of key-value pairs where the key is the name of the compatibility property and the value is the value of the compatibility property. There will always be at least 1 compat property. + "str": "str" # Required. The compat properties of the device class. + This object can be thought of as a set of key-value pairs where the key is + the name of the compatibility property and the value is the value of the + compatibility property. There will always be at least 1 compat property. }, "deviceClassId": "str" # Required. The device class identifier. } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_get_device_class_request( instance_id=self._config.instance_id, device_class_id=device_class_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -1516,11 +1715,10 @@ async def get_device_class( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - get_device_class.metadata = {'url': '/deviceupdate/{instanceId}/management/deviceclasses/{deviceClassId}'} # type: ignore @distributed_trace @@ -1528,16 +1726,13 @@ def list_installable_updates_for_device_class( self, device_class_id: str, **kwargs: Any - ) -> AsyncIterable[JSONType]: + ) -> AsyncIterable[JSON]: """Gets a list of installable updates for a device class. :param device_class_id: Device class identifier. :type device_class_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.async_paging.AsyncItemPaged[JSONType] + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -1555,13 +1750,16 @@ def list_installable_updates_for_device_class( ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1569,23 +1767,26 @@ def prepare_request(next_link=None): instance_id=self._config.instance_id, device_class_id=device_class_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_management_list_installable_updates_for_device_class_request( instance_id=self._config.instance_id, device_class_id=device_class_id, - api_version=api_version, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -1594,7 +1795,7 @@ def prepare_request(next_link=None): return request async def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -1603,7 +1804,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1616,7 +1821,7 @@ async def get_next(next_link=None): 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( @@ -1624,17 +1829,14 @@ def list_devices( *, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[JSONType]: + ) -> AsyncIterable[JSON]: """Gets a list of devices connected to Device Update for IoT Hub. :keyword filter: Restricts the set of devices returned. You can filter on device GroupId or - DeviceClassId. + DeviceClassId. Default value is None. :paramtype filter: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.async_paging.AsyncItemPaged[JSONType] + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -1645,7 +1847,9 @@ def list_devices( "nextLink": "str", # Optional. The link to the next page of items. "value": [ { - "deploymentStatus": "str", # Optional. State of the device in its last deployment. Possible values include: "Succeeded", "InProgress", "Failed", "Canceled", "Incompatible". + "deploymentStatus": "str", # Optional. State of the device + in its last deployment. Known values are: "Succeeded", "InProgress", + "Failed", "Canceled", "Incompatible". "deviceClassId": "str", # Required. Device class identity. "deviceId": "str", # Required. Device identity. "groupId": "str", # Optional. Device group identity. @@ -1659,21 +1863,31 @@ def list_devices( "provider": "str", # Required. Update provider. "version": "str" # Required. Update version. }, - "lastDeploymentId": "str", # Optional. The deployment identifier for the last deployment to the device. + "lastDeploymentId": "str", # Optional. The deployment + identifier for the last deployment to the device. "lastInstallResult": { - "extendedResultCode": 0, # Required. Install extended result code. + "extendedResultCode": 0, # Required. Install + extended result code. "resultCode": 0, # Required. Install result code. - "resultDetails": "str", # Optional. A string containing further details about the install result. + "resultDetails": "str", # Optional. A string + containing further details about the install result. "stepResults": [ { - "description": "str", # Optional. Step description. It might be null for update steps. - "extendedResultCode": 0, # Required. Install extended result code. - "resultCode": 0, # Required. Install result code. - "resultDetails": "str", # Optional. A string containing further details about the install result. + "description": "str", # Optional. + Step description. It might be null for update steps. + "extendedResultCode": 0, # Required. + Install extended result code. + "resultCode": 0, # Required. Install + result code. + "resultDetails": "str", # Optional. + A string containing further details about the install result. "updateId": { - "name": "str", # Required. Update name. - "provider": "str", # Required. Update provider. - "version": "str" # Required. Update version. + "name": "str", # Required. + Update name. + "provider": "str", # + Required. Update provider. + "version": "str" # Required. + Update version. } } ] @@ -1681,18 +1895,22 @@ def list_devices( "manufacturer": "str", # Required. Device manufacturer. "model": "str", # Required. Device model. "moduleId": "str", # Optional. Device module identity. - "onLatestUpdate": bool # Required. Boolean flag indicating whether the latest update is installed on the device. + "onLatestUpdate": bool # Required. Boolean flag indicating + whether the latest update is installed on the device. } ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1700,23 +1918,25 @@ def prepare_request(next_link=None): instance_id=self._config.instance_id, api_version=api_version, filter=filter, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_management_list_devices_request( instance_id=self._config.instance_id, - api_version=api_version, - filter=filter, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -1725,7 +1945,7 @@ def prepare_request(next_link=None): return request async def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -1734,7 +1954,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1747,23 +1971,26 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_devices.metadata = {'url': '/deviceupdate/{instanceId}/management/devices'} # type: ignore - async def _import_devices_initial( + + async def _import_devices_initial( # pylint: disable=inconsistent-return-statements self, import_type: str, *, action: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = import_type @@ -1773,13 +2000,19 @@ async def _import_devices_initial( content_type=content_type, action=action, json=_json, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -1793,11 +2026,10 @@ async def _import_devices_initial( if cls: return cls(pipeline_response, None, response_headers) - _import_devices_initial.metadata = {'url': '/deviceupdate/{instanceId}/management/devices'} # type: ignore @distributed_trace_async - async def begin_import_devices( + async def begin_import_devices( # pylint: disable=inconsistent-return-statements self, import_type: str, *, @@ -1806,14 +2038,11 @@ async def begin_import_devices( ) -> AsyncLROPoller[None]: """Import existing devices from IoT Hub. - :param import_type: The types of devices to import. Possible values are: "Devices", "Modules", - and "All". + :param import_type: The types of devices to import. Known values are: "Devices", "Modules", and + "All". :type import_type: str :keyword action: Devices action. "import" :paramtype action: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :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 @@ -1825,22 +2054,27 @@ async def begin_import_devices( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _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', "2021-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # 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_devices_initial( + raw_result = await self._import_devices_initial( # type: ignore import_type=import_type, action=action, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1854,8 +2088,14 @@ def get_long_running_output(pipeline_response): "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - if polling is True: polling_method = AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -1864,27 +2104,23 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + - begin_import_devices.metadata = {'url': '/deviceupdate/{instanceId}/management/devices'} # type: ignore @distributed_trace_async async def get_device( self, device_id: str, **kwargs: Any - ) -> JSONType: + ) -> JSON: """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. :type device_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -1892,7 +2128,9 @@ async def get_device( # response body for status code(s): 200 response.json() == { - "deploymentStatus": "str", # Optional. State of the device in its last deployment. Possible values include: "Succeeded", "InProgress", "Failed", "Canceled", "Incompatible". + "deploymentStatus": "str", # Optional. State of the device in its last + deployment. Known values are: "Succeeded", "InProgress", "Failed", "Canceled", + "Incompatible". "deviceClassId": "str", # Required. Device class identity. "deviceId": "str", # Required. Device identity. "groupId": "str", # Optional. Device group identity. @@ -1906,20 +2144,26 @@ async def get_device( "provider": "str", # Required. Update provider. "version": "str" # Required. Update version. }, - "lastDeploymentId": "str", # Optional. The deployment identifier for the last deployment to the device. + "lastDeploymentId": "str", # Optional. The deployment identifier for the + last deployment to the device. "lastInstallResult": { "extendedResultCode": 0, # Required. Install extended result code. "resultCode": 0, # Required. Install result code. - "resultDetails": "str", # Optional. A string containing further details about the install result. + "resultDetails": "str", # Optional. A string containing further + details about the install result. "stepResults": [ { - "description": "str", # Optional. Step description. It might be null for update steps. - "extendedResultCode": 0, # Required. Install extended result code. + "description": "str", # Optional. Step description. + It might be null for update steps. + "extendedResultCode": 0, # Required. Install + extended result code. "resultCode": 0, # Required. Install result code. - "resultDetails": "str", # Optional. A string containing further details about the install result. + "resultDetails": "str", # Optional. A string + containing further details about the install result. "updateId": { "name": "str", # Required. Update name. - "provider": "str", # Required. Update provider. + "provider": "str", # Required. Update + provider. "version": "str" # Required. Update version. } } @@ -1928,29 +2172,39 @@ async def get_device( "manufacturer": "str", # Required. Device manufacturer. "model": "str", # Required. Device model. "moduleId": "str", # Optional. Device module identity. - "onLatestUpdate": bool # Required. Boolean flag indicating whether the latest update is installed on the device. + "onLatestUpdate": bool # Required. Boolean flag indicating whether the + latest update is installed on the device. } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_get_device_request( instance_id=self._config.instance_id, device_id=device_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -1963,11 +2217,10 @@ async def get_device( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - get_device.metadata = {'url': '/deviceupdate/{instanceId}/management/devices/{deviceId}'} # type: ignore @distributed_trace_async @@ -1976,7 +2229,7 @@ async def get_device_module( device_id: str, module_id: str, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Gets the device module properties and latest deployment status for a device module connected to Device Update for IoT Hub. @@ -1984,11 +2237,8 @@ async def get_device_module( :type device_id: str :param module_id: Device module identifier in Azure IoT Hub. :type module_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -1996,7 +2246,9 @@ async def get_device_module( # response body for status code(s): 200 response.json() == { - "deploymentStatus": "str", # Optional. State of the device in its last deployment. Possible values include: "Succeeded", "InProgress", "Failed", "Canceled", "Incompatible". + "deploymentStatus": "str", # Optional. State of the device in its last + deployment. Known values are: "Succeeded", "InProgress", "Failed", "Canceled", + "Incompatible". "deviceClassId": "str", # Required. Device class identity. "deviceId": "str", # Required. Device identity. "groupId": "str", # Optional. Device group identity. @@ -2010,20 +2262,26 @@ async def get_device_module( "provider": "str", # Required. Update provider. "version": "str" # Required. Update version. }, - "lastDeploymentId": "str", # Optional. The deployment identifier for the last deployment to the device. + "lastDeploymentId": "str", # Optional. The deployment identifier for the + last deployment to the device. "lastInstallResult": { "extendedResultCode": 0, # Required. Install extended result code. "resultCode": 0, # Required. Install result code. - "resultDetails": "str", # Optional. A string containing further details about the install result. + "resultDetails": "str", # Optional. A string containing further + details about the install result. "stepResults": [ { - "description": "str", # Optional. Step description. It might be null for update steps. - "extendedResultCode": 0, # Required. Install extended result code. + "description": "str", # Optional. Step description. + It might be null for update steps. + "extendedResultCode": 0, # Required. Install + extended result code. "resultCode": 0, # Required. Install result code. - "resultDetails": "str", # Optional. A string containing further details about the install result. + "resultDetails": "str", # Optional. A string + containing further details about the install result. "updateId": { "name": "str", # Required. Update name. - "provider": "str", # Required. Update provider. + "provider": "str", # Required. Update + provider. "version": "str" # Required. Update version. } } @@ -2032,16 +2290,20 @@ async def get_device_module( "manufacturer": "str", # Required. Device manufacturer. "model": "str", # Required. Device model. "moduleId": "str", # Optional. Device module identity. - "onLatestUpdate": bool # Required. Boolean flag indicating whether the latest update is installed on the device. + "onLatestUpdate": bool # Required. Boolean flag indicating whether the + latest update is installed on the device. } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_get_device_module_request( @@ -2049,13 +2311,19 @@ async def get_device_module( device_id=device_id, module_id=module_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -2068,26 +2336,22 @@ async def get_device_module( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, 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 - ) -> JSONType: + ) -> JSON: """Gets the breakdown of how many devices are on their latest update, have new updates available, or are in progress receiving new updates. - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -2095,31 +2359,43 @@ async def get_update_compliance( # response body for status code(s): 200 response.json() == { - "newUpdatesAvailableDeviceCount": 0, # Required. Number of devices with a newer update available. - "onLatestUpdateDeviceCount": 0, # Required. Number of devices on the latest update. + "newUpdatesAvailableDeviceCount": 0, # Required. Number of devices with a + newer update available. + "onLatestUpdateDeviceCount": 0, # Required. Number of devices on the latest + update. "totalDeviceCount": 0, # Required. Total number of devices. - "updatesInProgressDeviceCount": 0 # Required. Number of devices with update in-progress. + "updatesInProgressDeviceCount": 0 # Required. Number of devices with update + in-progress. } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_get_update_compliance_request( instance_id=self._config.instance_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -2132,26 +2408,22 @@ async def get_update_compliance( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - get_update_compliance.metadata = {'url': '/deviceupdate/{instanceId}/management/updatecompliance'} # type: ignore @distributed_trace def list_device_tags( self, **kwargs: Any - ) -> AsyncIterable[JSONType]: + ) -> AsyncIterable[JSON]: """Gets a list of available group device tags for all devices connected to Device Update for IoT Hub. - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.async_paging.AsyncItemPaged[JSONType] + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -2162,41 +2434,48 @@ def list_device_tags( "nextLink": "str", # Optional. The link to the next page of items. "value": [ { - "deviceCount": 0, # Required. Number of devices with this tag. + "deviceCount": 0, # Required. Number of devices with this + tag. "tagName": "str" # Required. Tag name. } ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_device_management_list_device_tags_request( instance_id=self._config.instance_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_management_list_device_tags_request( instance_id=self._config.instance_id, - api_version=api_version, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -2205,7 +2484,7 @@ def prepare_request(next_link=None): return request async def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -2214,7 +2493,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2227,23 +2510,20 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_device_tags.metadata = {'url': '/deviceupdate/{instanceId}/management/devicetags'} # type: ignore + @distributed_trace_async async def get_device_tag( self, tag_name: str, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Gets a count of how many devices have a device tag. :param tag_name: Tag name. :type tag_name: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -2255,26 +2535,35 @@ async def get_device_tag( "tagName": "str" # Required. Tag name. } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_get_device_tag_request( instance_id=self._config.instance_id, tag_name=tag_name, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -2287,25 +2576,21 @@ async def get_device_tag( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - get_device_tag.metadata = {'url': '/deviceupdate/{instanceId}/management/devicetags/{tagName}'} # type: ignore @distributed_trace def list_groups( self, **kwargs: Any - ) -> AsyncIterable[JSONType]: + ) -> AsyncIterable[JSON]: """Gets a list of all device groups. - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.async_paging.AsyncItemPaged[JSONType] + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -2316,12 +2601,18 @@ def list_groups( "nextLink": "str", # Optional. The link to the next page of items. "value": [ { - "createdDateTime": "str", # Required. Date and time when the update was created. - "deploymentId": "str", # Optional. The deployment Id for the group. - "deviceClassId": "str", # Optional. The device class Id for the group. - "deviceCount": 0, # Optional. The number of devices in the group. + "createdDateTime": "str", # Required. Date and time when the + update was created. + "deploymentId": "str", # Optional. The deployment Id for the + group. + "deviceClassId": "str", # Optional. The device class Id for + the group. + "deviceCount": 0, # Optional. The number of devices in the + group. "groupId": "str", # Required. Group identity. - "groupType": "str", # Required. Group type. Possible values include: "DeviceClassIdAndIoTHubTag", "InvalidDeviceClassIdAndIoTHubTag", "DefaultDeviceClassId". + "groupType": "str", # Required. Group type. Known values + are: "DeviceClassIdAndIoTHubTag", "InvalidDeviceClassIdAndIoTHubTag", + "DefaultDeviceClassId". "tags": [ "str" # Required. A set of tags. IoT Hub tags. ] @@ -2329,35 +2620,41 @@ def list_groups( ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_device_management_list_groups_request( instance_id=self._config.instance_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_management_list_groups_request( instance_id=self._config.instance_id, - api_version=api_version, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -2366,7 +2663,7 @@ def prepare_request(next_link=None): return request async def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -2375,7 +2672,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2388,23 +2689,20 @@ async def get_next(next_link=None): 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 - ) -> JSONType: + ) -> JSON: """Gets the properties of a group. :param group_id: Group identity. :type group_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -2412,37 +2710,49 @@ async def get_group( # response body for status code(s): 200 response.json() == { - "createdDateTime": "str", # Required. Date and time when the update was created. + "createdDateTime": "str", # Required. Date and time when the update was + created. "deploymentId": "str", # Optional. The deployment Id for the group. "deviceClassId": "str", # Optional. The device class Id for the group. "deviceCount": 0, # Optional. The number of devices in the group. "groupId": "str", # Required. Group identity. - "groupType": "str", # Required. Group type. Possible values include: "DeviceClassIdAndIoTHubTag", "InvalidDeviceClassIdAndIoTHubTag", "DefaultDeviceClassId". + "groupType": "str", # Required. Group type. Known values are: + "DeviceClassIdAndIoTHubTag", "InvalidDeviceClassIdAndIoTHubTag", + "DefaultDeviceClassId". "tags": [ "str" # Required. A set of tags. IoT Hub tags. ] } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_get_group_request( instance_id=self._config.instance_id, group_id=group_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -2455,31 +2765,27 @@ async def get_group( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - get_group.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}'} # type: ignore @distributed_trace_async async def create_or_update_group( self, group_id: str, - group: JSONType, + group: JSON, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Create or update a device group. :param group_id: Group identity. :type group_id: str :param group: The group properties. - :type group: JSONType - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str + :type group: JSON :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -2487,12 +2793,15 @@ async def create_or_update_group( # JSON input template you can fill out and use as your body input. group = { - "createdDateTime": "str", # Required. Date and time when the update was created. + "createdDateTime": "str", # Required. Date and time when the update was + created. "deploymentId": "str", # Optional. The deployment Id for the group. "deviceClassId": "str", # Optional. The device class Id for the group. "deviceCount": 0, # Optional. The number of devices in the group. "groupId": "str", # Required. Group identity. - "groupType": "str", # Required. Group type. Possible values include: "DeviceClassIdAndIoTHubTag", "InvalidDeviceClassIdAndIoTHubTag", "DefaultDeviceClassId". + "groupType": "str", # Required. Group type. Known values are: + "DeviceClassIdAndIoTHubTag", "InvalidDeviceClassIdAndIoTHubTag", + "DefaultDeviceClassId". "tags": [ "str" # Required. A set of tags. IoT Hub tags. ] @@ -2500,25 +2809,31 @@ async def create_or_update_group( # response body for status code(s): 200 response.json() == { - "createdDateTime": "str", # Required. Date and time when the update was created. + "createdDateTime": "str", # Required. Date and time when the update was + created. "deploymentId": "str", # Optional. The deployment Id for the group. "deviceClassId": "str", # Optional. The device class Id for the group. "deviceCount": 0, # Optional. The number of devices in the group. "groupId": "str", # Required. Group identity. - "groupType": "str", # Required. Group type. Possible values include: "DeviceClassIdAndIoTHubTag", "InvalidDeviceClassIdAndIoTHubTag", "DefaultDeviceClassId". + "groupType": "str", # Required. Group type. Known values are: + "DeviceClassIdAndIoTHubTag", "InvalidDeviceClassIdAndIoTHubTag", + "DefaultDeviceClassId". "tags": [ "str" # Required. A set of tags. IoT Hub tags. ] } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _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', "2021-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[JSON] _json = group @@ -2528,13 +2843,19 @@ async def create_or_update_group( api_version=api_version, content_type=content_type, json=_json, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -2547,15 +2868,14 @@ async def create_or_update_group( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - create_or_update_group.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}'} # type: ignore @distributed_trace_async - async def delete_group( + async def delete_group( # pylint: disable=inconsistent-return-statements self, group_id: str, **kwargs: Any @@ -2564,33 +2884,39 @@ async def delete_group( :param group_id: Group identity. :type group_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: None :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_device_management_delete_group_request( instance_id=self._config.instance_id, group_id=group_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -2600,7 +2926,6 @@ async def delete_group( if cls: return cls(pipeline_response, None, {}) - delete_group.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}'} # type: ignore @distributed_trace_async @@ -2608,17 +2933,14 @@ async def get_group_update_compliance( self, group_id: str, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Get 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. :type group_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -2626,32 +2948,44 @@ async def get_group_update_compliance( # response body for status code(s): 200 response.json() == { - "newUpdatesAvailableDeviceCount": 0, # Required. Number of devices with a newer update available. - "onLatestUpdateDeviceCount": 0, # Required. Number of devices on the latest update. + "newUpdatesAvailableDeviceCount": 0, # Required. Number of devices with a + newer update available. + "onLatestUpdateDeviceCount": 0, # Required. Number of devices on the latest + update. "totalDeviceCount": 0, # Required. Total number of devices. - "updatesInProgressDeviceCount": 0 # Required. Number of devices with update in-progress. + "updatesInProgressDeviceCount": 0 # Required. Number of devices with update + in-progress. } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_get_group_update_compliance_request( instance_id=self._config.instance_id, group_id=group_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -2664,11 +2998,10 @@ async def get_group_update_compliance( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - get_group_update_compliance.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}/updateCompliance'} # type: ignore @distributed_trace @@ -2678,19 +3011,16 @@ def list_best_updates_for_group( *, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[JSONType]: + ) -> AsyncIterable[JSON]: """Get the best available updates for a group and a count of how many devices need each update. :param group_id: Group identity. :type group_id: str :keyword filter: Restricts the set of bestUpdates returned. You can filter on update Provider, - Name and Version property. + Name and Version property. Default value is None. :paramtype filter: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.async_paging.AsyncItemPaged[JSONType] + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -2701,7 +3031,8 @@ def list_best_updates_for_group( "nextLink": "str", # Optional. The link to the next page of items. "value": [ { - "deviceCount": 0, # Required. Total number of devices for which the update is applicable. + "deviceCount": 0, # Required. Total number of devices for + which the update is applicable. "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. @@ -2711,13 +3042,16 @@ def list_best_updates_for_group( ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2726,24 +3060,26 @@ def prepare_request(next_link=None): group_id=group_id, api_version=api_version, filter=filter, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_management_list_best_updates_for_group_request( instance_id=self._config.instance_id, group_id=group_id, - api_version=api_version, - filter=filter, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -2752,7 +3088,7 @@ def prepare_request(next_link=None): return request async def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -2761,7 +3097,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2774,7 +3114,7 @@ async def get_next(next_link=None): 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( @@ -2783,19 +3123,16 @@ def list_deployments_for_group( *, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[JSONType]: + ) -> AsyncIterable[JSON]: """Gets a list of deployments for a group. :param group_id: Group identity. :type group_id: str :keyword filter: Restricts the set of deployments returned. You can filter on update Provider, - Name and Version property. + Name and Version property. Default value is None. :paramtype filter: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.async_paging.AsyncItemPaged[JSONType] + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -2806,11 +3143,15 @@ def list_deployments_for_group( "nextLink": "str", # Optional. The link to the next page of items. "value": [ { - "deploymentId": "str", # Required. The deployment identifier. + "deploymentId": "str", # Required. The deployment + identifier. "groupId": "str", # Required. The group identity. - "isCanceled": bool, # Optional. Boolean flag indicating whether the deployment was canceled. - "isRetried": bool, # Optional. Boolean flag indicating whether the deployment has been retried. - "startDateTime": "2020-02-20 00:00:00", # Required. The deployment start datetime. + "isCanceled": bool, # Optional. Boolean flag indicating + whether the deployment was canceled. + "isRetried": bool, # Optional. Boolean flag indicating + whether the deployment has been retried. + "startDateTime": "2020-02-20 00:00:00", # Required. The + deployment start datetime. "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. @@ -2820,13 +3161,16 @@ def list_deployments_for_group( ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2835,24 +3179,26 @@ def prepare_request(next_link=None): group_id=group_id, api_version=api_version, filter=filter, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_management_list_deployments_for_group_request( instance_id=self._config.instance_id, group_id=group_id, - api_version=api_version, - filter=filter, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -2861,7 +3207,7 @@ def prepare_request(next_link=None): return request async def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -2870,7 +3216,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2883,7 +3233,7 @@ async def get_next(next_link=None): 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( @@ -2891,18 +3241,15 @@ async def get_deployment( group_id: str, deployment_id: str, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Gets the properties of a deployment. :param group_id: Group identity. :type group_id: str :param deployment_id: Deployment identifier. :type deployment_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -2912,9 +3259,12 @@ async def get_deployment( response.json() == { "deploymentId": "str", # Required. The deployment identifier. "groupId": "str", # Required. The group identity. - "isCanceled": bool, # Optional. Boolean flag indicating whether the deployment was canceled. - "isRetried": bool, # Optional. Boolean flag indicating whether the deployment has been retried. - "startDateTime": "2020-02-20 00:00:00", # Required. The deployment start datetime. + "isCanceled": bool, # Optional. Boolean flag indicating whether the + deployment was canceled. + "isRetried": bool, # Optional. Boolean flag indicating whether the + deployment has been retried. + "startDateTime": "2020-02-20 00:00:00", # Required. The deployment start + datetime. "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. @@ -2922,13 +3272,16 @@ async def get_deployment( } } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_get_deployment_request( @@ -2936,13 +3289,19 @@ async def get_deployment( group_id=group_id, deployment_id=deployment_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -2955,11 +3314,10 @@ async def get_deployment( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - get_deployment.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}'} # type: ignore @distributed_trace_async @@ -2967,9 +3325,9 @@ async def create_or_update_deployment( self, deployment_id: str, group_id: str, - deployment: JSONType, + deployment: JSON, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Creates or updates a deployment. :param deployment_id: Deployment identifier. @@ -2977,12 +3335,9 @@ async def create_or_update_deployment( :param group_id: Group identity. :type group_id: str :param deployment: The deployment properties. - :type deployment: JSONType - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str + :type deployment: JSON :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -2992,9 +3347,12 @@ async def create_or_update_deployment( deployment = { "deploymentId": "str", # Required. The deployment identifier. "groupId": "str", # Required. The group identity. - "isCanceled": bool, # Optional. Boolean flag indicating whether the deployment was canceled. - "isRetried": bool, # Optional. Boolean flag indicating whether the deployment has been retried. - "startDateTime": "2020-02-20 00:00:00", # Required. The deployment start datetime. + "isCanceled": bool, # Optional. Boolean flag indicating whether the + deployment was canceled. + "isRetried": bool, # Optional. Boolean flag indicating whether the + deployment has been retried. + "startDateTime": "2020-02-20 00:00:00", # Required. The deployment start + datetime. "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. @@ -3006,9 +3364,12 @@ async def create_or_update_deployment( response.json() == { "deploymentId": "str", # Required. The deployment identifier. "groupId": "str", # Required. The group identity. - "isCanceled": bool, # Optional. Boolean flag indicating whether the deployment was canceled. - "isRetried": bool, # Optional. Boolean flag indicating whether the deployment has been retried. - "startDateTime": "2020-02-20 00:00:00", # Required. The deployment start datetime. + "isCanceled": bool, # Optional. Boolean flag indicating whether the + deployment was canceled. + "isRetried": bool, # Optional. Boolean flag indicating whether the + deployment has been retried. + "startDateTime": "2020-02-20 00:00:00", # Required. The deployment start + datetime. "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. @@ -3016,14 +3377,17 @@ async def create_or_update_deployment( } } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[JSON] _json = deployment @@ -3034,13 +3398,19 @@ async def create_or_update_deployment( api_version=api_version, content_type=content_type, json=_json, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -3053,15 +3423,14 @@ async def create_or_update_deployment( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - create_or_update_deployment.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}'} # type: ignore @distributed_trace_async - async def delete_deployment( + async def delete_deployment( # pylint: disable=inconsistent-return-statements self, group_id: str, deployment_id: str, @@ -3073,20 +3442,20 @@ async def delete_deployment( :type group_id: str :param deployment_id: Deployment identifier. :type deployment_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: None :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_device_management_delete_deployment_request( @@ -3094,13 +3463,19 @@ async def delete_deployment( group_id=group_id, deployment_id=deployment_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -3110,7 +3485,6 @@ async def delete_deployment( if cls: return cls(pipeline_response, None, {}) - delete_deployment.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}'} # type: ignore @distributed_trace_async @@ -3119,7 +3493,7 @@ async def get_deployment_status( group_id: str, deployment_id: str, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Gets the status of a deployment including a breakdown of how many devices in the deployment are in progress, completed, or failed. @@ -3127,11 +3501,8 @@ async def get_deployment_status( :type group_id: str :param deployment_id: Deployment identifier. :type deployment_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -3139,21 +3510,29 @@ async def get_deployment_status( # response body for status code(s): 200 response.json() == { - "deploymentState": "str", # Required. The state of the deployment. Possible values include: "Active", "Inactive", "Canceled". - "devicesCanceledCount": 0, # Optional. The number of devices which have had their deployment canceled. - "devicesCompletedFailedCount": 0, # Optional. The number of devices that have completed deployment with a failure. - "devicesCompletedSucceededCount": 0, # Optional. The number of devices which have successfully completed deployment. - "devicesInProgressCount": 0, # Optional. The number of devices that are currently in deployment. + "deploymentState": "str", # Required. The state of the deployment. Known + values are: "Active", "Inactive", "Canceled". + "devicesCanceledCount": 0, # Optional. The number of devices which have had + their deployment canceled. + "devicesCompletedFailedCount": 0, # Optional. The number of devices that + have completed deployment with a failure. + "devicesCompletedSucceededCount": 0, # Optional. The number of devices which + have successfully completed deployment. + "devicesInProgressCount": 0, # Optional. The number of devices that are + currently in deployment. "totalDevices": 0 # Optional. The total number of devices in the deployment. } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_get_deployment_status_request( @@ -3161,13 +3540,19 @@ async def get_deployment_status( group_id=group_id, deployment_id=deployment_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -3180,11 +3565,10 @@ async def get_deployment_status( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - get_deployment_status.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}/status'} # type: ignore @distributed_trace @@ -3195,7 +3579,7 @@ def list_deployment_devices( *, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[JSONType]: + ) -> AsyncIterable[JSON]: """Gets a list of devices in a deployment along with their state. Useful for getting a list of failed devices. @@ -3204,13 +3588,10 @@ def list_deployment_devices( :param deployment_id: Deployment identifier. :type deployment_id: str :keyword filter: Restricts the set of deployment device states returned. You can filter on - deviceId and moduleId and/or deviceState. + deviceId and moduleId and/or deviceState. Default value is None. :paramtype filter: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.async_paging.AsyncItemPaged[JSONType] + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -3222,21 +3603,29 @@ def list_deployment_devices( "value": [ { "deviceId": "str", # Required. Device identity. - "deviceState": "str", # Required. Deployment device state. Possible values include: "Succeeded", "InProgress", "Failed", "Canceled", "Incompatible". + "deviceState": "str", # Required. Deployment device state. + Known values are: "Succeeded", "InProgress", "Failed", "Canceled", + "Incompatible". "moduleId": "str", # Optional. Device module identity. - "movedOnToNewDeployment": bool, # Required. Boolean flag indicating whether this device is in a newer deployment and can no longer retry this deployment. - "retryCount": 0 # Required. The number of times this deployment has been retried on this device. + "movedOnToNewDeployment": bool, # Required. Boolean flag + indicating whether this device is in a newer deployment and can no longer + retry this deployment. + "retryCount": 0 # Required. The number of times this + deployment has been retried on this device. } ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -3246,11 +3635,13 @@ def prepare_request(next_link=None): deployment_id=deployment_id, api_version=api_version, filter=filter, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: @@ -3258,13 +3649,13 @@ def prepare_request(next_link=None): instance_id=self._config.instance_id, group_id=group_id, deployment_id=deployment_id, - api_version=api_version, - filter=filter, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -3273,7 +3664,7 @@ def prepare_request(next_link=None): return request async def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -3282,7 +3673,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -3295,7 +3690,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_deployment_devices.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}/devicestates'} # type: ignore + @distributed_trace_async async def get_operation( @@ -3304,19 +3699,16 @@ async def get_operation( *, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional[JSONType]: + ) -> Optional[JSON]: """Retrieve operation status. :param operation_id: Operation identifier. :type operation_id: str :keyword if_none_match: Defines the If-None-Match condition. The operation will be performed - only if the ETag on the server does not match this value. + only if the ETag on the server does not match this value. Default value is None. :paramtype if_none_match: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType or None + :rtype: JSON or None :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -3324,36 +3716,48 @@ async def get_operation( # response body for status code(s): 200 response.json() == { - "createdDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the operation was created. + "createdDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC + when the operation was created. "error": { "code": "str", # Required. Server defined error code. "details": [ ... ], "innererror": { - "code": "str", # Required. A more specific error code than what was provided by the containing error. - "errorDetail": "str", # Optional. The internal error or exception message. + "code": "str", # Required. A more specific error code than + what was provided by the containing error. + "errorDetail": "str", # Optional. The internal error or + exception message. "innerError": ..., - "message": "str" # Optional. A human-readable representation of the error. + "message": "str" # Optional. A human-readable representation + of the error. }, - "message": "str", # Required. A human-readable representation of the error. - "occurredDateTime": "2020-02-20 00:00:00", # Optional. Date and time in UTC when the error occurred. + "message": "str", # Required. A human-readable representation of the + error. + "occurredDateTime": "2020-02-20 00:00:00", # Optional. Date and time + in UTC when the error occurred. "target": "str" # Optional. The target of the error. }, "etag": "str", # Optional. Operation ETag. - "lastActionDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the operation status was last updated. + "lastActionDateTime": "2020-02-20 00:00:00", # Required. Date and time in + UTC when the operation status was last updated. "operationId": "str", # Required. Operation Id. - "status": "str", # Required. Operation status. Possible values include: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". - "traceId": "str" # Optional. Operation correlation identity that can used by Microsoft Support for troubleshooting. + "status": "str", # Required. Operation status. Known values are: + "Undefined", "NotStarted", "Running", "Succeeded", "Failed". + "traceId": "str" # Optional. Operation correlation identity that can used by + Microsoft Support for troubleshooting. } """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[JSONType]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[JSON]] request = build_device_management_get_operation_request( @@ -3361,13 +3765,19 @@ async def get_operation( operation_id=operation_id, api_version=api_version, if_none_match=if_none_match, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -3389,7 +3799,6 @@ async def get_operation( return deserialized - get_operation.metadata = {'url': '/deviceupdate/{instanceId}/management/operations/{operationId}'} # type: ignore @distributed_trace @@ -3399,22 +3808,19 @@ def list_operations( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[JSONType]: + ) -> AsyncIterable[JSON]: """Get a list of all device import operations. Completed operations are kept for 7 days before auto-deleted. :keyword filter: Restricts the set of operations returned. Only one specific filter is - supported: "status eq 'NotStarted' or status eq 'Running'". + supported: "status eq 'NotStarted' or status eq 'Running'". Default value is None. :paramtype filter: str :keyword 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. + specified value n. Default value is None. :paramtype top: int - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.async_paging.AsyncItemPaged[JSONType] + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -3425,38 +3831,51 @@ def list_operations( "nextLink": "str", # Optional. The link to the next page of items. "value": [ { - "createdDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the operation was created. + "createdDateTime": "2020-02-20 00:00:00", # Required. Date + and time in UTC when the operation was created. "error": { - "code": "str", # Required. Server defined error code. + "code": "str", # Required. Server defined error + code. "details": [ ... ], "innererror": { - "code": "str", # Required. A more specific error code than what was provided by the containing error. - "errorDetail": "str", # Optional. The internal error or exception message. + "code": "str", # Required. A more specific + error code than what was provided by the containing error. + "errorDetail": "str", # Optional. The + internal error or exception message. "innerError": ..., - "message": "str" # Optional. A human-readable representation of the error. + "message": "str" # Optional. A + human-readable representation of the error. }, - "message": "str", # Required. A human-readable representation of the error. - "occurredDateTime": "2020-02-20 00:00:00", # Optional. Date and time in UTC when the error occurred. + "message": "str", # Required. A human-readable + representation of the error. + "occurredDateTime": "2020-02-20 00:00:00", # + Optional. Date and time in UTC when the error occurred. "target": "str" # Optional. The target of the error. }, "etag": "str", # Optional. Operation ETag. - "lastActionDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the operation status was last updated. + "lastActionDateTime": "2020-02-20 00:00:00", # Required. + Date and time in UTC when the operation status was last updated. "operationId": "str", # Required. Operation Id. - "status": "str", # Required. Operation status. Possible values include: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". - "traceId": "str" # Optional. Operation correlation identity that can used by Microsoft Support for troubleshooting. + "status": "str", # Required. Operation status. Known values + are: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". + "traceId": "str" # Optional. Operation correlation identity + that can used by Microsoft Support for troubleshooting. } ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -3465,24 +3884,25 @@ def prepare_request(next_link=None): api_version=api_version, filter=filter, top=top, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_management_list_operations_request( instance_id=self._config.instance_id, - api_version=api_version, - filter=filter, - top=top, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -3491,7 +3911,7 @@ def prepare_request(next_link=None): return request async def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -3500,7 +3920,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -3513,26 +3937,23 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_operations.metadata = {'url': '/deviceupdate/{instanceId}/management/operations'} # type: ignore + @distributed_trace_async async def collect_logs( self, operation_id: str, - log_collection_request: JSONType, + log_collection_request: JSON, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Start the device diagnostics log collection operation on specified devices. :param operation_id: Operation identifier. :type operation_id: str :param log_collection_request: The deployment properties. - :type log_collection_request: JSONType - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str + :type log_collection_request: JSON :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -3540,7 +3961,8 @@ async def collect_logs( # JSON input template you can fill out and use as your body input. log_collection_request = { - "createdDateTime": "str", # Optional. The timestamp when the operation was created. + "createdDateTime": "str", # Optional. The timestamp when the operation was + created. "description": "str", # Optional. Description of the diagnostics operation. "deviceList": [ { @@ -3548,14 +3970,17 @@ async def collect_logs( "moduleId": "str" # Optional. Module Id. } ], - "lastActionDateTime": "str", # Optional. A timestamp for when the current state was entered. + "lastActionDateTime": "str", # Optional. A timestamp for when the current + state was entered. "operationId": "str", # Optional. The diagnostics operation id. - "status": "str" # Optional. Operation status. Possible values include: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". + "status": "str" # Optional. Operation status. Known values are: "Undefined", + "NotStarted", "Running", "Succeeded", "Failed". } # response body for status code(s): 201 response.json() == { - "createdDateTime": "str", # Optional. The timestamp when the operation was created. + "createdDateTime": "str", # Optional. The timestamp when the operation was + created. "description": "str", # Optional. Description of the diagnostics operation. "deviceList": [ { @@ -3563,19 +3988,24 @@ async def collect_logs( "moduleId": "str" # Optional. Module Id. } ], - "lastActionDateTime": "str", # Optional. A timestamp for when the current state was entered. + "lastActionDateTime": "str", # Optional. A timestamp for when the current + state was entered. "operationId": "str", # Optional. The diagnostics operation id. - "status": "str" # Optional. Operation status. Possible values include: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". + "status": "str" # Optional. Operation status. Known values are: "Undefined", + "NotStarted", "Running", "Succeeded", "Failed". } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _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', "2021-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[JSON] _json = log_collection_request @@ -3585,13 +4015,19 @@ async def collect_logs( api_version=api_version, content_type=content_type, json=_json, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -3604,11 +4040,10 @@ async def collect_logs( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - collect_logs.metadata = {'url': '/deviceupdate/{instanceId}/management/deviceDiagnostics/logCollections/{operationId}'} # type: ignore @distributed_trace_async @@ -3616,16 +4051,13 @@ async def get_log_collection_operation( self, operation_id: str, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Get the device diagnostics log collection operation. :param operation_id: Operation identifier. :type operation_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -3633,7 +4065,8 @@ async def get_log_collection_operation( # response body for status code(s): 200 response.json() == { - "createdDateTime": "str", # Optional. The timestamp when the operation was created. + "createdDateTime": "str", # Optional. The timestamp when the operation was + created. "description": "str", # Optional. Description of the diagnostics operation. "deviceList": [ { @@ -3641,31 +4074,42 @@ async def get_log_collection_operation( "moduleId": "str" # Optional. Module Id. } ], - "lastActionDateTime": "str", # Optional. A timestamp for when the current state was entered. + "lastActionDateTime": "str", # Optional. A timestamp for when the current + state was entered. "operationId": "str", # Optional. The diagnostics operation id. - "status": "str" # Optional. Operation status. Possible values include: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". + "status": "str" # Optional. Operation status. Known values are: "Undefined", + "NotStarted", "Running", "Succeeded", "Failed". } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_get_log_collection_operation_request( instance_id=self._config.instance_id, operation_id=operation_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -3678,25 +4122,21 @@ async def get_log_collection_operation( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - get_log_collection_operation.metadata = {'url': '/deviceupdate/{instanceId}/management/deviceDiagnostics/logCollections/{operationId}'} # type: ignore @distributed_trace def list_log_collection_operations( self, **kwargs: Any - ) -> AsyncIterable[JSONType]: + ) -> AsyncIterable[JSON]: """Get all device diagnostics log collection operations. - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.async_paging.AsyncItemPaged[JSONType] + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -3707,50 +4147,61 @@ def list_log_collection_operations( "nextLink": "str", # Optional. The link to the next page of items. "value": [ { - "createdDateTime": "str", # Optional. The timestamp when the operation was created. - "description": "str", # Optional. Description of the diagnostics operation. + "createdDateTime": "str", # Optional. The timestamp when the + operation was created. + "description": "str", # Optional. Description of the + diagnostics operation. "deviceList": [ { "deviceId": "str", # Required. Device Id. "moduleId": "str" # Optional. Module Id. } ], - "lastActionDateTime": "str", # Optional. A timestamp for when the current state was entered. - "operationId": "str", # Optional. The diagnostics operation id. - "status": "str" # Optional. Operation status. Possible values include: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". + "lastActionDateTime": "str", # Optional. A timestamp for + when the current state was entered. + "operationId": "str", # Optional. The diagnostics operation + id. + "status": "str" # Optional. Operation status. Known values + are: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". } ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_device_management_list_log_collection_operations_request( instance_id=self._config.instance_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_management_list_log_collection_operations_request( instance_id=self._config.instance_id, - api_version=api_version, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -3759,7 +4210,7 @@ def prepare_request(next_link=None): return request async def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -3768,7 +4219,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -3781,23 +4236,20 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_log_collection_operations.metadata = {'url': '/deviceupdate/{instanceId}/management/deviceDiagnostics/logCollections'} # type: ignore + @distributed_trace_async async def get_log_collection_operation_detailed_status( self, operation_id: str, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Get device diagnostics log collection operation with detailed status. :param operation_id: Operation identifier. :type operation_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -3805,43 +4257,57 @@ async def get_log_collection_operation_detailed_status( # response body for status code(s): 200 response.json() == { - "createdDateTime": "str", # Optional. The timestamp when the operation was created. + "createdDateTime": "str", # Optional. The timestamp when the operation was + created. "description": "str", # Optional. Device diagnostics operation description. "deviceStatus": [ { "deviceId": "str", # Required. Device id. - "extendedResultCode": "str", # Optional. Log upload extended result code. + "extendedResultCode": "str", # Optional. Log upload extended + result code. "logLocation": "str", # Optional. Log upload location. "moduleId": "str", # Optional. Module id. "resultCode": "str", # Optional. Log upload result code. - "status": "str" # Required. Log upload status. Possible values include: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". + "status": "str" # Required. Log upload status. Known values + are: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". } ], - "lastActionDateTime": "str", # Optional. A timestamp for when the current state was entered. + "lastActionDateTime": "str", # Optional. A timestamp for when the current + state was entered. "operationId": "str", # Optional. The device diagnostics operation id. - "status": "str" # Optional. Operation status. Possible values include: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". + "status": "str" # Optional. Operation status. Known values are: "Undefined", + "NotStarted", "Running", "Succeeded", "Failed". } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_get_log_collection_operation_detailed_status_request( instance_id=self._config.instance_id, operation_id=operation_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -3854,11 +4320,10 @@ async def get_log_collection_operation_detailed_status( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - get_log_collection_operation_detailed_status.metadata = {'url': '/deviceupdate/{instanceId}/management/deviceDiagnostics/logCollections/{operationId}/detailedStatus'} # type: ignore @distributed_trace_async @@ -3869,7 +4334,7 @@ async def stop_deployment( *, action: str, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Stops a deployment. :param group_id: Group identity. @@ -3878,11 +4343,8 @@ async def stop_deployment( :type deployment_id: str :keyword action: Cancel deployment action. "cancel" :paramtype action: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -3892,9 +4354,12 @@ async def stop_deployment( response.json() == { "deploymentId": "str", # Required. The deployment identifier. "groupId": "str", # Required. The group identity. - "isCanceled": bool, # Optional. Boolean flag indicating whether the deployment was canceled. - "isRetried": bool, # Optional. Boolean flag indicating whether the deployment has been retried. - "startDateTime": "2020-02-20 00:00:00", # Required. The deployment start datetime. + "isCanceled": bool, # Optional. Boolean flag indicating whether the + deployment was canceled. + "isRetried": bool, # Optional. Boolean flag indicating whether the + deployment has been retried. + "startDateTime": "2020-02-20 00:00:00", # Required. The deployment start + datetime. "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. @@ -3902,13 +4367,16 @@ async def stop_deployment( } } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_stop_deployment_request( @@ -3917,13 +4385,19 @@ async def stop_deployment( deployment_id=deployment_id, api_version=api_version, action=action, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -3936,11 +4410,10 @@ async def stop_deployment( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - stop_deployment.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}'} # type: ignore @distributed_trace_async @@ -3951,7 +4424,7 @@ async def retry_deployment( *, action: str, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Retries a deployment with failed devices. :param group_id: Group identity. @@ -3960,11 +4433,8 @@ async def retry_deployment( :type deployment_id: str :keyword action: Retry deployment action. "retry" :paramtype action: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -3974,9 +4444,12 @@ async def retry_deployment( response.json() == { "deploymentId": "str", # Required. The deployment identifier. "groupId": "str", # Required. The group identity. - "isCanceled": bool, # Optional. Boolean flag indicating whether the deployment was canceled. - "isRetried": bool, # Optional. Boolean flag indicating whether the deployment has been retried. - "startDateTime": "2020-02-20 00:00:00", # Required. The deployment start datetime. + "isCanceled": bool, # Optional. Boolean flag indicating whether the + deployment was canceled. + "isRetried": bool, # Optional. Boolean flag indicating whether the + deployment has been retried. + "startDateTime": "2020-02-20 00:00:00", # Required. The deployment start + datetime. "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. @@ -3984,13 +4457,16 @@ async def retry_deployment( } } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_retry_deployment_request( @@ -3999,13 +4475,19 @@ async def retry_deployment( deployment_id=deployment_id, api_version=api_version, action=action, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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]: @@ -4018,9 +4500,8 @@ async def retry_deployment( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - retry_deployment.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}'} # type: ignore diff --git a/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/operations/_patch.py b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/operations/__init__.py b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/operations/__init__.py index 12ed68c85ea9..0c0112ed2670 100644 --- a/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/operations/__init__.py +++ b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/operations/__init__.py @@ -9,7 +9,12 @@ from ._operations import DeviceUpdateOperations from ._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/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/operations/_operations.py b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/operations/_operations.py index babe98c19979..fe0d2971f620 100644 --- a/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/operations/_operations.py +++ b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,10 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from json import loads as _loads -from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, Callable, Dict, Iterable, List, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -18,11 +19,15 @@ from azure.core.polling.base_polling import LROBasePolling from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from msrest import Serializer +from azure.core.utils import case_insensitive_dict from .._vendor import _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,38 +37,39 @@ def build_device_update_import_update_request_initial( instance_id: str, *, action: str, - json: JSONType = None, + json: Optional[List[JSON]] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _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', "2021-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/updates' + _url = "/deviceupdate/{instanceId}/updates" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['action'] = _SERIALIZER.query("action", action, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['action'] = _SERIALIZER.query("action", action, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -77,34 +83,35 @@ def build_device_update_list_updates_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/updates' + _url = "/deviceupdate/{instanceId}/updates" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if search is not None: - query_parameters['$search'] = _SERIALIZER.query("search", search, 'str') + _params['$search'] = _SERIALIZER.query("search", search, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -118,11 +125,14 @@ def build_device_update_get_update_request( if_none_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}' + _url = "/deviceupdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "provider": _SERIALIZER.url("provider", provider, 'str'), @@ -130,23 +140,21 @@ def build_device_update_get_update_request( "version": _SERIALIZER.url("version", version, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_none_match is not None: - header_parameters['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -158,11 +166,14 @@ def build_device_update_delete_update_request_initial( version: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}' + _url = "/deviceupdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "provider": _SERIALIZER.url("provider", provider, 'str'), @@ -170,21 +181,19 @@ def build_device_update_delete_update_request_initial( "version": _SERIALIZER.url("version", version, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -193,30 +202,31 @@ def build_device_update_list_providers_request( instance_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/updates/providers' + _url = "/deviceupdate/{instanceId}/updates/providers" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -226,31 +236,32 @@ def build_device_update_list_names_request( provider: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/updates/providers/{provider}/names' + _url = "/deviceupdate/{instanceId}/updates/providers/{provider}/names" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "provider": _SERIALIZER.url("provider", provider, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -263,34 +274,35 @@ def build_device_update_list_versions_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/updates/providers/{provider}/names/{name}/versions' + _url = "/deviceupdate/{instanceId}/updates/providers/{provider}/names/{name}/versions" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "provider": _SERIALIZER.url("provider", provider, 'str'), "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -302,11 +314,14 @@ def build_device_update_list_files_request( version: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}/files' + _url = "/deviceupdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}/files" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "provider": _SERIALIZER.url("provider", provider, 'str'), @@ -314,21 +329,19 @@ def build_device_update_list_files_request( "version": _SERIALIZER.url("version", version, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -343,11 +356,14 @@ def build_device_update_get_file_request( if_none_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}/files/{fileId}' + _url = "/deviceupdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}/files/{fileId}" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "provider": _SERIALIZER.url("provider", provider, 'str'), @@ -356,23 +372,21 @@ def build_device_update_get_file_request( "fileId": _SERIALIZER.url("file_id", file_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_none_match is not None: - header_parameters['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -384,34 +398,35 @@ def build_device_update_list_operations_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/updates/operations' + _url = "/deviceupdate/{instanceId}/updates/operations" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$top'] = _SERIALIZER.query("top", top, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -423,33 +438,34 @@ def build_device_update_get_operation_request( if_none_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/updates/operations/{operationId}' + _url = "/deviceupdate/{instanceId}/updates/operations/{operationId}" 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), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_none_match is not None: - header_parameters['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -458,30 +474,31 @@ def build_device_management_list_device_classes_request( instance_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/deviceclasses' + _url = "/deviceupdate/{instanceId}/management/deviceclasses" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -491,31 +508,32 @@ def build_device_management_get_device_class_request( device_class_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/deviceclasses/{deviceClassId}' + _url = "/deviceupdate/{instanceId}/management/deviceclasses/{deviceClassId}" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "deviceClassId": _SERIALIZER.url("device_class_id", device_class_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -525,31 +543,32 @@ def build_device_management_list_installable_updates_for_device_class_request( device_class_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/deviceclasses/{deviceClassId}/installableupdates' + _url = "/deviceupdate/{instanceId}/management/deviceclasses/{deviceClassId}/installableupdates" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "deviceClassId": _SERIALIZER.url("device_class_id", device_class_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -560,32 +579,33 @@ def build_device_management_list_devices_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/devices' + _url = "/deviceupdate/{instanceId}/management/devices" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -594,38 +614,39 @@ def build_device_management_import_devices_request_initial( instance_id: str, *, action: str, - json: JSONType = None, + json: Any = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _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', "2021-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/devices' + _url = "/deviceupdate/{instanceId}/management/devices" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - query_parameters['action'] = _SERIALIZER.query("action", action, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['action'] = _SERIALIZER.query("action", action, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -637,31 +658,32 @@ def build_device_management_get_device_request( device_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/devices/{deviceId}' + _url = "/deviceupdate/{instanceId}/management/devices/{deviceId}" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "deviceId": _SERIALIZER.url("device_id", device_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -672,32 +694,33 @@ def build_device_management_get_device_module_request( module_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/devices/{deviceId}/modules/{moduleId}' + _url = "/deviceupdate/{instanceId}/management/devices/{deviceId}/modules/{moduleId}" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "deviceId": _SERIALIZER.url("device_id", device_id, 'str'), "moduleId": _SERIALIZER.url("module_id", module_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -706,30 +729,31 @@ def build_device_management_get_update_compliance_request( instance_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/updatecompliance' + _url = "/deviceupdate/{instanceId}/management/updatecompliance" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -738,30 +762,31 @@ def build_device_management_list_device_tags_request( instance_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/devicetags' + _url = "/deviceupdate/{instanceId}/management/devicetags" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -771,31 +796,32 @@ def build_device_management_get_device_tag_request( tag_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/devicetags/{tagName}' + _url = "/deviceupdate/{instanceId}/management/devicetags/{tagName}" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -804,30 +830,31 @@ def build_device_management_list_groups_request( instance_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/groups' + _url = "/deviceupdate/{instanceId}/management/groups" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -837,31 +864,32 @@ def build_device_management_get_group_request( group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/groups/{groupId}' + _url = "/deviceupdate/{instanceId}/management/groups/{groupId}" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "groupId": _SERIALIZER.url("group_id", group_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -870,38 +898,39 @@ def build_device_management_create_or_update_group_request( instance_id: str, group_id: str, *, - json: JSONType = None, + json: Optional[JSON] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _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', "2021-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/groups/{groupId}' + _url = "/deviceupdate/{instanceId}/management/groups/{groupId}" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "groupId": _SERIALIZER.url("group_id", group_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -913,31 +942,32 @@ def build_device_management_delete_group_request( group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/groups/{groupId}' + _url = "/deviceupdate/{instanceId}/management/groups/{groupId}" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "groupId": _SERIALIZER.url("group_id", group_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -947,31 +977,32 @@ def build_device_management_get_group_update_compliance_request( group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/groups/{groupId}/updateCompliance' + _url = "/deviceupdate/{instanceId}/management/groups/{groupId}/updateCompliance" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "groupId": _SERIALIZER.url("group_id", group_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -983,33 +1014,34 @@ def build_device_management_list_best_updates_for_group_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/groups/{groupId}/bestUpdates' + _url = "/deviceupdate/{instanceId}/management/groups/{groupId}/bestUpdates" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "groupId": _SERIALIZER.url("group_id", group_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -1021,33 +1053,34 @@ def build_device_management_list_deployments_for_group_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments' + _url = "/deviceupdate/{instanceId}/management/groups/{groupId}/deployments" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "groupId": _SERIALIZER.url("group_id", group_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -1058,32 +1091,33 @@ def build_device_management_get_deployment_request( deployment_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}' + _url = "/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "groupId": _SERIALIZER.url("group_id", group_id, 'str'), "deploymentId": _SERIALIZER.url("deployment_id", deployment_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -1093,39 +1127,40 @@ def build_device_management_create_or_update_deployment_request( deployment_id: str, group_id: str, *, - json: JSONType = None, + json: Optional[JSON] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _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', "2021-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}' + _url = "/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "deploymentId": _SERIALIZER.url("deployment_id", deployment_id, 'str'), "groupId": _SERIALIZER.url("group_id", group_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -1138,32 +1173,33 @@ def build_device_management_delete_deployment_request( deployment_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}' + _url = "/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "groupId": _SERIALIZER.url("group_id", group_id, 'str'), "deploymentId": _SERIALIZER.url("deployment_id", deployment_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -1174,32 +1210,33 @@ def build_device_management_get_deployment_status_request( deployment_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}/status' + _url = "/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}/status" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "groupId": _SERIALIZER.url("group_id", group_id, 'str'), "deploymentId": _SERIALIZER.url("deployment_id", deployment_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -1212,34 +1249,35 @@ def build_device_management_list_deployment_devices_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}/devicestates' + _url = "/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}/devicestates" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "groupId": _SERIALIZER.url("group_id", group_id, 'str'), "deploymentId": _SERIALIZER.url("deployment_id", deployment_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -1251,33 +1289,34 @@ def build_device_management_get_operation_request( if_none_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/operations/{operationId}' + _url = "/deviceupdate/{instanceId}/management/operations/{operationId}" 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), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_none_match is not None: - header_parameters['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -1289,34 +1328,35 @@ def build_device_management_list_operations_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/operations' + _url = "/deviceupdate/{instanceId}/management/operations" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$top'] = _SERIALIZER.query("top", top, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -1325,38 +1365,39 @@ def build_device_management_collect_logs_request( instance_id: str, operation_id: str, *, - json: JSONType = None, + json: Optional[JSON] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _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', "2021-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/deviceDiagnostics/logCollections/{operationId}' + _url = "/deviceupdate/{instanceId}/management/deviceDiagnostics/logCollections/{operationId}" 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), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -1368,31 +1409,32 @@ def build_device_management_get_log_collection_operation_request( operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/deviceDiagnostics/logCollections/{operationId}' + _url = "/deviceupdate/{instanceId}/management/deviceDiagnostics/logCollections/{operationId}" 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), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -1401,30 +1443,31 @@ def build_device_management_list_log_collection_operations_request( instance_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/deviceDiagnostics/logCollections' + _url = "/deviceupdate/{instanceId}/management/deviceDiagnostics/logCollections" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -1434,31 +1477,32 @@ def build_device_management_get_log_collection_operation_detailed_status_request operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/deviceDiagnostics/logCollections/{operationId}/detailedStatus' + _url = "/deviceupdate/{instanceId}/management/deviceDiagnostics/logCollections/{operationId}/detailedStatus" 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), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -1471,33 +1515,34 @@ def build_device_management_stop_deployment_request( action: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}' + _url = "/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "groupId": _SERIALIZER.url("group_id", group_id, 'str'), "deploymentId": _SERIALIZER.url("deployment_id", deployment_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['action'] = _SERIALIZER.query("action", action, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['action'] = _SERIALIZER.query("action", action, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -1510,69 +1555,73 @@ def build_device_management_retry_deployment_request( action: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _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', "2021-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL - url = '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}' + _url = "/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}" path_format_arguments = { "instanceId": _SERIALIZER.url("instance_id", instance_id, 'str', skip_quote=True), "groupId": _SERIALIZER.url("group_id", group_id, 'str'), "deploymentId": _SERIALIZER.url("deployment_id", deployment_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['action'] = _SERIALIZER.query("action", action, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['action'] = _SERIALIZER.query("action", action, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DeviceUpdateOperations(object): - """DeviceUpdateOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeviceUpdateOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.iot.deviceupdate.DeviceUpdateClient`'s + :attr:`device_update` attribute. """ - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + 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") + def _import_update_initial( self, - update_to_import: List[JSONType], + update_to_import: List[JSON], *, action: str, **kwargs: Any - ) -> JSONType: - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] + ) -> JSON: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[JSON] _json = update_to_import @@ -1582,13 +1631,19 @@ def _import_update_initial( content_type=content_type, action=action, json=_json, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -1604,30 +1659,26 @@ def _import_update_initial( deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, cast(JSON, deserialized), response_headers) - return deserialized + return cast(JSON, deserialized) - _import_update_initial.metadata = {'url': '/deviceupdate/{instanceId}/updates'} # type: ignore @distributed_trace def begin_import_update( self, - update_to_import: List[JSONType], + update_to_import: List[JSON], *, action: str, **kwargs: Any - ) -> LROPoller[JSONType]: + ) -> LROPoller[JSON]: """Import new update version. :param update_to_import: The update to be imported. - :type update_to_import: list[JSONType] + :type update_to_import: list[JSON] :keyword action: Import update action. "import" :paramtype action: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal @@ -1636,7 +1687,7 @@ def begin_import_update( :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of LROPoller that returns JSON object - :rtype: ~azure.core.polling.LROPoller[JSONType] + :rtype: ~azure.core.polling.LROPoller[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -1647,17 +1698,29 @@ def begin_import_update( { "files": [ { - "filename": "str", # Required. Update file name as specified inside import manifest. - "url": "str" # Required. Azure Blob location from which the update file can be downloaded by Device Update for IoT Hub. This is typically a read-only SAS-protected blob URL with an expiration set to at least 4 hours. + "filename": "str", # Required. Update file name as + specified inside import manifest. + "url": "str" # Required. Azure Blob location from + which the update file can be downloaded by Device Update for IoT Hub. + This is typically a read-only SAS-protected blob URL with an + expiration set to at least 4 hours. } ], "friendlyName": "str", # Optional. Friendly update name. "importManifest": { "hashes": { - "str": "str" # Required. A JSON object containing the hash(es) of the file. At least SHA256 hash is required. This object can be thought of as a set of key-value pairs where the key is the hash algorithm, and the value is the hash of the file calculated using that algorithm. + "str": "str" # Required. A JSON object containing + the hash(es) of the file. At least SHA256 hash is required. This + object can be thought of as a set of key-value pairs where the key is + the hash algorithm, and the value is the hash of the file calculated + using that algorithm. }, - "sizeInBytes": 0.0, # Required. File size in number of bytes. - "url": "str" # Required. Azure Blob location from which the import manifest can be downloaded by Device Update for IoT Hub. This is typically a read-only SAS-protected blob URL with an expiration set to at least 4 hours. + "sizeInBytes": 0.0, # Required. File size in number of + bytes. + "url": "str" # Required. Azure Blob location from which the + import manifest can be downloaded by Device Update for IoT Hub. This is + typically a read-only SAS-protected blob URL with an expiration set to at + least 4 hours. } } ] @@ -1666,35 +1729,50 @@ def begin_import_update( response.json() == { "compatibility": [ { - "str": "str" # Required. List of update compatibility information. + "str": "str" # Required. List of update compatibility + information. } ], - "createdDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the update was created. + "createdDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC + when the update was created. "description": "str", # Optional. Update description specified by creator. "etag": "str", # Optional. Update ETag. - "friendlyName": "str", # Optional. Friendly update name specified by importer. - "importedDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the update was imported. - "installedCriteria": "str", # Optional. String interpreted by Device Update client to determine if the update is installed on the device. Deprecated in latest import manifest schema. + "friendlyName": "str", # Optional. Friendly update name specified by + importer. + "importedDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC + when the update was imported. + "installedCriteria": "str", # Optional. String interpreted by Device Update + client to determine if the update is installed on the device. Deprecated in + latest import manifest schema. "instructions": { "steps": [ { "description": "str", # Optional. Step description. "files": [ - "str" # Optional. Collection of file names to be passed to handler during execution. Required if step type is inline. + "str" # Optional. Collection of file names + to be passed to handler during execution. Required if step type + is inline. ], - "handler": "str", # Optional. Identity of handler that will execute this step. Required if step type is inline. - "handlerProperties": {}, # Optional. Parameters to be passed to handler during execution. - "type": "inline", # Optional. Default value is "inline". Step type. Possible values include: "Inline", "Reference". Default value: "inline". + "handler": "str", # Optional. Identity of handler + that will execute this step. Required if step type is inline. + "handlerProperties": {}, # Optional. Parameters to + be passed to handler during execution. + "type": "inline", # Optional. Default value is + "inline". Step type. Known values are: "Inline", "Reference". Default + value: "inline". "updateId": { "name": "str", # Required. Update name. - "provider": "str", # Required. Update provider. + "provider": "str", # Required. Update + provider. "version": "str" # Required. Update version. } } ] }, - "isDeployable": True, # Optional. Default value is True. Whether the update can be deployed to a device on its own. - "manifestVersion": "str", # Required. Schema version of manifest used to import the update. + "isDeployable": True, # Optional. Default value is True. Whether the update + can be deployed to a device on its own. + "manifestVersion": "str", # Required. Schema version of manifest used to + import the update. "referencedBy": [ { "name": "str", # Required. Update name. @@ -1702,31 +1780,38 @@ def begin_import_update( "version": "str" # Required. Update version. } ], - "scanResult": "str", # Optional. Update aggregate scan result (calculated from payload file scan results). + "scanResult": "str", # Optional. Update aggregate scan result (calculated + from payload file scan results). "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. "version": "str" # Required. Update version. }, - "updateType": "str" # Optional. Update type. Deprecated in latest import manifest schema. + "updateType": "str" # Optional. Update type. Deprecated in latest import + manifest schema. } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] + _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', "2021-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] 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 = self._import_update_initial( + raw_result = self._import_update_initial( # type: ignore update_to_import=update_to_import, action=action, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1749,8 +1834,14 @@ def get_long_running_output(pipeline_response): "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - if polling is True: polling_method = LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, LROBasePolling( + lro_delay, + + path_format_arguments=path_format_arguments, + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1759,10 +1850,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + - begin_import_update.metadata = {'url': '/deviceupdate/{instanceId}/updates'} # type: ignore @distributed_trace def list_updates( @@ -1771,18 +1861,15 @@ def list_updates( search: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable[JSONType]: + ) -> Iterable[JSON]: """Get a list of all updates that have been imported to Device Update for IoT Hub. - :keyword search: Request updates matching a free-text search expression. + :keyword search: Request updates matching a free-text search expression. Default value is None. :paramtype search: str - :keyword filter: Filter updates by its properties. + :keyword filter: Filter updates by its properties. Default value is None. :paramtype filter: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSONType] + :rtype: ~azure.core.paging.ItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -1795,60 +1882,86 @@ def list_updates( { "compatibility": [ { - "str": "str" # Required. List of update compatibility information. + "str": "str" # Required. List of update + compatibility information. } ], - "createdDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the update was created. - "description": "str", # Optional. Update description specified by creator. + "createdDateTime": "2020-02-20 00:00:00", # Required. Date + and time in UTC when the update was created. + "description": "str", # Optional. Update description + specified by creator. "etag": "str", # Optional. Update ETag. - "friendlyName": "str", # Optional. Friendly update name specified by importer. - "importedDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the update was imported. - "installedCriteria": "str", # Optional. String interpreted by Device Update client to determine if the update is installed on the device. Deprecated in latest import manifest schema. + "friendlyName": "str", # Optional. Friendly update name + specified by importer. + "importedDateTime": "2020-02-20 00:00:00", # Required. Date + and time in UTC when the update was imported. + "installedCriteria": "str", # Optional. String interpreted + by Device Update client to determine if the update is installed on the + device. Deprecated in latest import manifest schema. "instructions": { "steps": [ { - "description": "str", # Optional. Step description. + "description": "str", # Optional. + Step description. "files": [ - "str" # Optional. Collection of file names to be passed to handler during execution. Required if step type is inline. + "str" # Optional. Collection + of file names to be passed to handler during execution. + Required if step type is inline. ], - "handler": "str", # Optional. Identity of handler that will execute this step. Required if step type is inline. - "handlerProperties": {}, # Optional. Parameters to be passed to handler during execution. - "type": "inline", # Optional. Default value is "inline". Step type. Possible values include: "Inline", "Reference". Default value: "inline". + "handler": "str", # Optional. + Identity of handler that will execute this step. Required if + step type is inline. + "handlerProperties": {}, # Optional. + Parameters to be passed to handler during execution. + "type": "inline", # Optional. + Default value is "inline". Step type. Known values are: + "Inline", "Reference". Default value: "inline". "updateId": { - "name": "str", # Required. Update name. - "provider": "str", # Required. Update provider. - "version": "str" # Required. Update version. + "name": "str", # Required. + Update name. + "provider": "str", # + Required. Update provider. + "version": "str" # Required. + Update version. } } ] }, - "isDeployable": True, # Optional. Default value is True. Whether the update can be deployed to a device on its own. - "manifestVersion": "str", # Required. Schema version of manifest used to import the update. + "isDeployable": True, # Optional. Default value is True. + Whether the update can be deployed to a device on its own. + "manifestVersion": "str", # Required. Schema version of + manifest used to import the update. "referencedBy": [ { "name": "str", # Required. Update name. - "provider": "str", # Required. Update provider. + "provider": "str", # Required. Update + provider. "version": "str" # Required. Update version. } ], - "scanResult": "str", # Optional. Update aggregate scan result (calculated from payload file scan results). + "scanResult": "str", # Optional. Update aggregate scan + result (calculated from payload file scan results). "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. "version": "str" # Required. Update version. }, - "updateType": "str" # Optional. Update type. Deprecated in latest import manifest schema. + "updateType": "str" # Optional. Update type. Deprecated in + latest import manifest schema. } ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1857,24 +1970,25 @@ def prepare_request(next_link=None): api_version=api_version, search=search, filter=filter, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_update_list_updates_request( instance_id=self._config.instance_id, - api_version=api_version, - search=search, - filter=filter, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -1883,7 +1997,7 @@ def prepare_request(next_link=None): return request def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -1892,7 +2006,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1905,7 +2023,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_updates.metadata = {'url': '/deviceupdate/{instanceId}/updates'} # type: ignore + @distributed_trace def get_update( @@ -1916,7 +2034,7 @@ def get_update( *, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional[JSONType]: + ) -> Optional[JSON]: """Get a specific update version. :param provider: Update provider. @@ -1926,13 +2044,10 @@ def get_update( :param version: Update version. :type version: str :keyword if_none_match: Defines the If-None-Match condition. The operation will be performed - only if the ETag on the server does not match this value. + only if the ETag on the server does not match this value. Default value is None. :paramtype if_none_match: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType or None + :rtype: JSON or None :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -1942,35 +2057,50 @@ def get_update( response.json() == { "compatibility": [ { - "str": "str" # Required. List of update compatibility information. + "str": "str" # Required. List of update compatibility + information. } ], - "createdDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the update was created. + "createdDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC + when the update was created. "description": "str", # Optional. Update description specified by creator. "etag": "str", # Optional. Update ETag. - "friendlyName": "str", # Optional. Friendly update name specified by importer. - "importedDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the update was imported. - "installedCriteria": "str", # Optional. String interpreted by Device Update client to determine if the update is installed on the device. Deprecated in latest import manifest schema. + "friendlyName": "str", # Optional. Friendly update name specified by + importer. + "importedDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC + when the update was imported. + "installedCriteria": "str", # Optional. String interpreted by Device Update + client to determine if the update is installed on the device. Deprecated in + latest import manifest schema. "instructions": { "steps": [ { "description": "str", # Optional. Step description. "files": [ - "str" # Optional. Collection of file names to be passed to handler during execution. Required if step type is inline. + "str" # Optional. Collection of file names + to be passed to handler during execution. Required if step type + is inline. ], - "handler": "str", # Optional. Identity of handler that will execute this step. Required if step type is inline. - "handlerProperties": {}, # Optional. Parameters to be passed to handler during execution. - "type": "inline", # Optional. Default value is "inline". Step type. Possible values include: "Inline", "Reference". Default value: "inline". + "handler": "str", # Optional. Identity of handler + that will execute this step. Required if step type is inline. + "handlerProperties": {}, # Optional. Parameters to + be passed to handler during execution. + "type": "inline", # Optional. Default value is + "inline". Step type. Known values are: "Inline", "Reference". Default + value: "inline". "updateId": { "name": "str", # Required. Update name. - "provider": "str", # Required. Update provider. + "provider": "str", # Required. Update + provider. "version": "str" # Required. Update version. } } ] }, - "isDeployable": True, # Optional. Default value is True. Whether the update can be deployed to a device on its own. - "manifestVersion": "str", # Required. Schema version of manifest used to import the update. + "isDeployable": True, # Optional. Default value is True. Whether the update + can be deployed to a device on its own. + "manifestVersion": "str", # Required. Schema version of manifest used to + import the update. "referencedBy": [ { "name": "str", # Required. Update name. @@ -1978,22 +2108,27 @@ def get_update( "version": "str" # Required. Update version. } ], - "scanResult": "str", # Optional. Update aggregate scan result (calculated from payload file scan results). + "scanResult": "str", # Optional. Update aggregate scan result (calculated + from payload file scan results). "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. "version": "str" # Required. Update version. }, - "updateType": "str" # Optional. Update type. Deprecated in latest import manifest schema. + "updateType": "str" # Optional. Update type. Deprecated in latest import + manifest schema. } """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[JSONType]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[JSON]] request = build_device_update_get_update_request( @@ -2003,13 +2138,19 @@ def get_update( version=version, api_version=api_version, if_none_match=if_none_match, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -2028,23 +2169,25 @@ def get_update( return deserialized - get_update.metadata = {'url': '/deviceupdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}'} # type: ignore - def _delete_update_initial( + def _delete_update_initial( # pylint: disable=inconsistent-return-statements self, provider: str, name: str, version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_device_update_delete_update_request_initial( @@ -2053,13 +2196,19 @@ def _delete_update_initial( name=name, version=version, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -2073,11 +2222,10 @@ def _delete_update_initial( 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 - def begin_delete_update( + def begin_delete_update( # pylint: disable=inconsistent-return-statements self, provider: str, name: str, @@ -2092,9 +2240,6 @@ def begin_delete_update( :type name: str :param version: Update version. :type version: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal @@ -2106,21 +2251,26 @@ def begin_delete_update( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] 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 = self._delete_update_initial( + raw_result = 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) @@ -2134,8 +2284,14 @@ def get_long_running_output(pipeline_response): "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - if polling is True: polling_method = LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, LROBasePolling( + lro_delay, + + path_format_arguments=path_format_arguments, + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2144,23 +2300,19 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(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 - ) -> Iterable[JSONType]: + ) -> Iterable[JSON]: """Get a list of all update providers that have been imported to Device Update for IoT Hub. - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSONType] + :rtype: ~azure.core.paging.ItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -2174,35 +2326,41 @@ def list_providers( ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_device_update_list_providers_request( instance_id=self._config.instance_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_update_list_providers_request( instance_id=self._config.instance_id, - api_version=api_version, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -2211,7 +2369,7 @@ def prepare_request(next_link=None): return request def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -2220,7 +2378,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2233,23 +2395,20 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_providers.metadata = {'url': '/deviceupdate/{instanceId}/updates/providers'} # type: ignore + @distributed_trace def list_names( self, provider: str, **kwargs: Any - ) -> Iterable[JSONType]: + ) -> Iterable[JSON]: """Get a list of all update names that match the specified provider. :param provider: Update provider. :type provider: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSONType] + :rtype: ~azure.core.paging.ItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -2263,13 +2422,16 @@ def list_names( ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2277,23 +2439,26 @@ def prepare_request(next_link=None): instance_id=self._config.instance_id, provider=provider, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_update_list_names_request( instance_id=self._config.instance_id, provider=provider, - api_version=api_version, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -2302,7 +2467,7 @@ def prepare_request(next_link=None): return request def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -2311,7 +2476,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2324,7 +2493,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_names.metadata = {'url': '/deviceupdate/{instanceId}/updates/providers/{provider}/names'} # type: ignore + @distributed_trace def list_versions( @@ -2334,20 +2503,17 @@ def list_versions( *, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable[JSONType]: + ) -> Iterable[JSON]: """Get a list of all update versions that match the specified provider and name. :param provider: Update provider. :type provider: str :param name: Update name. :type name: str - :keyword filter: Filter updates by its properties. + :keyword filter: Filter updates by its properties. Default value is None. :paramtype filter: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSONType] + :rtype: ~azure.core.paging.ItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -2361,13 +2527,16 @@ def list_versions( ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2377,11 +2546,13 @@ def prepare_request(next_link=None): name=name, api_version=api_version, filter=filter, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: @@ -2389,13 +2560,13 @@ def prepare_request(next_link=None): instance_id=self._config.instance_id, provider=provider, name=name, - api_version=api_version, - filter=filter, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -2404,7 +2575,7 @@ def prepare_request(next_link=None): return request def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -2413,7 +2584,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2426,7 +2601,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_versions.metadata = {'url': '/deviceupdate/{instanceId}/updates/providers/{provider}/names/{name}/versions'} # type: ignore + @distributed_trace def list_files( @@ -2435,7 +2610,7 @@ def list_files( name: str, version: str, **kwargs: Any - ) -> Iterable[JSONType]: + ) -> Iterable[JSON]: """Get a list of all update file identifiers for the specified version. :param provider: Update provider. @@ -2444,11 +2619,8 @@ def list_files( :type name: str :param version: Update version. :type version: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSONType] + :rtype: ~azure.core.paging.ItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -2462,13 +2634,16 @@ def list_files( ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2478,11 +2653,13 @@ def prepare_request(next_link=None): name=name, version=version, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: @@ -2491,12 +2668,13 @@ def prepare_request(next_link=None): provider=provider, name=name, version=version, - api_version=api_version, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -2505,7 +2683,7 @@ def prepare_request(next_link=None): return request def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -2514,7 +2692,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2527,7 +2709,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_files.metadata = {'url': '/deviceupdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}/files'} # type: ignore + @distributed_trace def get_file( @@ -2539,7 +2721,7 @@ def get_file( *, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional[JSONType]: + ) -> Optional[JSON]: """Get a specific update file from the version. :param provider: Update provider. @@ -2551,13 +2733,10 @@ def get_file( :param file_id: File identifier. :type file_id: str :keyword if_none_match: Defines the If-None-Match condition. The operation will be performed - only if the ETag on the server does not match this value. + only if the ETag on the server does not match this value. Default value is None. :paramtype if_none_match: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType or None + :rtype: JSON or None :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -2566,10 +2745,12 @@ def get_file( # response body for status code(s): 200 response.json() == { "etag": "str", # Optional. File ETag. - "fileId": "str", # Required. File identity, generated by server at import time. + "fileId": "str", # Required. File identity, generated by server at import + time. "fileName": "str", # Required. File name. "hashes": { - "str": "str" # Required. Mapping of hashing algorithm to base64 encoded hash values. + "str": "str" # Required. Mapping of hashing algorithm to base64 + encoded hash values. }, "mimeType": "str", # Optional. File MIME type. "scanDetails": "str", # Optional. Anti-malware scan details. @@ -2577,13 +2758,16 @@ def get_file( "sizeInBytes": 0.0 # Required. File size in number of bytes. } """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[JSONType]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[JSON]] request = build_device_update_get_file_request( @@ -2594,13 +2778,19 @@ def get_file( file_id=file_id, api_version=api_version, if_none_match=if_none_match, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -2619,7 +2809,6 @@ def get_file( return deserialized - get_file.metadata = {'url': '/deviceupdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}/files/{fileId}'} # type: ignore @distributed_trace @@ -2629,22 +2818,19 @@ def list_operations( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[JSONType]: + ) -> Iterable[JSON]: """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. :keyword filter: Restricts the set of operations returned. Only one specific filter is - supported: "status eq 'NotStarted' or status eq 'Running'". + supported: "status eq 'NotStarted' or status eq 'Running'". Default value is None. :paramtype filter: str :keyword 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. + specified value n. Default value is None. :paramtype top: int - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSONType] + :rtype: ~azure.core.paging.ItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -2655,28 +2841,39 @@ def list_operations( "nextLink": "str", # Optional. The link to the next page of items. "value": [ { - "createdDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the operation was created. + "createdDateTime": "2020-02-20 00:00:00", # Required. Date + and time in UTC when the operation was created. "error": { - "code": "str", # Required. Server defined error code. + "code": "str", # Required. Server defined error + code. "details": [ ... ], "innererror": { - "code": "str", # Required. A more specific error code than what was provided by the containing error. - "errorDetail": "str", # Optional. The internal error or exception message. + "code": "str", # Required. A more specific + error code than what was provided by the containing error. + "errorDetail": "str", # Optional. The + internal error or exception message. "innerError": ..., - "message": "str" # Optional. A human-readable representation of the error. + "message": "str" # Optional. A + human-readable representation of the error. }, - "message": "str", # Required. A human-readable representation of the error. - "occurredDateTime": "2020-02-20 00:00:00", # Optional. Date and time in UTC when the error occurred. + "message": "str", # Required. A human-readable + representation of the error. + "occurredDateTime": "2020-02-20 00:00:00", # + Optional. Date and time in UTC when the error occurred. "target": "str" # Optional. The target of the error. }, "etag": "str", # Optional. Operation ETag. - "lastActionDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the operation status was last updated. + "lastActionDateTime": "2020-02-20 00:00:00", # Required. + Date and time in UTC when the operation status was last updated. "operationId": "str", # Required. Operation Id. - "resourceLocation": "str", # Optional. Location of the imported update when operation is successful. - "status": "str", # Required. Operation status. Possible values include: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". - "traceId": "str", # Optional. Operation correlation identity that can used by Microsoft Support for troubleshooting. + "resourceLocation": "str", # Optional. Location of the + imported update when operation is successful. + "status": "str", # Required. Operation status. Known values + are: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". + "traceId": "str", # Optional. Operation correlation identity + that can used by Microsoft Support for troubleshooting. "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. @@ -2686,13 +2883,16 @@ def list_operations( ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2701,24 +2901,25 @@ def prepare_request(next_link=None): api_version=api_version, filter=filter, top=top, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_update_list_operations_request( instance_id=self._config.instance_id, - api_version=api_version, - filter=filter, - top=top, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -2727,7 +2928,7 @@ def prepare_request(next_link=None): return request def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -2736,7 +2937,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2749,7 +2954,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_operations.metadata = {'url': '/deviceupdate/{instanceId}/updates/operations'} # type: ignore + @distributed_trace def get_operation( @@ -2758,19 +2963,16 @@ def get_operation( *, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional[JSONType]: + ) -> Optional[JSON]: """Retrieve operation status. :param operation_id: Operation identifier. :type operation_id: str :keyword if_none_match: Defines the If-None-Match condition. The operation will be performed - only if the ETag on the server does not match this value. + only if the ETag on the server does not match this value. Default value is None. :paramtype if_none_match: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType or None + :rtype: JSON or None :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -2778,28 +2980,38 @@ def get_operation( # response body for status code(s): 200 response.json() == { - "createdDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the operation was created. + "createdDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC + when the operation was created. "error": { "code": "str", # Required. Server defined error code. "details": [ ... ], "innererror": { - "code": "str", # Required. A more specific error code than what was provided by the containing error. - "errorDetail": "str", # Optional. The internal error or exception message. + "code": "str", # Required. A more specific error code than + what was provided by the containing error. + "errorDetail": "str", # Optional. The internal error or + exception message. "innerError": ..., - "message": "str" # Optional. A human-readable representation of the error. + "message": "str" # Optional. A human-readable representation + of the error. }, - "message": "str", # Required. A human-readable representation of the error. - "occurredDateTime": "2020-02-20 00:00:00", # Optional. Date and time in UTC when the error occurred. + "message": "str", # Required. A human-readable representation of the + error. + "occurredDateTime": "2020-02-20 00:00:00", # Optional. Date and time + in UTC when the error occurred. "target": "str" # Optional. The target of the error. }, "etag": "str", # Optional. Operation ETag. - "lastActionDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the operation status was last updated. + "lastActionDateTime": "2020-02-20 00:00:00", # Required. Date and time in + UTC when the operation status was last updated. "operationId": "str", # Required. Operation Id. - "resourceLocation": "str", # Optional. Location of the imported update when operation is successful. - "status": "str", # Required. Operation status. Possible values include: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". - "traceId": "str", # Optional. Operation correlation identity that can used by Microsoft Support for troubleshooting. + "resourceLocation": "str", # Optional. Location of the imported update when + operation is successful. + "status": "str", # Required. Operation status. Known values are: + "Undefined", "NotStarted", "Running", "Succeeded", "Failed". + "traceId": "str", # Optional. Operation correlation identity that can used + by Microsoft Support for troubleshooting. "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. @@ -2807,13 +3019,16 @@ def get_operation( } } """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[JSONType]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[JSON]] request = build_device_update_get_operation_request( @@ -2821,13 +3036,19 @@ def get_operation( operation_id=operation_id, api_version=api_version, if_none_match=if_none_match, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -2849,39 +3070,35 @@ def get_operation( return deserialized - get_operation.metadata = {'url': '/deviceupdate/{instanceId}/updates/operations/{operationId}'} # type: ignore -class DeviceManagementOperations(object): - """DeviceManagementOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeviceManagementOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.iot.deviceupdate.DeviceUpdateClient`'s + :attr:`device_management` attribute. """ - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + 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 - ) -> Iterable[JSONType]: + ) -> Iterable[JSON]: """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 api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSONType] + :rtype: ~azure.core.paging.ItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -2898,42 +3115,53 @@ def list_device_classes( "version": "str" # Required. Update version. }, "compatProperties": { - "str": "str" # Required. The compat properties of the device class. This object can be thought of as a set of key-value pairs where the key is the name of the compatibility property and the value is the value of the compatibility property. There will always be at least 1 compat property. + "str": "str" # Required. The compat properties of + the device class. This object can be thought of as a set of key-value + pairs where the key is the name of the compatibility property and the + value is the value of the compatibility property. There will always + be at least 1 compat property. }, - "deviceClassId": "str" # Required. The device class identifier. + "deviceClassId": "str" # Required. The device class + identifier. } ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_device_management_list_device_classes_request( instance_id=self._config.instance_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_management_list_device_classes_request( instance_id=self._config.instance_id, - api_version=api_version, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -2942,7 +3170,7 @@ def prepare_request(next_link=None): return request def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -2951,7 +3179,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2964,23 +3196,20 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_device_classes.metadata = {'url': '/deviceupdate/{instanceId}/management/deviceclasses'} # type: ignore + @distributed_trace def get_device_class( self, device_class_id: str, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Gets the properties of a device class. :param device_class_id: Device class identifier. :type device_class_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -2994,31 +3223,43 @@ def get_device_class( "version": "str" # Required. Update version. }, "compatProperties": { - "str": "str" # Required. The compat properties of the device class. This object can be thought of as a set of key-value pairs where the key is the name of the compatibility property and the value is the value of the compatibility property. There will always be at least 1 compat property. + "str": "str" # Required. The compat properties of the device class. + This object can be thought of as a set of key-value pairs where the key is + the name of the compatibility property and the value is the value of the + compatibility property. There will always be at least 1 compat property. }, "deviceClassId": "str" # Required. The device class identifier. } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_get_device_class_request( instance_id=self._config.instance_id, device_class_id=device_class_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -3031,11 +3272,10 @@ def get_device_class( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - get_device_class.metadata = {'url': '/deviceupdate/{instanceId}/management/deviceclasses/{deviceClassId}'} # type: ignore @distributed_trace @@ -3043,16 +3283,13 @@ def list_installable_updates_for_device_class( self, device_class_id: str, **kwargs: Any - ) -> Iterable[JSONType]: + ) -> Iterable[JSON]: """Gets a list of installable updates for a device class. :param device_class_id: Device class identifier. :type device_class_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSONType] + :rtype: ~azure.core.paging.ItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -3070,13 +3307,16 @@ def list_installable_updates_for_device_class( ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -3084,23 +3324,26 @@ def prepare_request(next_link=None): instance_id=self._config.instance_id, device_class_id=device_class_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_management_list_installable_updates_for_device_class_request( instance_id=self._config.instance_id, device_class_id=device_class_id, - api_version=api_version, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -3109,7 +3352,7 @@ def prepare_request(next_link=None): return request def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -3118,7 +3361,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -3131,7 +3378,7 @@ def get_next(next_link=None): return ItemPaged( 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( @@ -3139,17 +3386,14 @@ def list_devices( *, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable[JSONType]: + ) -> Iterable[JSON]: """Gets a list of devices connected to Device Update for IoT Hub. :keyword filter: Restricts the set of devices returned. You can filter on device GroupId or - DeviceClassId. + DeviceClassId. Default value is None. :paramtype filter: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSONType] + :rtype: ~azure.core.paging.ItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -3160,7 +3404,9 @@ def list_devices( "nextLink": "str", # Optional. The link to the next page of items. "value": [ { - "deploymentStatus": "str", # Optional. State of the device in its last deployment. Possible values include: "Succeeded", "InProgress", "Failed", "Canceled", "Incompatible". + "deploymentStatus": "str", # Optional. State of the device + in its last deployment. Known values are: "Succeeded", "InProgress", + "Failed", "Canceled", "Incompatible". "deviceClassId": "str", # Required. Device class identity. "deviceId": "str", # Required. Device identity. "groupId": "str", # Optional. Device group identity. @@ -3174,21 +3420,31 @@ def list_devices( "provider": "str", # Required. Update provider. "version": "str" # Required. Update version. }, - "lastDeploymentId": "str", # Optional. The deployment identifier for the last deployment to the device. + "lastDeploymentId": "str", # Optional. The deployment + identifier for the last deployment to the device. "lastInstallResult": { - "extendedResultCode": 0, # Required. Install extended result code. + "extendedResultCode": 0, # Required. Install + extended result code. "resultCode": 0, # Required. Install result code. - "resultDetails": "str", # Optional. A string containing further details about the install result. + "resultDetails": "str", # Optional. A string + containing further details about the install result. "stepResults": [ { - "description": "str", # Optional. Step description. It might be null for update steps. - "extendedResultCode": 0, # Required. Install extended result code. - "resultCode": 0, # Required. Install result code. - "resultDetails": "str", # Optional. A string containing further details about the install result. + "description": "str", # Optional. + Step description. It might be null for update steps. + "extendedResultCode": 0, # Required. + Install extended result code. + "resultCode": 0, # Required. Install + result code. + "resultDetails": "str", # Optional. + A string containing further details about the install result. "updateId": { - "name": "str", # Required. Update name. - "provider": "str", # Required. Update provider. - "version": "str" # Required. Update version. + "name": "str", # Required. + Update name. + "provider": "str", # + Required. Update provider. + "version": "str" # Required. + Update version. } } ] @@ -3196,18 +3452,22 @@ def list_devices( "manufacturer": "str", # Required. Device manufacturer. "model": "str", # Required. Device model. "moduleId": "str", # Optional. Device module identity. - "onLatestUpdate": bool # Required. Boolean flag indicating whether the latest update is installed on the device. + "onLatestUpdate": bool # Required. Boolean flag indicating + whether the latest update is installed on the device. } ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -3215,23 +3475,25 @@ def prepare_request(next_link=None): instance_id=self._config.instance_id, api_version=api_version, filter=filter, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_management_list_devices_request( instance_id=self._config.instance_id, - api_version=api_version, - filter=filter, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -3240,7 +3502,7 @@ def prepare_request(next_link=None): return request def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -3249,7 +3511,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -3262,23 +3528,26 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_devices.metadata = {'url': '/deviceupdate/{instanceId}/management/devices'} # type: ignore - def _import_devices_initial( + + def _import_devices_initial( # pylint: disable=inconsistent-return-statements self, import_type: str, *, action: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = import_type @@ -3288,13 +3557,19 @@ def _import_devices_initial( content_type=content_type, action=action, json=_json, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -3308,11 +3583,10 @@ def _import_devices_initial( if cls: return cls(pipeline_response, None, response_headers) - _import_devices_initial.metadata = {'url': '/deviceupdate/{instanceId}/management/devices'} # type: ignore @distributed_trace - def begin_import_devices( + def begin_import_devices( # pylint: disable=inconsistent-return-statements self, import_type: str, *, @@ -3321,14 +3595,11 @@ def begin_import_devices( ) -> LROPoller[None]: """Import existing devices from IoT Hub. - :param import_type: The types of devices to import. Possible values are: "Devices", "Modules", - and "All". + :param import_type: The types of devices to import. Known values are: "Devices", "Modules", and + "All". :type import_type: str :keyword action: Devices action. "import" :paramtype action: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal @@ -3340,22 +3611,27 @@ def begin_import_devices( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _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', "2021-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] 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 = self._import_devices_initial( + raw_result = self._import_devices_initial( # type: ignore import_type=import_type, action=action, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -3369,8 +3645,14 @@ def get_long_running_output(pipeline_response): "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - if polling is True: polling_method = LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, LROBasePolling( + lro_delay, + + path_format_arguments=path_format_arguments, + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -3379,27 +3661,23 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + - begin_import_devices.metadata = {'url': '/deviceupdate/{instanceId}/management/devices'} # type: ignore @distributed_trace def get_device( self, device_id: str, **kwargs: Any - ) -> JSONType: + ) -> JSON: """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. :type device_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -3407,7 +3685,9 @@ def get_device( # response body for status code(s): 200 response.json() == { - "deploymentStatus": "str", # Optional. State of the device in its last deployment. Possible values include: "Succeeded", "InProgress", "Failed", "Canceled", "Incompatible". + "deploymentStatus": "str", # Optional. State of the device in its last + deployment. Known values are: "Succeeded", "InProgress", "Failed", "Canceled", + "Incompatible". "deviceClassId": "str", # Required. Device class identity. "deviceId": "str", # Required. Device identity. "groupId": "str", # Optional. Device group identity. @@ -3421,20 +3701,26 @@ def get_device( "provider": "str", # Required. Update provider. "version": "str" # Required. Update version. }, - "lastDeploymentId": "str", # Optional. The deployment identifier for the last deployment to the device. + "lastDeploymentId": "str", # Optional. The deployment identifier for the + last deployment to the device. "lastInstallResult": { "extendedResultCode": 0, # Required. Install extended result code. "resultCode": 0, # Required. Install result code. - "resultDetails": "str", # Optional. A string containing further details about the install result. + "resultDetails": "str", # Optional. A string containing further + details about the install result. "stepResults": [ { - "description": "str", # Optional. Step description. It might be null for update steps. - "extendedResultCode": 0, # Required. Install extended result code. + "description": "str", # Optional. Step description. + It might be null for update steps. + "extendedResultCode": 0, # Required. Install + extended result code. "resultCode": 0, # Required. Install result code. - "resultDetails": "str", # Optional. A string containing further details about the install result. + "resultDetails": "str", # Optional. A string + containing further details about the install result. "updateId": { "name": "str", # Required. Update name. - "provider": "str", # Required. Update provider. + "provider": "str", # Required. Update + provider. "version": "str" # Required. Update version. } } @@ -3443,29 +3729,39 @@ def get_device( "manufacturer": "str", # Required. Device manufacturer. "model": "str", # Required. Device model. "moduleId": "str", # Optional. Device module identity. - "onLatestUpdate": bool # Required. Boolean flag indicating whether the latest update is installed on the device. + "onLatestUpdate": bool # Required. Boolean flag indicating whether the + latest update is installed on the device. } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_get_device_request( instance_id=self._config.instance_id, device_id=device_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -3478,11 +3774,10 @@ def get_device( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - get_device.metadata = {'url': '/deviceupdate/{instanceId}/management/devices/{deviceId}'} # type: ignore @distributed_trace @@ -3491,7 +3786,7 @@ def get_device_module( device_id: str, module_id: str, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Gets the device module properties and latest deployment status for a device module connected to Device Update for IoT Hub. @@ -3499,11 +3794,8 @@ def get_device_module( :type device_id: str :param module_id: Device module identifier in Azure IoT Hub. :type module_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -3511,7 +3803,9 @@ def get_device_module( # response body for status code(s): 200 response.json() == { - "deploymentStatus": "str", # Optional. State of the device in its last deployment. Possible values include: "Succeeded", "InProgress", "Failed", "Canceled", "Incompatible". + "deploymentStatus": "str", # Optional. State of the device in its last + deployment. Known values are: "Succeeded", "InProgress", "Failed", "Canceled", + "Incompatible". "deviceClassId": "str", # Required. Device class identity. "deviceId": "str", # Required. Device identity. "groupId": "str", # Optional. Device group identity. @@ -3525,20 +3819,26 @@ def get_device_module( "provider": "str", # Required. Update provider. "version": "str" # Required. Update version. }, - "lastDeploymentId": "str", # Optional. The deployment identifier for the last deployment to the device. + "lastDeploymentId": "str", # Optional. The deployment identifier for the + last deployment to the device. "lastInstallResult": { "extendedResultCode": 0, # Required. Install extended result code. "resultCode": 0, # Required. Install result code. - "resultDetails": "str", # Optional. A string containing further details about the install result. + "resultDetails": "str", # Optional. A string containing further + details about the install result. "stepResults": [ { - "description": "str", # Optional. Step description. It might be null for update steps. - "extendedResultCode": 0, # Required. Install extended result code. + "description": "str", # Optional. Step description. + It might be null for update steps. + "extendedResultCode": 0, # Required. Install + extended result code. "resultCode": 0, # Required. Install result code. - "resultDetails": "str", # Optional. A string containing further details about the install result. + "resultDetails": "str", # Optional. A string + containing further details about the install result. "updateId": { "name": "str", # Required. Update name. - "provider": "str", # Required. Update provider. + "provider": "str", # Required. Update + provider. "version": "str" # Required. Update version. } } @@ -3547,16 +3847,20 @@ def get_device_module( "manufacturer": "str", # Required. Device manufacturer. "model": "str", # Required. Device model. "moduleId": "str", # Optional. Device module identity. - "onLatestUpdate": bool # Required. Boolean flag indicating whether the latest update is installed on the device. + "onLatestUpdate": bool # Required. Boolean flag indicating whether the + latest update is installed on the device. } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_get_device_module_request( @@ -3564,13 +3868,19 @@ def get_device_module( device_id=device_id, module_id=module_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -3583,26 +3893,22 @@ def get_device_module( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - get_device_module.metadata = {'url': '/deviceupdate/{instanceId}/management/devices/{deviceId}/modules/{moduleId}'} # type: ignore @distributed_trace def get_update_compliance( self, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Gets the breakdown of how many devices are on their latest update, have new updates available, or are in progress receiving new updates. - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -3610,31 +3916,43 @@ def get_update_compliance( # response body for status code(s): 200 response.json() == { - "newUpdatesAvailableDeviceCount": 0, # Required. Number of devices with a newer update available. - "onLatestUpdateDeviceCount": 0, # Required. Number of devices on the latest update. + "newUpdatesAvailableDeviceCount": 0, # Required. Number of devices with a + newer update available. + "onLatestUpdateDeviceCount": 0, # Required. Number of devices on the latest + update. "totalDeviceCount": 0, # Required. Total number of devices. - "updatesInProgressDeviceCount": 0 # Required. Number of devices with update in-progress. + "updatesInProgressDeviceCount": 0 # Required. Number of devices with update + in-progress. } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_get_update_compliance_request( instance_id=self._config.instance_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -3647,26 +3965,22 @@ def get_update_compliance( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - get_update_compliance.metadata = {'url': '/deviceupdate/{instanceId}/management/updatecompliance'} # type: ignore @distributed_trace def list_device_tags( self, **kwargs: Any - ) -> Iterable[JSONType]: + ) -> Iterable[JSON]: """Gets a list of available group device tags for all devices connected to Device Update for IoT Hub. - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSONType] + :rtype: ~azure.core.paging.ItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -3677,41 +3991,48 @@ def list_device_tags( "nextLink": "str", # Optional. The link to the next page of items. "value": [ { - "deviceCount": 0, # Required. Number of devices with this tag. + "deviceCount": 0, # Required. Number of devices with this + tag. "tagName": "str" # Required. Tag name. } ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_device_management_list_device_tags_request( instance_id=self._config.instance_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_management_list_device_tags_request( instance_id=self._config.instance_id, - api_version=api_version, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -3720,7 +4041,7 @@ def prepare_request(next_link=None): return request def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -3729,7 +4050,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -3742,23 +4067,20 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_device_tags.metadata = {'url': '/deviceupdate/{instanceId}/management/devicetags'} # type: ignore + @distributed_trace def get_device_tag( self, tag_name: str, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Gets a count of how many devices have a device tag. :param tag_name: Tag name. :type tag_name: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -3770,26 +4092,35 @@ def get_device_tag( "tagName": "str" # Required. Tag name. } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_get_device_tag_request( instance_id=self._config.instance_id, tag_name=tag_name, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -3802,25 +4133,21 @@ def get_device_tag( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - get_device_tag.metadata = {'url': '/deviceupdate/{instanceId}/management/devicetags/{tagName}'} # type: ignore @distributed_trace def list_groups( self, **kwargs: Any - ) -> Iterable[JSONType]: + ) -> Iterable[JSON]: """Gets a list of all device groups. - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSONType] + :rtype: ~azure.core.paging.ItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -3831,12 +4158,18 @@ def list_groups( "nextLink": "str", # Optional. The link to the next page of items. "value": [ { - "createdDateTime": "str", # Required. Date and time when the update was created. - "deploymentId": "str", # Optional. The deployment Id for the group. - "deviceClassId": "str", # Optional. The device class Id for the group. - "deviceCount": 0, # Optional. The number of devices in the group. + "createdDateTime": "str", # Required. Date and time when the + update was created. + "deploymentId": "str", # Optional. The deployment Id for the + group. + "deviceClassId": "str", # Optional. The device class Id for + the group. + "deviceCount": 0, # Optional. The number of devices in the + group. "groupId": "str", # Required. Group identity. - "groupType": "str", # Required. Group type. Possible values include: "DeviceClassIdAndIoTHubTag", "InvalidDeviceClassIdAndIoTHubTag", "DefaultDeviceClassId". + "groupType": "str", # Required. Group type. Known values + are: "DeviceClassIdAndIoTHubTag", "InvalidDeviceClassIdAndIoTHubTag", + "DefaultDeviceClassId". "tags": [ "str" # Required. A set of tags. IoT Hub tags. ] @@ -3844,35 +4177,41 @@ def list_groups( ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_device_management_list_groups_request( instance_id=self._config.instance_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_management_list_groups_request( instance_id=self._config.instance_id, - api_version=api_version, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -3881,7 +4220,7 @@ def prepare_request(next_link=None): return request def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -3890,7 +4229,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -3903,23 +4246,20 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_groups.metadata = {'url': '/deviceupdate/{instanceId}/management/groups'} # type: ignore + @distributed_trace def get_group( self, group_id: str, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Gets the properties of a group. :param group_id: Group identity. :type group_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -3927,37 +4267,49 @@ def get_group( # response body for status code(s): 200 response.json() == { - "createdDateTime": "str", # Required. Date and time when the update was created. + "createdDateTime": "str", # Required. Date and time when the update was + created. "deploymentId": "str", # Optional. The deployment Id for the group. "deviceClassId": "str", # Optional. The device class Id for the group. "deviceCount": 0, # Optional. The number of devices in the group. "groupId": "str", # Required. Group identity. - "groupType": "str", # Required. Group type. Possible values include: "DeviceClassIdAndIoTHubTag", "InvalidDeviceClassIdAndIoTHubTag", "DefaultDeviceClassId". + "groupType": "str", # Required. Group type. Known values are: + "DeviceClassIdAndIoTHubTag", "InvalidDeviceClassIdAndIoTHubTag", + "DefaultDeviceClassId". "tags": [ "str" # Required. A set of tags. IoT Hub tags. ] } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_get_group_request( instance_id=self._config.instance_id, group_id=group_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -3970,31 +4322,27 @@ def get_group( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - get_group.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}'} # type: ignore @distributed_trace def create_or_update_group( self, group_id: str, - group: JSONType, + group: JSON, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Create or update a device group. :param group_id: Group identity. :type group_id: str :param group: The group properties. - :type group: JSONType - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str + :type group: JSON :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -4002,12 +4350,15 @@ def create_or_update_group( # JSON input template you can fill out and use as your body input. group = { - "createdDateTime": "str", # Required. Date and time when the update was created. + "createdDateTime": "str", # Required. Date and time when the update was + created. "deploymentId": "str", # Optional. The deployment Id for the group. "deviceClassId": "str", # Optional. The device class Id for the group. "deviceCount": 0, # Optional. The number of devices in the group. "groupId": "str", # Required. Group identity. - "groupType": "str", # Required. Group type. Possible values include: "DeviceClassIdAndIoTHubTag", "InvalidDeviceClassIdAndIoTHubTag", "DefaultDeviceClassId". + "groupType": "str", # Required. Group type. Known values are: + "DeviceClassIdAndIoTHubTag", "InvalidDeviceClassIdAndIoTHubTag", + "DefaultDeviceClassId". "tags": [ "str" # Required. A set of tags. IoT Hub tags. ] @@ -4015,25 +4366,31 @@ def create_or_update_group( # response body for status code(s): 200 response.json() == { - "createdDateTime": "str", # Required. Date and time when the update was created. + "createdDateTime": "str", # Required. Date and time when the update was + created. "deploymentId": "str", # Optional. The deployment Id for the group. "deviceClassId": "str", # Optional. The device class Id for the group. "deviceCount": 0, # Optional. The number of devices in the group. "groupId": "str", # Required. Group identity. - "groupType": "str", # Required. Group type. Possible values include: "DeviceClassIdAndIoTHubTag", "InvalidDeviceClassIdAndIoTHubTag", "DefaultDeviceClassId". + "groupType": "str", # Required. Group type. Known values are: + "DeviceClassIdAndIoTHubTag", "InvalidDeviceClassIdAndIoTHubTag", + "DefaultDeviceClassId". "tags": [ "str" # Required. A set of tags. IoT Hub tags. ] } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[JSON] _json = group @@ -4043,13 +4400,19 @@ def create_or_update_group( api_version=api_version, content_type=content_type, json=_json, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -4062,15 +4425,14 @@ def create_or_update_group( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - create_or_update_group.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}'} # type: ignore @distributed_trace - def delete_group( + def delete_group( # pylint: disable=inconsistent-return-statements self, group_id: str, **kwargs: Any @@ -4079,33 +4441,39 @@ def delete_group( :param group_id: Group identity. :type group_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: None :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_device_management_delete_group_request( instance_id=self._config.instance_id, group_id=group_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -4115,7 +4483,6 @@ def delete_group( if cls: return cls(pipeline_response, None, {}) - delete_group.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}'} # type: ignore @distributed_trace @@ -4123,17 +4490,14 @@ def get_group_update_compliance( self, group_id: str, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Get 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. :type group_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -4141,32 +4505,44 @@ def get_group_update_compliance( # response body for status code(s): 200 response.json() == { - "newUpdatesAvailableDeviceCount": 0, # Required. Number of devices with a newer update available. - "onLatestUpdateDeviceCount": 0, # Required. Number of devices on the latest update. + "newUpdatesAvailableDeviceCount": 0, # Required. Number of devices with a + newer update available. + "onLatestUpdateDeviceCount": 0, # Required. Number of devices on the latest + update. "totalDeviceCount": 0, # Required. Total number of devices. - "updatesInProgressDeviceCount": 0 # Required. Number of devices with update in-progress. + "updatesInProgressDeviceCount": 0 # Required. Number of devices with update + in-progress. } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_get_group_update_compliance_request( instance_id=self._config.instance_id, group_id=group_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -4179,11 +4555,10 @@ def get_group_update_compliance( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - get_group_update_compliance.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}/updateCompliance'} # type: ignore @distributed_trace @@ -4193,19 +4568,16 @@ def list_best_updates_for_group( *, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable[JSONType]: + ) -> Iterable[JSON]: """Get the best available updates for a group and a count of how many devices need each update. :param group_id: Group identity. :type group_id: str :keyword filter: Restricts the set of bestUpdates returned. You can filter on update Provider, - Name and Version property. + Name and Version property. Default value is None. :paramtype filter: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSONType] + :rtype: ~azure.core.paging.ItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -4216,7 +4588,8 @@ def list_best_updates_for_group( "nextLink": "str", # Optional. The link to the next page of items. "value": [ { - "deviceCount": 0, # Required. Total number of devices for which the update is applicable. + "deviceCount": 0, # Required. Total number of devices for + which the update is applicable. "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. @@ -4226,13 +4599,16 @@ def list_best_updates_for_group( ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -4241,24 +4617,26 @@ def prepare_request(next_link=None): group_id=group_id, api_version=api_version, filter=filter, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_management_list_best_updates_for_group_request( instance_id=self._config.instance_id, group_id=group_id, - api_version=api_version, - filter=filter, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -4267,7 +4645,7 @@ def prepare_request(next_link=None): return request def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -4276,7 +4654,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -4289,7 +4671,7 @@ def get_next(next_link=None): return ItemPaged( 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( @@ -4298,19 +4680,16 @@ def list_deployments_for_group( *, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable[JSONType]: + ) -> Iterable[JSON]: """Gets a list of deployments for a group. :param group_id: Group identity. :type group_id: str :keyword filter: Restricts the set of deployments returned. You can filter on update Provider, - Name and Version property. + Name and Version property. Default value is None. :paramtype filter: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSONType] + :rtype: ~azure.core.paging.ItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -4321,11 +4700,15 @@ def list_deployments_for_group( "nextLink": "str", # Optional. The link to the next page of items. "value": [ { - "deploymentId": "str", # Required. The deployment identifier. + "deploymentId": "str", # Required. The deployment + identifier. "groupId": "str", # Required. The group identity. - "isCanceled": bool, # Optional. Boolean flag indicating whether the deployment was canceled. - "isRetried": bool, # Optional. Boolean flag indicating whether the deployment has been retried. - "startDateTime": "2020-02-20 00:00:00", # Required. The deployment start datetime. + "isCanceled": bool, # Optional. Boolean flag indicating + whether the deployment was canceled. + "isRetried": bool, # Optional. Boolean flag indicating + whether the deployment has been retried. + "startDateTime": "2020-02-20 00:00:00", # Required. The + deployment start datetime. "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. @@ -4335,13 +4718,16 @@ def list_deployments_for_group( ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -4350,24 +4736,26 @@ def prepare_request(next_link=None): group_id=group_id, api_version=api_version, filter=filter, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_management_list_deployments_for_group_request( instance_id=self._config.instance_id, group_id=group_id, - api_version=api_version, - filter=filter, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -4376,7 +4764,7 @@ def prepare_request(next_link=None): return request def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -4385,7 +4773,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -4398,7 +4790,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_deployments_for_group.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments'} # type: ignore + @distributed_trace def get_deployment( @@ -4406,18 +4798,15 @@ def get_deployment( group_id: str, deployment_id: str, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Gets the properties of a deployment. :param group_id: Group identity. :type group_id: str :param deployment_id: Deployment identifier. :type deployment_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -4427,9 +4816,12 @@ def get_deployment( response.json() == { "deploymentId": "str", # Required. The deployment identifier. "groupId": "str", # Required. The group identity. - "isCanceled": bool, # Optional. Boolean flag indicating whether the deployment was canceled. - "isRetried": bool, # Optional. Boolean flag indicating whether the deployment has been retried. - "startDateTime": "2020-02-20 00:00:00", # Required. The deployment start datetime. + "isCanceled": bool, # Optional. Boolean flag indicating whether the + deployment was canceled. + "isRetried": bool, # Optional. Boolean flag indicating whether the + deployment has been retried. + "startDateTime": "2020-02-20 00:00:00", # Required. The deployment start + datetime. "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. @@ -4437,13 +4829,16 @@ def get_deployment( } } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_get_deployment_request( @@ -4451,13 +4846,19 @@ def get_deployment( group_id=group_id, deployment_id=deployment_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -4470,11 +4871,10 @@ def get_deployment( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - get_deployment.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}'} # type: ignore @distributed_trace @@ -4482,9 +4882,9 @@ def create_or_update_deployment( self, deployment_id: str, group_id: str, - deployment: JSONType, + deployment: JSON, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Creates or updates a deployment. :param deployment_id: Deployment identifier. @@ -4492,12 +4892,9 @@ def create_or_update_deployment( :param group_id: Group identity. :type group_id: str :param deployment: The deployment properties. - :type deployment: JSONType - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str + :type deployment: JSON :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -4507,9 +4904,12 @@ def create_or_update_deployment( deployment = { "deploymentId": "str", # Required. The deployment identifier. "groupId": "str", # Required. The group identity. - "isCanceled": bool, # Optional. Boolean flag indicating whether the deployment was canceled. - "isRetried": bool, # Optional. Boolean flag indicating whether the deployment has been retried. - "startDateTime": "2020-02-20 00:00:00", # Required. The deployment start datetime. + "isCanceled": bool, # Optional. Boolean flag indicating whether the + deployment was canceled. + "isRetried": bool, # Optional. Boolean flag indicating whether the + deployment has been retried. + "startDateTime": "2020-02-20 00:00:00", # Required. The deployment start + datetime. "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. @@ -4521,9 +4921,12 @@ def create_or_update_deployment( response.json() == { "deploymentId": "str", # Required. The deployment identifier. "groupId": "str", # Required. The group identity. - "isCanceled": bool, # Optional. Boolean flag indicating whether the deployment was canceled. - "isRetried": bool, # Optional. Boolean flag indicating whether the deployment has been retried. - "startDateTime": "2020-02-20 00:00:00", # Required. The deployment start datetime. + "isCanceled": bool, # Optional. Boolean flag indicating whether the + deployment was canceled. + "isRetried": bool, # Optional. Boolean flag indicating whether the + deployment has been retried. + "startDateTime": "2020-02-20 00:00:00", # Required. The deployment start + datetime. "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. @@ -4531,14 +4934,17 @@ def create_or_update_deployment( } } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _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', "2021-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[JSON] _json = deployment @@ -4549,13 +4955,19 @@ def create_or_update_deployment( api_version=api_version, content_type=content_type, json=_json, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -4568,15 +4980,14 @@ def create_or_update_deployment( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - create_or_update_deployment.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}'} # type: ignore @distributed_trace - def delete_deployment( + def delete_deployment( # pylint: disable=inconsistent-return-statements self, group_id: str, deployment_id: str, @@ -4588,20 +4999,20 @@ def delete_deployment( :type group_id: str :param deployment_id: Deployment identifier. :type deployment_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: None :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_device_management_delete_deployment_request( @@ -4609,13 +5020,19 @@ def delete_deployment( group_id=group_id, deployment_id=deployment_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -4625,7 +5042,6 @@ def delete_deployment( if cls: return cls(pipeline_response, None, {}) - delete_deployment.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}'} # type: ignore @distributed_trace @@ -4634,7 +5050,7 @@ def get_deployment_status( group_id: str, deployment_id: str, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Gets the status of a deployment including a breakdown of how many devices in the deployment are in progress, completed, or failed. @@ -4642,11 +5058,8 @@ def get_deployment_status( :type group_id: str :param deployment_id: Deployment identifier. :type deployment_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -4654,21 +5067,29 @@ def get_deployment_status( # response body for status code(s): 200 response.json() == { - "deploymentState": "str", # Required. The state of the deployment. Possible values include: "Active", "Inactive", "Canceled". - "devicesCanceledCount": 0, # Optional. The number of devices which have had their deployment canceled. - "devicesCompletedFailedCount": 0, # Optional. The number of devices that have completed deployment with a failure. - "devicesCompletedSucceededCount": 0, # Optional. The number of devices which have successfully completed deployment. - "devicesInProgressCount": 0, # Optional. The number of devices that are currently in deployment. + "deploymentState": "str", # Required. The state of the deployment. Known + values are: "Active", "Inactive", "Canceled". + "devicesCanceledCount": 0, # Optional. The number of devices which have had + their deployment canceled. + "devicesCompletedFailedCount": 0, # Optional. The number of devices that + have completed deployment with a failure. + "devicesCompletedSucceededCount": 0, # Optional. The number of devices which + have successfully completed deployment. + "devicesInProgressCount": 0, # Optional. The number of devices that are + currently in deployment. "totalDevices": 0 # Optional. The total number of devices in the deployment. } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_get_deployment_status_request( @@ -4676,13 +5097,19 @@ def get_deployment_status( group_id=group_id, deployment_id=deployment_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -4695,11 +5122,10 @@ def get_deployment_status( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - get_deployment_status.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}/status'} # type: ignore @distributed_trace @@ -4710,7 +5136,7 @@ def list_deployment_devices( *, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable[JSONType]: + ) -> Iterable[JSON]: """Gets a list of devices in a deployment along with their state. Useful for getting a list of failed devices. @@ -4719,13 +5145,10 @@ def list_deployment_devices( :param deployment_id: Deployment identifier. :type deployment_id: str :keyword filter: Restricts the set of deployment device states returned. You can filter on - deviceId and moduleId and/or deviceState. + deviceId and moduleId and/or deviceState. Default value is None. :paramtype filter: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSONType] + :rtype: ~azure.core.paging.ItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -4737,21 +5160,29 @@ def list_deployment_devices( "value": [ { "deviceId": "str", # Required. Device identity. - "deviceState": "str", # Required. Deployment device state. Possible values include: "Succeeded", "InProgress", "Failed", "Canceled", "Incompatible". + "deviceState": "str", # Required. Deployment device state. + Known values are: "Succeeded", "InProgress", "Failed", "Canceled", + "Incompatible". "moduleId": "str", # Optional. Device module identity. - "movedOnToNewDeployment": bool, # Required. Boolean flag indicating whether this device is in a newer deployment and can no longer retry this deployment. - "retryCount": 0 # Required. The number of times this deployment has been retried on this device. + "movedOnToNewDeployment": bool, # Required. Boolean flag + indicating whether this device is in a newer deployment and can no longer + retry this deployment. + "retryCount": 0 # Required. The number of times this + deployment has been retried on this device. } ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -4761,11 +5192,13 @@ def prepare_request(next_link=None): deployment_id=deployment_id, api_version=api_version, filter=filter, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: @@ -4773,13 +5206,13 @@ def prepare_request(next_link=None): instance_id=self._config.instance_id, group_id=group_id, deployment_id=deployment_id, - api_version=api_version, - filter=filter, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -4788,7 +5221,7 @@ def prepare_request(next_link=None): return request def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -4797,7 +5230,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -4810,7 +5247,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_deployment_devices.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}/devicestates'} # type: ignore + @distributed_trace def get_operation( @@ -4819,19 +5256,16 @@ def get_operation( *, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional[JSONType]: + ) -> Optional[JSON]: """Retrieve operation status. :param operation_id: Operation identifier. :type operation_id: str :keyword if_none_match: Defines the If-None-Match condition. The operation will be performed - only if the ETag on the server does not match this value. + only if the ETag on the server does not match this value. Default value is None. :paramtype if_none_match: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType or None + :rtype: JSON or None :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -4839,36 +5273,48 @@ def get_operation( # response body for status code(s): 200 response.json() == { - "createdDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the operation was created. + "createdDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC + when the operation was created. "error": { "code": "str", # Required. Server defined error code. "details": [ ... ], "innererror": { - "code": "str", # Required. A more specific error code than what was provided by the containing error. - "errorDetail": "str", # Optional. The internal error or exception message. + "code": "str", # Required. A more specific error code than + what was provided by the containing error. + "errorDetail": "str", # Optional. The internal error or + exception message. "innerError": ..., - "message": "str" # Optional. A human-readable representation of the error. + "message": "str" # Optional. A human-readable representation + of the error. }, - "message": "str", # Required. A human-readable representation of the error. - "occurredDateTime": "2020-02-20 00:00:00", # Optional. Date and time in UTC when the error occurred. + "message": "str", # Required. A human-readable representation of the + error. + "occurredDateTime": "2020-02-20 00:00:00", # Optional. Date and time + in UTC when the error occurred. "target": "str" # Optional. The target of the error. }, "etag": "str", # Optional. Operation ETag. - "lastActionDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the operation status was last updated. + "lastActionDateTime": "2020-02-20 00:00:00", # Required. Date and time in + UTC when the operation status was last updated. "operationId": "str", # Required. Operation Id. - "status": "str", # Required. Operation status. Possible values include: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". - "traceId": "str" # Optional. Operation correlation identity that can used by Microsoft Support for troubleshooting. + "status": "str", # Required. Operation status. Known values are: + "Undefined", "NotStarted", "Running", "Succeeded", "Failed". + "traceId": "str" # Optional. Operation correlation identity that can used by + Microsoft Support for troubleshooting. } """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[JSONType]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[JSON]] request = build_device_management_get_operation_request( @@ -4876,13 +5322,19 @@ def get_operation( operation_id=operation_id, api_version=api_version, if_none_match=if_none_match, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -4904,7 +5356,6 @@ def get_operation( return deserialized - get_operation.metadata = {'url': '/deviceupdate/{instanceId}/management/operations/{operationId}'} # type: ignore @distributed_trace @@ -4914,22 +5365,19 @@ def list_operations( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[JSONType]: + ) -> Iterable[JSON]: """Get a list of all device import operations. Completed operations are kept for 7 days before auto-deleted. :keyword filter: Restricts the set of operations returned. Only one specific filter is - supported: "status eq 'NotStarted' or status eq 'Running'". + supported: "status eq 'NotStarted' or status eq 'Running'". Default value is None. :paramtype filter: str :keyword 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. + specified value n. Default value is None. :paramtype top: int - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSONType] + :rtype: ~azure.core.paging.ItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -4940,38 +5388,51 @@ def list_operations( "nextLink": "str", # Optional. The link to the next page of items. "value": [ { - "createdDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the operation was created. + "createdDateTime": "2020-02-20 00:00:00", # Required. Date + and time in UTC when the operation was created. "error": { - "code": "str", # Required. Server defined error code. + "code": "str", # Required. Server defined error + code. "details": [ ... ], "innererror": { - "code": "str", # Required. A more specific error code than what was provided by the containing error. - "errorDetail": "str", # Optional. The internal error or exception message. + "code": "str", # Required. A more specific + error code than what was provided by the containing error. + "errorDetail": "str", # Optional. The + internal error or exception message. "innerError": ..., - "message": "str" # Optional. A human-readable representation of the error. + "message": "str" # Optional. A + human-readable representation of the error. }, - "message": "str", # Required. A human-readable representation of the error. - "occurredDateTime": "2020-02-20 00:00:00", # Optional. Date and time in UTC when the error occurred. + "message": "str", # Required. A human-readable + representation of the error. + "occurredDateTime": "2020-02-20 00:00:00", # + Optional. Date and time in UTC when the error occurred. "target": "str" # Optional. The target of the error. }, "etag": "str", # Optional. Operation ETag. - "lastActionDateTime": "2020-02-20 00:00:00", # Required. Date and time in UTC when the operation status was last updated. + "lastActionDateTime": "2020-02-20 00:00:00", # Required. + Date and time in UTC when the operation status was last updated. "operationId": "str", # Required. Operation Id. - "status": "str", # Required. Operation status. Possible values include: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". - "traceId": "str" # Optional. Operation correlation identity that can used by Microsoft Support for troubleshooting. + "status": "str", # Required. Operation status. Known values + are: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". + "traceId": "str" # Optional. Operation correlation identity + that can used by Microsoft Support for troubleshooting. } ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -4980,24 +5441,25 @@ def prepare_request(next_link=None): api_version=api_version, filter=filter, top=top, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_management_list_operations_request( instance_id=self._config.instance_id, - api_version=api_version, - filter=filter, - top=top, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -5006,7 +5468,7 @@ def prepare_request(next_link=None): return request def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -5015,7 +5477,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -5028,26 +5494,23 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_operations.metadata = {'url': '/deviceupdate/{instanceId}/management/operations'} # type: ignore + @distributed_trace def collect_logs( self, operation_id: str, - log_collection_request: JSONType, + log_collection_request: JSON, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Start the device diagnostics log collection operation on specified devices. :param operation_id: Operation identifier. :type operation_id: str :param log_collection_request: The deployment properties. - :type log_collection_request: JSONType - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str + :type log_collection_request: JSON :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -5055,7 +5518,8 @@ def collect_logs( # JSON input template you can fill out and use as your body input. log_collection_request = { - "createdDateTime": "str", # Optional. The timestamp when the operation was created. + "createdDateTime": "str", # Optional. The timestamp when the operation was + created. "description": "str", # Optional. Description of the diagnostics operation. "deviceList": [ { @@ -5063,14 +5527,17 @@ def collect_logs( "moduleId": "str" # Optional. Module Id. } ], - "lastActionDateTime": "str", # Optional. A timestamp for when the current state was entered. + "lastActionDateTime": "str", # Optional. A timestamp for when the current + state was entered. "operationId": "str", # Optional. The diagnostics operation id. - "status": "str" # Optional. Operation status. Possible values include: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". + "status": "str" # Optional. Operation status. Known values are: "Undefined", + "NotStarted", "Running", "Succeeded", "Failed". } # response body for status code(s): 201 response.json() == { - "createdDateTime": "str", # Optional. The timestamp when the operation was created. + "createdDateTime": "str", # Optional. The timestamp when the operation was + created. "description": "str", # Optional. Description of the diagnostics operation. "deviceList": [ { @@ -5078,19 +5545,24 @@ def collect_logs( "moduleId": "str" # Optional. Module Id. } ], - "lastActionDateTime": "str", # Optional. A timestamp for when the current state was entered. + "lastActionDateTime": "str", # Optional. A timestamp for when the current + state was entered. "operationId": "str", # Optional. The diagnostics operation id. - "status": "str" # Optional. Operation status. Possible values include: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". + "status": "str" # Optional. Operation status. Known values are: "Undefined", + "NotStarted", "Running", "Succeeded", "Failed". } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _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', "2021-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[JSON] _json = log_collection_request @@ -5100,13 +5572,19 @@ def collect_logs( api_version=api_version, content_type=content_type, json=_json, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -5119,11 +5597,10 @@ def collect_logs( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - collect_logs.metadata = {'url': '/deviceupdate/{instanceId}/management/deviceDiagnostics/logCollections/{operationId}'} # type: ignore @distributed_trace @@ -5131,16 +5608,13 @@ def get_log_collection_operation( self, operation_id: str, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Get the device diagnostics log collection operation. :param operation_id: Operation identifier. :type operation_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -5148,7 +5622,8 @@ def get_log_collection_operation( # response body for status code(s): 200 response.json() == { - "createdDateTime": "str", # Optional. The timestamp when the operation was created. + "createdDateTime": "str", # Optional. The timestamp when the operation was + created. "description": "str", # Optional. Description of the diagnostics operation. "deviceList": [ { @@ -5156,31 +5631,42 @@ def get_log_collection_operation( "moduleId": "str" # Optional. Module Id. } ], - "lastActionDateTime": "str", # Optional. A timestamp for when the current state was entered. + "lastActionDateTime": "str", # Optional. A timestamp for when the current + state was entered. "operationId": "str", # Optional. The diagnostics operation id. - "status": "str" # Optional. Operation status. Possible values include: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". + "status": "str" # Optional. Operation status. Known values are: "Undefined", + "NotStarted", "Running", "Succeeded", "Failed". } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_get_log_collection_operation_request( instance_id=self._config.instance_id, operation_id=operation_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -5193,25 +5679,21 @@ def get_log_collection_operation( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - get_log_collection_operation.metadata = {'url': '/deviceupdate/{instanceId}/management/deviceDiagnostics/logCollections/{operationId}'} # type: ignore @distributed_trace def list_log_collection_operations( self, **kwargs: Any - ) -> Iterable[JSONType]: + ) -> Iterable[JSON]: """Get all device diagnostics log collection operations. - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSONType] + :rtype: ~azure.core.paging.ItemPaged[JSON] :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -5222,50 +5704,61 @@ def list_log_collection_operations( "nextLink": "str", # Optional. The link to the next page of items. "value": [ { - "createdDateTime": "str", # Optional. The timestamp when the operation was created. - "description": "str", # Optional. Description of the diagnostics operation. + "createdDateTime": "str", # Optional. The timestamp when the + operation was created. + "description": "str", # Optional. Description of the + diagnostics operation. "deviceList": [ { "deviceId": "str", # Required. Device Id. "moduleId": "str" # Optional. Module Id. } ], - "lastActionDateTime": "str", # Optional. A timestamp for when the current state was entered. - "operationId": "str", # Optional. The diagnostics operation id. - "status": "str" # Optional. Operation status. Possible values include: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". + "lastActionDateTime": "str", # Optional. A timestamp for + when the current state was entered. + "operationId": "str", # Optional. The diagnostics operation + id. + "status": "str" # Optional. Operation status. Known values + are: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". } ] } """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_device_management_list_log_collection_operations_request( instance_id=self._config.instance_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore else: request = build_device_management_list_log_collection_operations_request( instance_id=self._config.instance_id, - api_version=api_version, + headers=_headers, + params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - request.url = self._client.format_url(next_link, **path_format_arguments) + request.url = self._client.format_url(next_link, **path_format_arguments) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), @@ -5274,7 +5767,7 @@ def prepare_request(next_link=None): return request def extract_data(pipeline_response): - deserialized = _loads(pipeline_response.http_response.body()) + deserialized = pipeline_response.http_response.json() list_of_elem = deserialized["value"] if cls: list_of_elem = cls(list_of_elem) @@ -5283,7 +5776,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -5296,23 +5793,20 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_log_collection_operations.metadata = {'url': '/deviceupdate/{instanceId}/management/deviceDiagnostics/logCollections'} # type: ignore + @distributed_trace def get_log_collection_operation_detailed_status( self, operation_id: str, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Get device diagnostics log collection operation with detailed status. :param operation_id: Operation identifier. :type operation_id: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -5320,43 +5814,57 @@ def get_log_collection_operation_detailed_status( # response body for status code(s): 200 response.json() == { - "createdDateTime": "str", # Optional. The timestamp when the operation was created. + "createdDateTime": "str", # Optional. The timestamp when the operation was + created. "description": "str", # Optional. Device diagnostics operation description. "deviceStatus": [ { "deviceId": "str", # Required. Device id. - "extendedResultCode": "str", # Optional. Log upload extended result code. + "extendedResultCode": "str", # Optional. Log upload extended + result code. "logLocation": "str", # Optional. Log upload location. "moduleId": "str", # Optional. Module id. "resultCode": "str", # Optional. Log upload result code. - "status": "str" # Required. Log upload status. Possible values include: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". + "status": "str" # Required. Log upload status. Known values + are: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". } ], - "lastActionDateTime": "str", # Optional. A timestamp for when the current state was entered. + "lastActionDateTime": "str", # Optional. A timestamp for when the current + state was entered. "operationId": "str", # Optional. The device diagnostics operation id. - "status": "str" # Optional. Operation status. Possible values include: "Undefined", "NotStarted", "Running", "Succeeded", "Failed". + "status": "str" # Optional. Operation status. Known values are: "Undefined", + "NotStarted", "Running", "Succeeded", "Failed". } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_get_log_collection_operation_detailed_status_request( instance_id=self._config.instance_id, operation_id=operation_id, api_version=api_version, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -5369,11 +5877,10 @@ def get_log_collection_operation_detailed_status( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - get_log_collection_operation_detailed_status.metadata = {'url': '/deviceupdate/{instanceId}/management/deviceDiagnostics/logCollections/{operationId}/detailedStatus'} # type: ignore @distributed_trace @@ -5384,7 +5891,7 @@ def stop_deployment( *, action: str, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Stops a deployment. :param group_id: Group identity. @@ -5393,11 +5900,8 @@ def stop_deployment( :type deployment_id: str :keyword action: Cancel deployment action. "cancel" :paramtype action: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -5407,9 +5911,12 @@ def stop_deployment( response.json() == { "deploymentId": "str", # Required. The deployment identifier. "groupId": "str", # Required. The group identity. - "isCanceled": bool, # Optional. Boolean flag indicating whether the deployment was canceled. - "isRetried": bool, # Optional. Boolean flag indicating whether the deployment has been retried. - "startDateTime": "2020-02-20 00:00:00", # Required. The deployment start datetime. + "isCanceled": bool, # Optional. Boolean flag indicating whether the + deployment was canceled. + "isRetried": bool, # Optional. Boolean flag indicating whether the + deployment has been retried. + "startDateTime": "2020-02-20 00:00:00", # Required. The deployment start + datetime. "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. @@ -5417,13 +5924,16 @@ def stop_deployment( } } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_stop_deployment_request( @@ -5432,13 +5942,19 @@ def stop_deployment( deployment_id=deployment_id, api_version=api_version, action=action, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -5451,11 +5967,10 @@ def stop_deployment( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - stop_deployment.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}'} # type: ignore @distributed_trace @@ -5466,7 +5981,7 @@ def retry_deployment( *, action: str, **kwargs: Any - ) -> JSONType: + ) -> JSON: """Retries a deployment with failed devices. :param group_id: Group identity. @@ -5475,11 +5990,8 @@ def retry_deployment( :type deployment_id: str :keyword action: Retry deployment action. "retry" :paramtype action: str - :keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that - overriding this default value may result in unsupported behavior. - :paramtype api_version: str :return: JSON object - :rtype: JSONType + :rtype: JSON :raises: ~azure.core.exceptions.HttpResponseError Example: @@ -5489,9 +6001,12 @@ def retry_deployment( response.json() == { "deploymentId": "str", # Required. The deployment identifier. "groupId": "str", # Required. The group identity. - "isCanceled": bool, # Optional. Boolean flag indicating whether the deployment was canceled. - "isRetried": bool, # Optional. Boolean flag indicating whether the deployment has been retried. - "startDateTime": "2020-02-20 00:00:00", # Required. The deployment start datetime. + "isCanceled": bool, # Optional. Boolean flag indicating whether the + deployment was canceled. + "isRetried": bool, # Optional. Boolean flag indicating whether the + deployment has been retried. + "startDateTime": "2020-02-20 00:00:00", # Required. The deployment start + datetime. "updateId": { "name": "str", # Required. Update name. "provider": "str", # Required. Update provider. @@ -5499,13 +6014,16 @@ def retry_deployment( } } """ - cls = kwargs.pop('cls', None) # type: ClsType[JSONType] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] request = build_device_management_retry_deployment_request( @@ -5514,13 +6032,19 @@ def retry_deployment( deployment_id=deployment_id, api_version=api_version, action=action, + headers=_headers, + params=_params, ) 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) + request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = 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]: @@ -5533,9 +6057,8 @@ def retry_deployment( deserialized = None if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) - return deserialized + return cast(JSON, deserialized) - retry_deployment.metadata = {'url': '/deviceupdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}'} # type: ignore diff --git a/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/operations/_patch.py b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 + """