diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/_meta.json b/sdk/deviceregistry/azure-mgmt-deviceregistry/_meta.json index 7cf4ecd7e565..c2be315806b6 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/_meta.json +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/_meta.json @@ -1,11 +1,11 @@ { - "commit": "1f6e89637068d59b5ae935de9a88d5742d12f8e6", + "commit": "ce183066e150dc49f27b52874facd569fcbb24ec", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.7", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.13.7", + "@autorest/python@6.19.0", "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/deviceregistry/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.13.7 --use=@autorest/modelerfour@4.27.0 --version=3.9.7 --version-tolerant=False", + "autorest_command": "autorest specification/deviceregistry/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/deviceregistry/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_configuration.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_configuration.py index 898a8906eb40..1f75f3fc2a03 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_configuration.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_configuration.py @@ -26,15 +26,15 @@ class DeviceRegistryMgmtClientConfiguration: # pylint: disable=too-many-instanc :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-11-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-11-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-11-01-preview") + api_version: str = kwargs.pop("api_version", "2024-11-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_device_registry_mgmt_client.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_device_registry_mgmt_client.py index a284048c9fe8..4e4466ae17cd 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_device_registry_mgmt_client.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_device_registry_mgmt_client.py @@ -8,6 +8,7 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse @@ -17,7 +18,13 @@ from . import models as _models from ._configuration import DeviceRegistryMgmtClientConfiguration from ._serialization import Deserializer, Serializer -from .operations import AssetEndpointProfilesOperations, AssetsOperations, OperationStatusOperations, Operations +from .operations import ( + AssetEndpointProfilesOperations, + AssetsOperations, + BillingContainersOperations, + OperationStatusOperations, + Operations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -34,16 +41,18 @@ class DeviceRegistryMgmtClient: # pylint: disable=client-accepts-api-version-ke azure.mgmt.deviceregistry.operations.AssetEndpointProfilesOperations :ivar assets: AssetsOperations operations :vartype assets: azure.mgmt.deviceregistry.operations.AssetsOperations + :ivar billing_containers: BillingContainersOperations operations + :vartype billing_containers: azure.mgmt.deviceregistry.operations.BillingContainersOperations :ivar operation_status: OperationStatusOperations operations :vartype operation_status: azure.mgmt.deviceregistry.operations.OperationStatusOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-11-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-11-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -88,6 +97,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) self.assets = AssetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.billing_containers = BillingContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operation_status = OperationStatusOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -117,7 +129,7 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: def close(self) -> None: self._client.close() - def __enter__(self) -> "DeviceRegistryMgmtClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_serialization.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_serialization.py index 2f781d740827..8139854b97bb 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_serialization.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_serialization.py @@ -144,6 +144,8 @@ def _json_attemp(data): # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -1441,7 +1443,7 @@ def _deserialize(self, target_obj, data): elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: attributes = response._attribute_map # type: ignore diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_vendor.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/_configuration.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/_configuration.py index f1b77da3c54b..901b6e60bea4 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/_configuration.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/_configuration.py @@ -26,15 +26,15 @@ class DeviceRegistryMgmtClientConfiguration: # pylint: disable=too-many-instanc :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-11-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-11-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-11-01-preview") + api_version: str = kwargs.pop("api_version", "2024-11-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/_device_registry_mgmt_client.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/_device_registry_mgmt_client.py index b3daef9315a7..fda436ed026f 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/_device_registry_mgmt_client.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/_device_registry_mgmt_client.py @@ -8,6 +8,7 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest @@ -17,7 +18,13 @@ from .. import models as _models from .._serialization import Deserializer, Serializer from ._configuration import DeviceRegistryMgmtClientConfiguration -from .operations import AssetEndpointProfilesOperations, AssetsOperations, OperationStatusOperations, Operations +from .operations import ( + AssetEndpointProfilesOperations, + AssetsOperations, + BillingContainersOperations, + OperationStatusOperations, + Operations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -34,16 +41,19 @@ class DeviceRegistryMgmtClient: # pylint: disable=client-accepts-api-version-ke azure.mgmt.deviceregistry.aio.operations.AssetEndpointProfilesOperations :ivar assets: AssetsOperations operations :vartype assets: azure.mgmt.deviceregistry.aio.operations.AssetsOperations + :ivar billing_containers: BillingContainersOperations operations + :vartype billing_containers: + azure.mgmt.deviceregistry.aio.operations.BillingContainersOperations :ivar operation_status: OperationStatusOperations operations :vartype operation_status: azure.mgmt.deviceregistry.aio.operations.OperationStatusOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-11-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-11-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -88,6 +98,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) self.assets = AssetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.billing_containers = BillingContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operation_status = OperationStatusOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -119,7 +132,7 @@ def _send_request( async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "DeviceRegistryMgmtClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/__init__.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/__init__.py index aadcb130f776..2cf5f274bfff 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/__init__.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/__init__.py @@ -9,6 +9,7 @@ from ._operations import Operations from ._asset_endpoint_profiles_operations import AssetEndpointProfilesOperations from ._assets_operations import AssetsOperations +from ._billing_containers_operations import BillingContainersOperations from ._operation_status_operations import OperationStatusOperations from ._patch import __all__ as _patch_all @@ -19,6 +20,7 @@ "Operations", "AssetEndpointProfilesOperations", "AssetsOperations", + "BillingContainersOperations", "OperationStatusOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/_asset_endpoint_profiles_operations.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/_asset_endpoint_profiles_operations.py index 905d3f5691a8..51b968ab3924 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/_asset_endpoint_profiles_operations.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/_asset_endpoint_profiles_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._asset_endpoint_profiles_operations import ( build_create_or_replace_request, build_delete_request, @@ -40,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,7 +84,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AssetEnd api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AssetEndpointProfileListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,7 +101,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -112,7 +116,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -163,7 +166,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AssetEndpointProfileListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -181,7 +184,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -197,7 +199,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -242,7 +243,7 @@ async def get( :rtype: ~azure.mgmt.deviceregistry.models.AssetEndpointProfile :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -264,7 +265,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -279,7 +279,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AssetEndpointProfile", pipeline_response) + deserialized = self._deserialize("AssetEndpointProfile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -292,8 +292,8 @@ async def _create_or_replace_initial( asset_endpoint_profile_name: str, resource: Union[_models.AssetEndpointProfile, IO[bytes]], **kwargs: Any - ) -> _models.AssetEndpointProfile: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -306,7 +306,7 @@ async def _create_or_replace_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AssetEndpointProfile] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -327,10 +327,10 @@ async def _create_or_replace_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -338,18 +338,22 @@ async def _create_or_replace_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AssetEndpointProfile", pipeline_response) - if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("AssetEndpointProfile", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -459,10 +463,11 @@ async def begin_create_or_replace( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AssetEndpointProfile", pipeline_response) + deserialized = self._deserialize("AssetEndpointProfile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -493,8 +498,8 @@ async def _update_initial( asset_endpoint_profile_name: str, properties: Union[_models.AssetEndpointProfileUpdate, IO[bytes]], **kwargs: Any - ) -> Optional[_models.AssetEndpointProfile]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -507,7 +512,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.AssetEndpointProfile]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -528,10 +533,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -539,19 +544,21 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AssetEndpointProfile", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -660,10 +667,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AssetEndpointProfile", pipeline_response) + deserialized = self._deserialize("AssetEndpointProfile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -687,10 +695,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, asset_endpoint_profile_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -702,7 +710,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -712,10 +720,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -723,6 +731,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -732,8 +744,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -759,7 +775,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, asset_endpoint_profile_name=asset_endpoint_profile_name, api_version=api_version, @@ -768,6 +784,7 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/_assets_operations.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/_assets_operations.py index 63219f51f37e..f541fa301258 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/_assets_operations.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/_assets_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._assets_operations import ( build_create_or_replace_request, build_delete_request, @@ -40,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,7 +82,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Asset"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AssetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -94,7 +99,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -110,7 +114,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -157,7 +160,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AssetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -175,7 +178,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -191,7 +193,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -234,7 +235,7 @@ async def get(self, resource_group_name: str, asset_name: str, **kwargs: Any) -> :rtype: ~azure.mgmt.deviceregistry.models.Asset :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -256,7 +257,6 @@ async def get(self, resource_group_name: str, asset_name: str, **kwargs: Any) -> headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -271,7 +271,7 @@ async def get(self, resource_group_name: str, asset_name: str, **kwargs: Any) -> error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Asset", pipeline_response) + deserialized = self._deserialize("Asset", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -280,8 +280,8 @@ async def get(self, resource_group_name: str, asset_name: str, **kwargs: Any) -> async def _create_or_replace_initial( self, resource_group_name: str, asset_name: str, resource: Union[_models.Asset, IO[bytes]], **kwargs: Any - ) -> _models.Asset: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -294,7 +294,7 @@ async def _create_or_replace_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Asset] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -315,10 +315,10 @@ async def _create_or_replace_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -326,18 +326,22 @@ async def _create_or_replace_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Asset", pipeline_response) - if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Asset", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -437,10 +441,11 @@ async def begin_create_or_replace( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Asset", pipeline_response) + deserialized = self._deserialize("Asset", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -471,8 +476,8 @@ async def _update_initial( asset_name: str, properties: Union[_models.AssetUpdate, IO[bytes]], **kwargs: Any - ) -> Optional[_models.Asset]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -485,7 +490,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.Asset]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -506,10 +511,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -517,19 +522,21 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Asset", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -632,10 +639,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Asset", pipeline_response) + deserialized = self._deserialize("Asset", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -659,10 +667,8 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, asset_name: str, **kwargs: Any - ) -> None: - error_map = { + async def _delete_initial(self, resource_group_name: str, asset_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -674,7 +680,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -684,10 +690,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -695,6 +701,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -704,8 +714,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, asset_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -729,7 +743,7 @@ async def begin_delete(self, resource_group_name: str, asset_name: str, **kwargs lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, asset_name=asset_name, api_version=api_version, @@ -738,6 +752,7 @@ async def begin_delete(self, resource_group_name: str, asset_name: str, **kwargs params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/_billing_containers_operations.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/_billing_containers_operations.py new file mode 100644 index 000000000000..f2e804b4cb42 --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/_billing_containers_operations.py @@ -0,0 +1,185 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._billing_containers_operations import build_get_request, build_list_by_subscription_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BillingContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.deviceregistry.aio.DeviceRegistryMgmtClient`'s + :attr:`billing_containers` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.BillingContainer"]: + """List BillingContainer resources by subscription ID. + + :return: An iterator like instance of either BillingContainer or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.deviceregistry.models.BillingContainer] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.BillingContainerListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BillingContainerListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, billing_container_name: str, **kwargs: Any) -> _models.BillingContainer: + """Get a BillingContainer. + + :param billing_container_name: Name of the billing container. Required. + :type billing_container_name: str + :return: BillingContainer or the result of cls(response) + :rtype: ~azure.mgmt.deviceregistry.models.BillingContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.BillingContainer] = kwargs.pop("cls", None) + + _request = build_get_request( + billing_container_name=billing_container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BillingContainer", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/_operation_status_operations.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/_operation_status_operations.py index 94b988749a3c..8a17da6dda6e 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/_operation_status_operations.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/_operation_status_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operation_status_operations import build_get_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +57,7 @@ def __init__(self, *args, **kwargs) -> None: async def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.OperationStatusResult: """Returns the current status of an async operation. - :param location: The name of Azure region. Required. + :param location: The name of the Azure region. Required. :type location: str :param operation_id: The ID of an ongoing async operation. Required. :type operation_id: str @@ -62,7 +65,7 @@ async def get(self, location: str, operation_id: str, **kwargs: Any) -> _models. :rtype: ~azure.mgmt.deviceregistry.models.OperationStatusResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -84,7 +87,6 @@ async def get(self, location: str, operation_id: str, **kwargs: Any) -> _models. headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -99,7 +101,7 @@ async def get(self, location: str, operation_id: str, **kwargs: Any) -> _models. error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OperationStatusResult", pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/_operations.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/_operations.py index 9fad95233545..69067ff38242 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/_operations.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -66,7 +69,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,7 +85,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -98,7 +100,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/models/__init__.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/models/__init__.py index cdb074ea7233..4a411231a3d2 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/models/__init__.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/models/__init__.py @@ -10,44 +10,56 @@ from ._models_py3 import AssetEndpointProfile from ._models_py3 import AssetEndpointProfileListResult from ._models_py3 import AssetEndpointProfileProperties +from ._models_py3 import AssetEndpointProfileStatus +from ._models_py3 import AssetEndpointProfileStatusError from ._models_py3 import AssetEndpointProfileUpdate from ._models_py3 import AssetEndpointProfileUpdateProperties from ._models_py3 import AssetListResult from ._models_py3 import AssetProperties from ._models_py3 import AssetStatus +from ._models_py3 import AssetStatusDataset from ._models_py3 import AssetStatusError +from ._models_py3 import AssetStatusEvent from ._models_py3 import AssetUpdate from ._models_py3 import AssetUpdateProperties +from ._models_py3 import Authentication +from ._models_py3 import AuthenticationUpdate +from ._models_py3 import BillingContainer +from ._models_py3 import BillingContainerListResult +from ._models_py3 import BillingContainerProperties from ._models_py3 import DataPoint +from ._models_py3 import DataPointBase +from ._models_py3 import Dataset from ._models_py3 import ErrorAdditionalInfo from ._models_py3 import ErrorDetail from ._models_py3 import ErrorResponse from ._models_py3 import Event +from ._models_py3 import EventBase from ._models_py3 import ExtendedLocation +from ._models_py3 import MessageSchemaReference from ._models_py3 import Operation from ._models_py3 import OperationDisplay from ._models_py3 import OperationListResult from ._models_py3 import OperationStatusResult -from ._models_py3 import OwnCertificate +from ._models_py3 import ProxyResource from ._models_py3 import Resource from ._models_py3 import SystemData +from ._models_py3 import Topic +from ._models_py3 import TopicUpdate from ._models_py3 import TrackedResource -from ._models_py3 import TransportAuthentication -from ._models_py3 import TransportAuthenticationUpdate -from ._models_py3 import UserAuthentication -from ._models_py3 import UserAuthenticationUpdate from ._models_py3 import UsernamePasswordCredentials from ._models_py3 import UsernamePasswordCredentialsUpdate from ._models_py3 import X509Credentials from ._models_py3 import X509CredentialsUpdate from ._device_registry_mgmt_client_enums import ActionType +from ._device_registry_mgmt_client_enums import AuthenticationMethod from ._device_registry_mgmt_client_enums import CreatedByType -from ._device_registry_mgmt_client_enums import DataPointsObservabilityMode -from ._device_registry_mgmt_client_enums import EventsObservabilityMode +from ._device_registry_mgmt_client_enums import DataPointObservabilityMode +from ._device_registry_mgmt_client_enums import EventObservabilityMode from ._device_registry_mgmt_client_enums import Origin from ._device_registry_mgmt_client_enums import ProvisioningState -from ._device_registry_mgmt_client_enums import UserAuthenticationMode +from ._device_registry_mgmt_client_enums import TopicRetainType from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk @@ -57,43 +69,55 @@ "AssetEndpointProfile", "AssetEndpointProfileListResult", "AssetEndpointProfileProperties", + "AssetEndpointProfileStatus", + "AssetEndpointProfileStatusError", "AssetEndpointProfileUpdate", "AssetEndpointProfileUpdateProperties", "AssetListResult", "AssetProperties", "AssetStatus", + "AssetStatusDataset", "AssetStatusError", + "AssetStatusEvent", "AssetUpdate", "AssetUpdateProperties", + "Authentication", + "AuthenticationUpdate", + "BillingContainer", + "BillingContainerListResult", + "BillingContainerProperties", "DataPoint", + "DataPointBase", + "Dataset", "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", "Event", + "EventBase", "ExtendedLocation", + "MessageSchemaReference", "Operation", "OperationDisplay", "OperationListResult", "OperationStatusResult", - "OwnCertificate", + "ProxyResource", "Resource", "SystemData", + "Topic", + "TopicUpdate", "TrackedResource", - "TransportAuthentication", - "TransportAuthenticationUpdate", - "UserAuthentication", - "UserAuthenticationUpdate", "UsernamePasswordCredentials", "UsernamePasswordCredentialsUpdate", "X509Credentials", "X509CredentialsUpdate", "ActionType", + "AuthenticationMethod", "CreatedByType", - "DataPointsObservabilityMode", - "EventsObservabilityMode", + "DataPointObservabilityMode", + "EventObservabilityMode", "Origin", "ProvisioningState", - "UserAuthenticationMode", + "TopicRetainType", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/models/_device_registry_mgmt_client_enums.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/models/_device_registry_mgmt_client_enums.py index 6b7a262920b0..718fe90dd11a 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/models/_device_registry_mgmt_client_enums.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/models/_device_registry_mgmt_client_enums.py @@ -16,6 +16,17 @@ class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): INTERNAL = "Internal" +class AuthenticationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the method to authenticate the user of the client at the server.""" + + ANONYMOUS = "Anonymous" + """The user authentication method is anonymous.""" + CERTIFICATE = "Certificate" + """The user authentication method is an x509 certificate.""" + USERNAME_PASSWORD = "UsernamePassword" + """The user authentication method is a username and password.""" + + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource.""" @@ -25,27 +36,27 @@ class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): KEY = "Key" -class DataPointsObservabilityMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): +class DataPointObservabilityMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """An indication of how the data point should be mapped to OpenTelemetry.""" - NONE = "none" + NONE = "None" """No mapping to OpenTelemetry.""" - COUNTER = "counter" + COUNTER = "Counter" """Map as counter to OpenTelemetry.""" - GAUGE = "gauge" + GAUGE = "Gauge" """Map as gauge to OpenTelemetry.""" - HISTOGRAM = "histogram" + HISTOGRAM = "Histogram" """Map as histogram to OpenTelemetry.""" - LOG = "log" + LOG = "Log" """Map as log to OpenTelemetry.""" -class EventsObservabilityMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): +class EventObservabilityMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """An indication of how the event should be mapped to OpenTelemetry.""" - NONE = "none" + NONE = "None" """No mapping to OpenTelemetry.""" - LOG = "log" + LOG = "Log" """Map as log to OpenTelemetry.""" @@ -70,14 +81,16 @@ class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Resource creation was canceled.""" ACCEPTED = "Accepted" """Resource has been accepted by the server.""" + DELETING = "Deleting" + """Resource is deleting.""" -class UserAuthenticationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Defines the mode to authenticate the user of the client at the server.""" +class TopicRetainType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """When set to 'Keep', messages published to an MQTT broker will have the retain flag set. + Default: 'Never'. + """ - ANONYMOUS = "Anonymous" - """The user authentication mode is anonymous.""" - CERTIFICATE = "Certificate" - """The user authentication mode is an x509 certificate.""" - USERNAME_PASSWORD = "UsernamePassword" - """The user authentication mode is a username and password.""" + KEEP = "Keep" + """Retain the messages.""" + NEVER = "Never" + """Never retain messages.""" diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/models/_models_py3.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/models/_models_py3.py index 2edee9747b89..3625834c635d 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/models/_models_py3.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/models/_models_py3.py @@ -22,8 +22,8 @@ class Resource(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -66,8 +66,8 @@ class TrackedResource(Resource): All required parameters must be populated in order to send to server. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -119,8 +119,8 @@ class Asset(TrackedResource): All required parameters must be populated in order to send to server. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -191,8 +191,8 @@ class AssetEndpointProfile(TrackedResource): All required parameters must be populated in order to send to server. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -304,31 +304,42 @@ class AssetEndpointProfileProperties(_serialization.Model): The additionalConfiguration field holds further connector type specific configuration. Required. :vartype target_address: str - :ivar user_authentication: Defines the client authentication mechanism to the server. - :vartype user_authentication: ~azure.mgmt.deviceregistry.models.UserAuthentication - :ivar transport_authentication: Defines the authentication mechanism for the southbound - connector connecting to the shop floor/OT device. - :vartype transport_authentication: ~azure.mgmt.deviceregistry.models.TransportAuthentication - :ivar additional_configuration: Contains connectivity type specific further configuration (e.g. - OPC UA, Modbus, ONVIF). + :ivar endpoint_profile_type: Defines the configuration for the connector type that is being + used with the endpoint profile. Required. + :vartype endpoint_profile_type: str + :ivar authentication: Defines the client authentication mechanism to the server. + :vartype authentication: ~azure.mgmt.deviceregistry.models.Authentication + :ivar additional_configuration: Stringified JSON that contains connectivity type specific + further configuration (e.g. OPC UA, Modbus, ONVIF). :vartype additional_configuration: str + :ivar discovered_asset_endpoint_profile_ref: Reference to a discovered asset endpoint profile. + Populated only if the asset endpoint profile has been created from discovery flow. Discovered + asset endpoint profile name must be provided. + :vartype discovered_asset_endpoint_profile_ref: str + :ivar status: Read only object to reflect changes that have occurred on the Edge. Similar to + Kubernetes status property for custom resources. + :vartype status: ~azure.mgmt.deviceregistry.models.AssetEndpointProfileStatus :ivar provisioning_state: Provisioning state of the resource. Known values are: "Succeeded", - "Failed", "Canceled", and "Accepted". + "Failed", "Canceled", "Accepted", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.deviceregistry.models.ProvisioningState """ _validation = { "uuid": {"readonly": True}, "target_address": {"required": True}, + "endpoint_profile_type": {"required": True}, + "status": {"readonly": True}, "provisioning_state": {"readonly": True}, } _attribute_map = { "uuid": {"key": "uuid", "type": "str"}, "target_address": {"key": "targetAddress", "type": "str"}, - "user_authentication": {"key": "userAuthentication", "type": "UserAuthentication"}, - "transport_authentication": {"key": "transportAuthentication", "type": "TransportAuthentication"}, + "endpoint_profile_type": {"key": "endpointProfileType", "type": "str"}, + "authentication": {"key": "authentication", "type": "Authentication"}, "additional_configuration": {"key": "additionalConfiguration", "type": "str"}, + "discovered_asset_endpoint_profile_ref": {"key": "discoveredAssetEndpointProfileRef", "type": "str"}, + "status": {"key": "status", "type": "AssetEndpointProfileStatus"}, "provisioning_state": {"key": "provisioningState", "type": "str"}, } @@ -336,9 +347,10 @@ def __init__( self, *, target_address: str, - user_authentication: Optional["_models.UserAuthentication"] = None, - transport_authentication: Optional["_models.TransportAuthentication"] = None, + endpoint_profile_type: str, + authentication: Optional["_models.Authentication"] = None, additional_configuration: Optional[str] = None, + discovered_asset_endpoint_profile_ref: Optional[str] = None, **kwargs: Any ) -> None: """ @@ -347,30 +359,88 @@ def __init__( The additionalConfiguration field holds further connector type specific configuration. Required. :paramtype target_address: str - :keyword user_authentication: Defines the client authentication mechanism to the server. - :paramtype user_authentication: ~azure.mgmt.deviceregistry.models.UserAuthentication - :keyword transport_authentication: Defines the authentication mechanism for the southbound - connector connecting to the shop floor/OT device. - :paramtype transport_authentication: ~azure.mgmt.deviceregistry.models.TransportAuthentication - :keyword additional_configuration: Contains connectivity type specific further configuration - (e.g. OPC UA, Modbus, ONVIF). + :keyword endpoint_profile_type: Defines the configuration for the connector type that is being + used with the endpoint profile. Required. + :paramtype endpoint_profile_type: str + :keyword authentication: Defines the client authentication mechanism to the server. + :paramtype authentication: ~azure.mgmt.deviceregistry.models.Authentication + :keyword additional_configuration: Stringified JSON that contains connectivity type specific + further configuration (e.g. OPC UA, Modbus, ONVIF). :paramtype additional_configuration: str + :keyword discovered_asset_endpoint_profile_ref: Reference to a discovered asset endpoint + profile. Populated only if the asset endpoint profile has been created from discovery flow. + Discovered asset endpoint profile name must be provided. + :paramtype discovered_asset_endpoint_profile_ref: str """ super().__init__(**kwargs) self.uuid = None self.target_address = target_address - self.user_authentication = user_authentication - self.transport_authentication = transport_authentication + self.endpoint_profile_type = endpoint_profile_type + self.authentication = authentication self.additional_configuration = additional_configuration + self.discovered_asset_endpoint_profile_ref = discovered_asset_endpoint_profile_ref + self.status = None self.provisioning_state = None +class AssetEndpointProfileStatus(_serialization.Model): + """Defines the asset endpoint profile status properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar errors: Array object to transfer and persist errors that originate from the Edge. + :vartype errors: list[~azure.mgmt.deviceregistry.models.AssetEndpointProfileStatusError] + """ + + _validation = { + "errors": {"readonly": True}, + } + + _attribute_map = { + "errors": {"key": "errors", "type": "[AssetEndpointProfileStatusError]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.errors = None + + +class AssetEndpointProfileStatusError(_serialization.Model): + """Defines the asset endpoint profile status error properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Error code for classification of errors (ex: 400, 404, 500, etc.). + :vartype code: int + :ivar message: Human readable helpful error message to provide additional context for error + (ex: “targetAddress 'foo' is not a valid url”). + :vartype message: str + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "int"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + + class AssetEndpointProfileUpdate(_serialization.Model): """The type used for update operations of the AssetEndpointProfile. :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar properties: The updatable properties of the AssetEndpointProfile. + :ivar properties: The resource-specific properties for this resource. :vartype properties: ~azure.mgmt.deviceregistry.models.AssetEndpointProfileUpdateProperties """ @@ -389,7 +459,7 @@ def __init__( """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword properties: The updatable properties of the AssetEndpointProfile. + :keyword properties: The resource-specific properties for this resource. :paramtype properties: ~azure.mgmt.deviceregistry.models.AssetEndpointProfileUpdateProperties """ super().__init__(**kwargs) @@ -404,21 +474,20 @@ class AssetEndpointProfileUpdateProperties(_serialization.Model): southbound device. The scheme part of the targetAddress URI specifies the type of the device. The additionalConfiguration field holds further connector type specific configuration. :vartype target_address: str - :ivar user_authentication: Defines the client authentication mechanism to the server. - :vartype user_authentication: ~azure.mgmt.deviceregistry.models.UserAuthenticationUpdate - :ivar transport_authentication: Defines the authentication mechanism for the southbound - connector connecting to the shop floor/OT device. - :vartype transport_authentication: - ~azure.mgmt.deviceregistry.models.TransportAuthenticationUpdate - :ivar additional_configuration: Contains connectivity type specific further configuration (e.g. - OPC UA, Modbus, ONVIF). + :ivar endpoint_profile_type: Defines the configuration for the connector type that is being + used with the endpoint profile. + :vartype endpoint_profile_type: str + :ivar authentication: Defines the client authentication mechanism to the server. + :vartype authentication: ~azure.mgmt.deviceregistry.models.AuthenticationUpdate + :ivar additional_configuration: Stringified JSON that contains connectivity type specific + further configuration (e.g. OPC UA, Modbus, ONVIF). :vartype additional_configuration: str """ _attribute_map = { "target_address": {"key": "targetAddress", "type": "str"}, - "user_authentication": {"key": "userAuthentication", "type": "UserAuthenticationUpdate"}, - "transport_authentication": {"key": "transportAuthentication", "type": "TransportAuthenticationUpdate"}, + "endpoint_profile_type": {"key": "endpointProfileType", "type": "str"}, + "authentication": {"key": "authentication", "type": "AuthenticationUpdate"}, "additional_configuration": {"key": "additionalConfiguration", "type": "str"}, } @@ -426,8 +495,8 @@ def __init__( self, *, target_address: Optional[str] = None, - user_authentication: Optional["_models.UserAuthenticationUpdate"] = None, - transport_authentication: Optional["_models.TransportAuthenticationUpdate"] = None, + endpoint_profile_type: Optional[str] = None, + authentication: Optional["_models.AuthenticationUpdate"] = None, additional_configuration: Optional[str] = None, **kwargs: Any ) -> None: @@ -436,20 +505,19 @@ def __init__( southbound device. The scheme part of the targetAddress URI specifies the type of the device. The additionalConfiguration field holds further connector type specific configuration. :paramtype target_address: str - :keyword user_authentication: Defines the client authentication mechanism to the server. - :paramtype user_authentication: ~azure.mgmt.deviceregistry.models.UserAuthenticationUpdate - :keyword transport_authentication: Defines the authentication mechanism for the southbound - connector connecting to the shop floor/OT device. - :paramtype transport_authentication: - ~azure.mgmt.deviceregistry.models.TransportAuthenticationUpdate - :keyword additional_configuration: Contains connectivity type specific further configuration - (e.g. OPC UA, Modbus, ONVIF). + :keyword endpoint_profile_type: Defines the configuration for the connector type that is being + used with the endpoint profile. + :paramtype endpoint_profile_type: str + :keyword authentication: Defines the client authentication mechanism to the server. + :paramtype authentication: ~azure.mgmt.deviceregistry.models.AuthenticationUpdate + :keyword additional_configuration: Stringified JSON that contains connectivity type specific + further configuration (e.g. OPC UA, Modbus, ONVIF). :paramtype additional_configuration: str """ super().__init__(**kwargs) self.target_address = target_address - self.user_authentication = user_authentication - self.transport_authentication = transport_authentication + self.endpoint_profile_type = endpoint_profile_type + self.authentication = authentication self.additional_configuration = additional_configuration @@ -494,8 +562,6 @@ class AssetProperties(_serialization.Model): # pylint: disable=too-many-instanc :ivar uuid: Globally unique, immutable, non-reusable id. :vartype uuid: str - :ivar asset_type: Resource path to asset type (model) definition. - :vartype asset_type: str :ivar enabled: Enabled/Disabled status of the asset. :vartype enabled: bool :ivar external_asset_id: Asset id provided by the customer. @@ -504,10 +570,10 @@ class AssetProperties(_serialization.Model): # pylint: disable=too-many-instanc :vartype display_name: str :ivar description: Human-readable description of the asset. :vartype description: str - :ivar asset_endpoint_profile_uri: A reference to the asset endpoint profile (connection + :ivar asset_endpoint_profile_ref: A reference to the asset endpoint profile (connection information) used by brokers to connect to an endpoint that provides data points for this - asset. Must have the format /. Required. - :vartype asset_endpoint_profile_uri: str + asset. Must provide asset endpoint profile name. Required. + :vartype asset_endpoint_profile_ref: str :ivar version: An integer that is incremented each time the resource is modified. :vartype version: int :ivar manufacturer: Asset manufacturer name. @@ -528,33 +594,36 @@ class AssetProperties(_serialization.Model): # pylint: disable=too-many-instanc :vartype serial_number: str :ivar attributes: A set of key-value pairs that contain custom attributes set by the customer. :vartype attributes: dict[str, any] - :ivar default_data_points_configuration: Protocol-specific default configuration for all data - points. Each data point can have its own configuration that overrides the default settings - here. This assumes that each asset instance has one protocol. - :vartype default_data_points_configuration: str - :ivar default_events_configuration: Protocol-specific default configuration for all events. - Each event can have its own configuration that overrides the default settings here. This - assumes that each asset instance has one protocol. + :ivar discovered_asset_refs: Reference to a list of discovered assets. Populated only if the + asset has been created from discovery flow. Discovered asset names must be provided. + :vartype discovered_asset_refs: list[str] + :ivar default_datasets_configuration: Stringified JSON that contains connector-specific default + configuration for all datasets. Each dataset can have its own configuration that overrides the + default settings here. + :vartype default_datasets_configuration: str + :ivar default_events_configuration: Stringified JSON that contains connector-specific default + configuration for all events. Each event can have its own configuration that overrides the + default settings here. :vartype default_events_configuration: str - :ivar data_points: Array of data points that are part of the asset. Each data point can - reference an asset type capability and have per-data point configuration. See below for more - details for the definition of the dataPoints element. - :vartype data_points: list[~azure.mgmt.deviceregistry.models.DataPoint] - :ivar events: Array of events that are part of the asset. Each event can reference an asset - type capability and have per-event configuration. See below for more details about the - definition of the events element. + :ivar default_topic: Object that describes the default topic information for the asset. + :vartype default_topic: ~azure.mgmt.deviceregistry.models.Topic + :ivar datasets: Array of datasets that are part of the asset. Each dataset describes the data + points that make up the set. + :vartype datasets: list[~azure.mgmt.deviceregistry.models.Dataset] + :ivar events: Array of events that are part of the asset. Each event can have per-event + configuration. :vartype events: list[~azure.mgmt.deviceregistry.models.Event] :ivar status: Read only object to reflect changes that have occurred on the Edge. Similar to Kubernetes status property for custom resources. :vartype status: ~azure.mgmt.deviceregistry.models.AssetStatus :ivar provisioning_state: Provisioning state of the resource. Known values are: "Succeeded", - "Failed", "Canceled", and "Accepted". + "Failed", "Canceled", "Accepted", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.deviceregistry.models.ProvisioningState """ _validation = { "uuid": {"readonly": True}, - "asset_endpoint_profile_uri": {"required": True}, + "asset_endpoint_profile_ref": {"required": True}, "version": {"readonly": True}, "status": {"readonly": True}, "provisioning_state": {"readonly": True}, @@ -562,12 +631,11 @@ class AssetProperties(_serialization.Model): # pylint: disable=too-many-instanc _attribute_map = { "uuid": {"key": "uuid", "type": "str"}, - "asset_type": {"key": "assetType", "type": "str"}, "enabled": {"key": "enabled", "type": "bool"}, "external_asset_id": {"key": "externalAssetId", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "description": {"key": "description", "type": "str"}, - "asset_endpoint_profile_uri": {"key": "assetEndpointProfileUri", "type": "str"}, + "asset_endpoint_profile_ref": {"key": "assetEndpointProfileRef", "type": "str"}, "version": {"key": "version", "type": "int"}, "manufacturer": {"key": "manufacturer", "type": "str"}, "manufacturer_uri": {"key": "manufacturerUri", "type": "str"}, @@ -578,19 +646,20 @@ class AssetProperties(_serialization.Model): # pylint: disable=too-many-instanc "documentation_uri": {"key": "documentationUri", "type": "str"}, "serial_number": {"key": "serialNumber", "type": "str"}, "attributes": {"key": "attributes", "type": "{object}"}, - "default_data_points_configuration": {"key": "defaultDataPointsConfiguration", "type": "str"}, + "discovered_asset_refs": {"key": "discoveredAssetRefs", "type": "[str]"}, + "default_datasets_configuration": {"key": "defaultDatasetsConfiguration", "type": "str"}, "default_events_configuration": {"key": "defaultEventsConfiguration", "type": "str"}, - "data_points": {"key": "dataPoints", "type": "[DataPoint]"}, + "default_topic": {"key": "defaultTopic", "type": "Topic"}, + "datasets": {"key": "datasets", "type": "[Dataset]"}, "events": {"key": "events", "type": "[Event]"}, "status": {"key": "status", "type": "AssetStatus"}, "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( + def __init__( # pylint: disable=too-many-locals self, *, - asset_endpoint_profile_uri: str, - asset_type: Optional[str] = None, + asset_endpoint_profile_ref: str, enabled: Optional[bool] = None, external_asset_id: Optional[str] = None, display_name: Optional[str] = None, @@ -604,15 +673,15 @@ def __init__( documentation_uri: Optional[str] = None, serial_number: Optional[str] = None, attributes: Optional[Dict[str, Any]] = None, - default_data_points_configuration: Optional[str] = None, + discovered_asset_refs: Optional[List[str]] = None, + default_datasets_configuration: Optional[str] = None, default_events_configuration: Optional[str] = None, - data_points: Optional[List["_models.DataPoint"]] = None, + default_topic: Optional["_models.Topic"] = None, + datasets: Optional[List["_models.Dataset"]] = None, events: Optional[List["_models.Event"]] = None, **kwargs: Any ) -> None: """ - :keyword asset_type: Resource path to asset type (model) definition. - :paramtype asset_type: str :keyword enabled: Enabled/Disabled status of the asset. :paramtype enabled: bool :keyword external_asset_id: Asset id provided by the customer. @@ -621,10 +690,10 @@ def __init__( :paramtype display_name: str :keyword description: Human-readable description of the asset. :paramtype description: str - :keyword asset_endpoint_profile_uri: A reference to the asset endpoint profile (connection + :keyword asset_endpoint_profile_ref: A reference to the asset endpoint profile (connection information) used by brokers to connect to an endpoint that provides data points for this - asset. Must have the format /. Required. - :paramtype asset_endpoint_profile_uri: str + asset. Must provide asset endpoint profile name. Required. + :paramtype asset_endpoint_profile_ref: str :keyword manufacturer: Asset manufacturer name. :paramtype manufacturer: str :keyword manufacturer_uri: Asset manufacturer URI. @@ -644,31 +713,33 @@ def __init__( :keyword attributes: A set of key-value pairs that contain custom attributes set by the customer. :paramtype attributes: dict[str, any] - :keyword default_data_points_configuration: Protocol-specific default configuration for all - data points. Each data point can have its own configuration that overrides the default settings - here. This assumes that each asset instance has one protocol. - :paramtype default_data_points_configuration: str - :keyword default_events_configuration: Protocol-specific default configuration for all events. - Each event can have its own configuration that overrides the default settings here. This - assumes that each asset instance has one protocol. + :keyword discovered_asset_refs: Reference to a list of discovered assets. Populated only if the + asset has been created from discovery flow. Discovered asset names must be provided. + :paramtype discovered_asset_refs: list[str] + :keyword default_datasets_configuration: Stringified JSON that contains connector-specific + default configuration for all datasets. Each dataset can have its own configuration that + overrides the default settings here. + :paramtype default_datasets_configuration: str + :keyword default_events_configuration: Stringified JSON that contains connector-specific + default configuration for all events. Each event can have its own configuration that overrides + the default settings here. :paramtype default_events_configuration: str - :keyword data_points: Array of data points that are part of the asset. Each data point can - reference an asset type capability and have per-data point configuration. See below for more - details for the definition of the dataPoints element. - :paramtype data_points: list[~azure.mgmt.deviceregistry.models.DataPoint] - :keyword events: Array of events that are part of the asset. Each event can reference an asset - type capability and have per-event configuration. See below for more details about the - definition of the events element. + :keyword default_topic: Object that describes the default topic information for the asset. + :paramtype default_topic: ~azure.mgmt.deviceregistry.models.Topic + :keyword datasets: Array of datasets that are part of the asset. Each dataset describes the + data points that make up the set. + :paramtype datasets: list[~azure.mgmt.deviceregistry.models.Dataset] + :keyword events: Array of events that are part of the asset. Each event can have per-event + configuration. :paramtype events: list[~azure.mgmt.deviceregistry.models.Event] """ super().__init__(**kwargs) self.uuid = None - self.asset_type = asset_type self.enabled = enabled self.external_asset_id = external_asset_id self.display_name = display_name self.description = description - self.asset_endpoint_profile_uri = asset_endpoint_profile_uri + self.asset_endpoint_profile_ref = asset_endpoint_profile_ref self.version = None self.manufacturer = manufacturer self.manufacturer_uri = manufacturer_uri @@ -679,9 +750,11 @@ def __init__( self.documentation_uri = documentation_uri self.serial_number = serial_number self.attributes = attributes - self.default_data_points_configuration = default_data_points_configuration + self.discovered_asset_refs = discovered_asset_refs + self.default_datasets_configuration = default_datasets_configuration self.default_events_configuration = default_events_configuration - self.data_points = data_points + self.default_topic = default_topic + self.datasets = datasets self.events = events self.status = None self.provisioning_state = None @@ -690,6 +763,8 @@ def __init__( class AssetStatus(_serialization.Model): """Defines the asset status properties. + Variables are only populated by the server, and will be ignored when sending a request. + :ivar errors: Array object to transfer and persist errors that originate from the Edge. :vartype errors: list[~azure.mgmt.deviceregistry.models.AssetStatusError] :ivar version: A read only incremental counter indicating the number of times the configuration @@ -697,33 +772,71 @@ class AssetStatus(_serialization.Model): would be the only writer of this value and would sync back up to the cloud. In steady state, this should equal version. :vartype version: int + :ivar datasets: Array of dataset statuses that describe the status of each dataset. + :vartype datasets: list[~azure.mgmt.deviceregistry.models.AssetStatusDataset] + :ivar events: Array of event statuses that describe the status of each event. + :vartype events: list[~azure.mgmt.deviceregistry.models.AssetStatusEvent] """ + _validation = { + "errors": {"readonly": True}, + "version": {"readonly": True}, + "datasets": {"readonly": True}, + "events": {"readonly": True}, + } + _attribute_map = { "errors": {"key": "errors", "type": "[AssetStatusError]"}, "version": {"key": "version", "type": "int"}, + "datasets": {"key": "datasets", "type": "[AssetStatusDataset]"}, + "events": {"key": "events", "type": "[AssetStatusEvent]"}, } - def __init__( - self, *, errors: Optional[List["_models.AssetStatusError"]] = None, version: Optional[int] = None, **kwargs: Any - ) -> None: - """ - :keyword errors: Array object to transfer and persist errors that originate from the Edge. - :paramtype errors: list[~azure.mgmt.deviceregistry.models.AssetStatusError] - :keyword version: A read only incremental counter indicating the number of times the - configuration has been modified from the perspective of the current actual (Edge) state of the - Asset. Edge would be the only writer of this value and would sync back up to the cloud. In - steady state, this should equal version. - :paramtype version: int - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.errors = errors - self.version = version + self.errors = None + self.version = None + self.datasets = None + self.events = None + + +class AssetStatusDataset(_serialization.Model): + """Defines the asset status dataset properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar name: The name of the dataset. Must be unique within the status.datasets array. This name + is used to correlate between the spec and status dataset information. Required. + :vartype name: str + :ivar message_schema_reference: The message schema reference object. + :vartype message_schema_reference: ~azure.mgmt.deviceregistry.models.MessageSchemaReference + """ + + _validation = { + "name": {"required": True, "readonly": True}, + "message_schema_reference": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "message_schema_reference": {"key": "messageSchemaReference", "type": "MessageSchemaReference"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name = None + self.message_schema_reference = None class AssetStatusError(_serialization.Model): """Defines the asset status error properties. + Variables are only populated by the server, and will be ignored when sending a request. + :ivar code: Error code for classification of errors (ex: 400, 404, 500, etc.). :vartype code: int :ivar message: Human readable helpful error message to provide additional context for error @@ -731,22 +844,52 @@ class AssetStatusError(_serialization.Model): :vartype message: str """ + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + } + _attribute_map = { "code": {"key": "code", "type": "int"}, "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[int] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code for classification of errors (ex: 400, 404, 500, etc.). - :paramtype code: int - :keyword message: Human readable helpful error message to provide additional context for error - (ex: “capability Id 'foo' does not exist”). - :paramtype message: str - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.code = code - self.message = message + self.code = None + self.message = None + + +class AssetStatusEvent(_serialization.Model): + """Defines the asset status event properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar name: The name of the event. Must be unique within the status.events array. This name is + used to correlate between the spec and status event information. Required. + :vartype name: str + :ivar message_schema_reference: The message schema reference object. + :vartype message_schema_reference: ~azure.mgmt.deviceregistry.models.MessageSchemaReference + """ + + _validation = { + "name": {"required": True, "readonly": True}, + "message_schema_reference": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "message_schema_reference": {"key": "messageSchemaReference", "type": "MessageSchemaReference"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name = None + self.message_schema_reference = None class AssetUpdate(_serialization.Model): @@ -754,7 +897,7 @@ class AssetUpdate(_serialization.Model): :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar properties: The updatable properties of the Asset. + :ivar properties: The resource-specific properties for this resource. :vartype properties: ~azure.mgmt.deviceregistry.models.AssetUpdateProperties """ @@ -773,7 +916,7 @@ def __init__( """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword properties: The updatable properties of the Asset. + :keyword properties: The resource-specific properties for this resource. :paramtype properties: ~azure.mgmt.deviceregistry.models.AssetUpdateProperties """ super().__init__(**kwargs) @@ -784,8 +927,6 @@ def __init__( class AssetUpdateProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """The updatable properties of the Asset. - :ivar asset_type: Resource path to asset type (model) definition. - :vartype asset_type: str :ivar enabled: Enabled/Disabled status of the asset. :vartype enabled: bool :ivar display_name: Human-readable display name. @@ -810,26 +951,25 @@ class AssetUpdateProperties(_serialization.Model): # pylint: disable=too-many-i :vartype serial_number: str :ivar attributes: A set of key-value pairs that contain custom attributes set by the customer. :vartype attributes: dict[str, any] - :ivar default_data_points_configuration: Protocol-specific default configuration for all data - points. Each data point can have its own configuration that overrides the default settings - here. This assumes that each asset instance has one protocol. - :vartype default_data_points_configuration: str - :ivar default_events_configuration: Protocol-specific default configuration for all events. - Each event can have its own configuration that overrides the default settings here. This - assumes that each asset instance has one protocol. + :ivar default_datasets_configuration: Stringified JSON that contains connector-specific default + configuration for all datasets. Each dataset can have its own configuration that overrides the + default settings here. + :vartype default_datasets_configuration: str + :ivar default_events_configuration: Stringified JSON that contains connector-specific default + configuration for all events. Each event can have its own configuration that overrides the + default settings here. :vartype default_events_configuration: str - :ivar data_points: Array of data points that are part of the asset. Each data point can - reference an asset type capability and have per-data point configuration. See below for more - details for the definition of the dataPoints element. - :vartype data_points: list[~azure.mgmt.deviceregistry.models.DataPoint] - :ivar events: Array of events that are part of the asset. Each event can reference an asset - type capability and have per-event configuration. See below for more details about the - definition of the events element. + :ivar default_topic: Object that describes the default topic information for the asset. + :vartype default_topic: ~azure.mgmt.deviceregistry.models.TopicUpdate + :ivar datasets: Array of datasets that are part of the asset. Each dataset describes the data + points that make up the set. + :vartype datasets: list[~azure.mgmt.deviceregistry.models.Dataset] + :ivar events: Array of events that are part of the asset. Each event can have per-event + configuration. :vartype events: list[~azure.mgmt.deviceregistry.models.Event] """ _attribute_map = { - "asset_type": {"key": "assetType", "type": "str"}, "enabled": {"key": "enabled", "type": "bool"}, "display_name": {"key": "displayName", "type": "str"}, "description": {"key": "description", "type": "str"}, @@ -842,16 +982,16 @@ class AssetUpdateProperties(_serialization.Model): # pylint: disable=too-many-i "documentation_uri": {"key": "documentationUri", "type": "str"}, "serial_number": {"key": "serialNumber", "type": "str"}, "attributes": {"key": "attributes", "type": "{object}"}, - "default_data_points_configuration": {"key": "defaultDataPointsConfiguration", "type": "str"}, + "default_datasets_configuration": {"key": "defaultDatasetsConfiguration", "type": "str"}, "default_events_configuration": {"key": "defaultEventsConfiguration", "type": "str"}, - "data_points": {"key": "dataPoints", "type": "[DataPoint]"}, + "default_topic": {"key": "defaultTopic", "type": "TopicUpdate"}, + "datasets": {"key": "datasets", "type": "[Dataset]"}, "events": {"key": "events", "type": "[Event]"}, } def __init__( self, *, - asset_type: Optional[str] = None, enabled: Optional[bool] = None, display_name: Optional[str] = None, description: Optional[str] = None, @@ -864,144 +1004,470 @@ def __init__( documentation_uri: Optional[str] = None, serial_number: Optional[str] = None, attributes: Optional[Dict[str, Any]] = None, - default_data_points_configuration: Optional[str] = None, + default_datasets_configuration: Optional[str] = None, default_events_configuration: Optional[str] = None, - data_points: Optional[List["_models.DataPoint"]] = None, + default_topic: Optional["_models.TopicUpdate"] = None, + datasets: Optional[List["_models.Dataset"]] = None, events: Optional[List["_models.Event"]] = None, **kwargs: Any ) -> None: """ - :keyword asset_type: Resource path to asset type (model) definition. - :paramtype asset_type: str - :keyword enabled: Enabled/Disabled status of the asset. - :paramtype enabled: bool - :keyword display_name: Human-readable display name. - :paramtype display_name: str - :keyword description: Human-readable description of the asset. - :paramtype description: str - :keyword manufacturer: Asset manufacturer name. - :paramtype manufacturer: str - :keyword manufacturer_uri: Asset manufacturer URI. - :paramtype manufacturer_uri: str - :keyword model: Asset model name. - :paramtype model: str - :keyword product_code: Asset product code. - :paramtype product_code: str - :keyword hardware_revision: Revision number of the hardware. - :paramtype hardware_revision: str - :keyword software_revision: Revision number of the software. - :paramtype software_revision: str - :keyword documentation_uri: Reference to the documentation. - :paramtype documentation_uri: str - :keyword serial_number: Asset serial number. - :paramtype serial_number: str - :keyword attributes: A set of key-value pairs that contain custom attributes set by the - customer. - :paramtype attributes: dict[str, any] - :keyword default_data_points_configuration: Protocol-specific default configuration for all - data points. Each data point can have its own configuration that overrides the default settings - here. This assumes that each asset instance has one protocol. - :paramtype default_data_points_configuration: str - :keyword default_events_configuration: Protocol-specific default configuration for all events. - Each event can have its own configuration that overrides the default settings here. This - assumes that each asset instance has one protocol. - :paramtype default_events_configuration: str - :keyword data_points: Array of data points that are part of the asset. Each data point can - reference an asset type capability and have per-data point configuration. See below for more - details for the definition of the dataPoints element. - :paramtype data_points: list[~azure.mgmt.deviceregistry.models.DataPoint] - :keyword events: Array of events that are part of the asset. Each event can reference an asset - type capability and have per-event configuration. See below for more details about the - definition of the events element. - :paramtype events: list[~azure.mgmt.deviceregistry.models.Event] + :keyword enabled: Enabled/Disabled status of the asset. + :paramtype enabled: bool + :keyword display_name: Human-readable display name. + :paramtype display_name: str + :keyword description: Human-readable description of the asset. + :paramtype description: str + :keyword manufacturer: Asset manufacturer name. + :paramtype manufacturer: str + :keyword manufacturer_uri: Asset manufacturer URI. + :paramtype manufacturer_uri: str + :keyword model: Asset model name. + :paramtype model: str + :keyword product_code: Asset product code. + :paramtype product_code: str + :keyword hardware_revision: Revision number of the hardware. + :paramtype hardware_revision: str + :keyword software_revision: Revision number of the software. + :paramtype software_revision: str + :keyword documentation_uri: Reference to the documentation. + :paramtype documentation_uri: str + :keyword serial_number: Asset serial number. + :paramtype serial_number: str + :keyword attributes: A set of key-value pairs that contain custom attributes set by the + customer. + :paramtype attributes: dict[str, any] + :keyword default_datasets_configuration: Stringified JSON that contains connector-specific + default configuration for all datasets. Each dataset can have its own configuration that + overrides the default settings here. + :paramtype default_datasets_configuration: str + :keyword default_events_configuration: Stringified JSON that contains connector-specific + default configuration for all events. Each event can have its own configuration that overrides + the default settings here. + :paramtype default_events_configuration: str + :keyword default_topic: Object that describes the default topic information for the asset. + :paramtype default_topic: ~azure.mgmt.deviceregistry.models.TopicUpdate + :keyword datasets: Array of datasets that are part of the asset. Each dataset describes the + data points that make up the set. + :paramtype datasets: list[~azure.mgmt.deviceregistry.models.Dataset] + :keyword events: Array of events that are part of the asset. Each event can have per-event + configuration. + :paramtype events: list[~azure.mgmt.deviceregistry.models.Event] + """ + super().__init__(**kwargs) + self.enabled = enabled + self.display_name = display_name + self.description = description + self.manufacturer = manufacturer + self.manufacturer_uri = manufacturer_uri + self.model = model + self.product_code = product_code + self.hardware_revision = hardware_revision + self.software_revision = software_revision + self.documentation_uri = documentation_uri + self.serial_number = serial_number + self.attributes = attributes + self.default_datasets_configuration = default_datasets_configuration + self.default_events_configuration = default_events_configuration + self.default_topic = default_topic + self.datasets = datasets + self.events = events + + +class Authentication(_serialization.Model): + """Definition of the client authentication mechanism to the server. + + All required parameters must be populated in order to send to server. + + :ivar method: Defines the method to authenticate the user of the client at the server. + Required. Known values are: "Anonymous", "Certificate", and "UsernamePassword". + :vartype method: str or ~azure.mgmt.deviceregistry.models.AuthenticationMethod + :ivar username_password_credentials: Defines the username and password references when + UsernamePassword user authentication mode is selected. + :vartype username_password_credentials: + ~azure.mgmt.deviceregistry.models.UsernamePasswordCredentials + :ivar x509_credentials: Defines the certificate reference when Certificate user authentication + mode is selected. + :vartype x509_credentials: ~azure.mgmt.deviceregistry.models.X509Credentials + """ + + _validation = { + "method": {"required": True}, + } + + _attribute_map = { + "method": {"key": "method", "type": "str"}, + "username_password_credentials": {"key": "usernamePasswordCredentials", "type": "UsernamePasswordCredentials"}, + "x509_credentials": {"key": "x509Credentials", "type": "X509Credentials"}, + } + + def __init__( + self, + *, + method: Union[str, "_models.AuthenticationMethod"], + username_password_credentials: Optional["_models.UsernamePasswordCredentials"] = None, + x509_credentials: Optional["_models.X509Credentials"] = None, + **kwargs: Any + ) -> None: + """ + :keyword method: Defines the method to authenticate the user of the client at the server. + Required. Known values are: "Anonymous", "Certificate", and "UsernamePassword". + :paramtype method: str or ~azure.mgmt.deviceregistry.models.AuthenticationMethod + :keyword username_password_credentials: Defines the username and password references when + UsernamePassword user authentication mode is selected. + :paramtype username_password_credentials: + ~azure.mgmt.deviceregistry.models.UsernamePasswordCredentials + :keyword x509_credentials: Defines the certificate reference when Certificate user + authentication mode is selected. + :paramtype x509_credentials: ~azure.mgmt.deviceregistry.models.X509Credentials + """ + super().__init__(**kwargs) + self.method = method + self.username_password_credentials = username_password_credentials + self.x509_credentials = x509_credentials + + +class AuthenticationUpdate(_serialization.Model): + """Definition of the client authentication mechanism to the server. + + :ivar method: Defines the method to authenticate the user of the client at the server. Known + values are: "Anonymous", "Certificate", and "UsernamePassword". + :vartype method: str or ~azure.mgmt.deviceregistry.models.AuthenticationMethod + :ivar username_password_credentials: Defines the username and password references when + UsernamePassword user authentication mode is selected. + :vartype username_password_credentials: + ~azure.mgmt.deviceregistry.models.UsernamePasswordCredentialsUpdate + :ivar x509_credentials: Defines the certificate reference when Certificate user authentication + mode is selected. + :vartype x509_credentials: ~azure.mgmt.deviceregistry.models.X509CredentialsUpdate + """ + + _attribute_map = { + "method": {"key": "method", "type": "str"}, + "username_password_credentials": { + "key": "usernamePasswordCredentials", + "type": "UsernamePasswordCredentialsUpdate", + }, + "x509_credentials": {"key": "x509Credentials", "type": "X509CredentialsUpdate"}, + } + + def __init__( + self, + *, + method: Optional[Union[str, "_models.AuthenticationMethod"]] = None, + username_password_credentials: Optional["_models.UsernamePasswordCredentialsUpdate"] = None, + x509_credentials: Optional["_models.X509CredentialsUpdate"] = None, + **kwargs: Any + ) -> None: + """ + :keyword method: Defines the method to authenticate the user of the client at the server. Known + values are: "Anonymous", "Certificate", and "UsernamePassword". + :paramtype method: str or ~azure.mgmt.deviceregistry.models.AuthenticationMethod + :keyword username_password_credentials: Defines the username and password references when + UsernamePassword user authentication mode is selected. + :paramtype username_password_credentials: + ~azure.mgmt.deviceregistry.models.UsernamePasswordCredentialsUpdate + :keyword x509_credentials: Defines the certificate reference when Certificate user + authentication mode is selected. + :paramtype x509_credentials: ~azure.mgmt.deviceregistry.models.X509CredentialsUpdate + """ + super().__init__(**kwargs) + self.method = method + self.username_password_credentials = username_password_credentials + self.x509_credentials = x509_credentials + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.deviceregistry.models.SystemData + """ + + +class BillingContainer(ProxyResource): + """billingContainer Model as Azure resource whose sole purpose is to keep track of billables + resources under a subscription. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.deviceregistry.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.deviceregistry.models.BillingContainerProperties + :ivar etag: Resource ETag. + :vartype etag: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "etag": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "BillingContainerProperties"}, + "etag": {"key": "etag", "type": "str"}, + } + + def __init__(self, *, properties: Optional["_models.BillingContainerProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: The resource-specific properties for this resource. + :paramtype properties: ~azure.mgmt.deviceregistry.models.BillingContainerProperties + """ + super().__init__(**kwargs) + self.properties = properties + self.etag = None + + +class BillingContainerListResult(_serialization.Model): + """The response of a BillingContainer list operation. + + All required parameters must be populated in order to send to server. + + :ivar value: The BillingContainer items on this page. Required. + :vartype value: list[~azure.mgmt.deviceregistry.models.BillingContainer] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[BillingContainer]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.BillingContainer"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The BillingContainer items on this page. Required. + :paramtype value: list[~azure.mgmt.deviceregistry.models.BillingContainer] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class BillingContainerProperties(_serialization.Model): + """Defines the billingContainer properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Succeeded", + "Failed", "Canceled", "Accepted", and "Deleting". + :vartype provisioning_state: str or ~azure.mgmt.deviceregistry.models.ProvisioningState + """ + + _validation = { + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.provisioning_state = None + + +class DataPointBase(_serialization.Model): + """Defines the data point properties. + + All required parameters must be populated in order to send to server. + + :ivar name: The name of the data point. Required. + :vartype name: str + :ivar data_source: The address of the source of the data in the asset (e.g. URL) so that a + client can access the data source on the asset. Required. + :vartype data_source: str + :ivar data_point_configuration: Stringified JSON that contains connector-specific configuration + for the data point. For OPC UA, this could include configuration like, publishingInterval, + samplingInterval, and queueSize. + :vartype data_point_configuration: str + """ + + _validation = { + "name": {"required": True}, + "data_source": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "data_source": {"key": "dataSource", "type": "str"}, + "data_point_configuration": {"key": "dataPointConfiguration", "type": "str"}, + } + + def __init__( + self, *, name: str, data_source: str, data_point_configuration: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword name: The name of the data point. Required. + :paramtype name: str + :keyword data_source: The address of the source of the data in the asset (e.g. URL) so that a + client can access the data source on the asset. Required. + :paramtype data_source: str + :keyword data_point_configuration: Stringified JSON that contains connector-specific + configuration for the data point. For OPC UA, this could include configuration like, + publishingInterval, samplingInterval, and queueSize. + :paramtype data_point_configuration: str """ super().__init__(**kwargs) - self.asset_type = asset_type - self.enabled = enabled - self.display_name = display_name - self.description = description - self.manufacturer = manufacturer - self.manufacturer_uri = manufacturer_uri - self.model = model - self.product_code = product_code - self.hardware_revision = hardware_revision - self.software_revision = software_revision - self.documentation_uri = documentation_uri - self.serial_number = serial_number - self.attributes = attributes - self.default_data_points_configuration = default_data_points_configuration - self.default_events_configuration = default_events_configuration - self.data_points = data_points - self.events = events + self.name = name + self.data_source = data_source + self.data_point_configuration = data_point_configuration -class DataPoint(_serialization.Model): +class DataPoint(DataPointBase): """Defines the data point properties. All required parameters must be populated in order to send to server. - :ivar name: The name of the data point. + :ivar name: The name of the data point. Required. :vartype name: str :ivar data_source: The address of the source of the data in the asset (e.g. URL) so that a client can access the data source on the asset. Required. :vartype data_source: str - :ivar capability_id: The path to the type definition of the capability (e.g. DTMI, OPC UA - information model node id, etc.), for example dtmi:com:example:Robot:_contents:__prop1;1. - :vartype capability_id: str + :ivar data_point_configuration: Stringified JSON that contains connector-specific configuration + for the data point. For OPC UA, this could include configuration like, publishingInterval, + samplingInterval, and queueSize. + :vartype data_point_configuration: str :ivar observability_mode: An indication of how the data point should be mapped to - OpenTelemetry. Known values are: "none", "counter", "gauge", "histogram", and "log". + OpenTelemetry. Known values are: "None", "Counter", "Gauge", "Histogram", and "Log". :vartype observability_mode: str or - ~azure.mgmt.deviceregistry.models.DataPointsObservabilityMode - :ivar data_point_configuration: Protocol-specific configuration for the data point. For OPC UA, - this could include configuration like, publishingInterval, samplingInterval, and queueSize. - :vartype data_point_configuration: str + ~azure.mgmt.deviceregistry.models.DataPointObservabilityMode """ _validation = { + "name": {"required": True}, "data_source": {"required": True}, } _attribute_map = { "name": {"key": "name", "type": "str"}, "data_source": {"key": "dataSource", "type": "str"}, - "capability_id": {"key": "capabilityId", "type": "str"}, - "observability_mode": {"key": "observabilityMode", "type": "str"}, "data_point_configuration": {"key": "dataPointConfiguration", "type": "str"}, + "observability_mode": {"key": "observabilityMode", "type": "str"}, } def __init__( self, *, + name: str, data_source: str, - name: Optional[str] = None, - capability_id: Optional[str] = None, - observability_mode: Union[str, "_models.DataPointsObservabilityMode"] = "none", data_point_configuration: Optional[str] = None, + observability_mode: Union[str, "_models.DataPointObservabilityMode"] = "None", **kwargs: Any ) -> None: """ - :keyword name: The name of the data point. + :keyword name: The name of the data point. Required. :paramtype name: str :keyword data_source: The address of the source of the data in the asset (e.g. URL) so that a client can access the data source on the asset. Required. :paramtype data_source: str - :keyword capability_id: The path to the type definition of the capability (e.g. DTMI, OPC UA - information model node id, etc.), for example dtmi:com:example:Robot:_contents:__prop1;1. - :paramtype capability_id: str + :keyword data_point_configuration: Stringified JSON that contains connector-specific + configuration for the data point. For OPC UA, this could include configuration like, + publishingInterval, samplingInterval, and queueSize. + :paramtype data_point_configuration: str :keyword observability_mode: An indication of how the data point should be mapped to - OpenTelemetry. Known values are: "none", "counter", "gauge", "histogram", and "log". + OpenTelemetry. Known values are: "None", "Counter", "Gauge", "Histogram", and "Log". :paramtype observability_mode: str or - ~azure.mgmt.deviceregistry.models.DataPointsObservabilityMode - :keyword data_point_configuration: Protocol-specific configuration for the data point. For OPC - UA, this could include configuration like, publishingInterval, samplingInterval, and queueSize. - :paramtype data_point_configuration: str + ~azure.mgmt.deviceregistry.models.DataPointObservabilityMode + """ + super().__init__( + name=name, data_source=data_source, data_point_configuration=data_point_configuration, **kwargs + ) + self.observability_mode = observability_mode + + +class Dataset(_serialization.Model): + """Defines the dataset properties. + + All required parameters must be populated in order to send to server. + + :ivar name: Name of the dataset. Required. + :vartype name: str + :ivar dataset_configuration: Stringified JSON that contains connector-specific JSON string that + describes configuration for the specific dataset. + :vartype dataset_configuration: str + :ivar topic: Object that describes the topic information for the specific dataset. + :vartype topic: ~azure.mgmt.deviceregistry.models.Topic + :ivar data_points: Array of data points that are part of the dataset. Each data point can have + per-data point configuration. + :vartype data_points: list[~azure.mgmt.deviceregistry.models.DataPoint] + """ + + _validation = { + "name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "dataset_configuration": {"key": "datasetConfiguration", "type": "str"}, + "topic": {"key": "topic", "type": "Topic"}, + "data_points": {"key": "dataPoints", "type": "[DataPoint]"}, + } + + def __init__( + self, + *, + name: str, + dataset_configuration: Optional[str] = None, + topic: Optional["_models.Topic"] = None, + data_points: Optional[List["_models.DataPoint"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the dataset. Required. + :paramtype name: str + :keyword dataset_configuration: Stringified JSON that contains connector-specific JSON string + that describes configuration for the specific dataset. + :paramtype dataset_configuration: str + :keyword topic: Object that describes the topic information for the specific dataset. + :paramtype topic: ~azure.mgmt.deviceregistry.models.Topic + :keyword data_points: Array of data points that are part of the dataset. Each data point can + have per-data point configuration. + :paramtype data_points: list[~azure.mgmt.deviceregistry.models.DataPoint] """ super().__init__(**kwargs) self.name = name - self.data_source = data_source - self.capability_id = capability_id - self.observability_mode = observability_mode - self.data_point_configuration = data_point_configuration + self.dataset_configuration = dataset_configuration + self.topic = topic + self.data_points = data_points class ErrorAdditionalInfo(_serialization.Model): @@ -1096,71 +1562,129 @@ def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: A self.error = error -class Event(_serialization.Model): +class EventBase(_serialization.Model): """Defines the event properties. All required parameters must be populated in order to send to server. - :ivar name: The name of the event. + :ivar name: The name of the event. Required. :vartype name: str :ivar event_notifier: The address of the notifier of the event in the asset (e.g. URL) so that a client can access the event on the asset. Required. :vartype event_notifier: str - :ivar capability_id: The path to the type definition of the capability (e.g. DTMI, OPC UA - information model node id, etc.), for example dtmi:com:example:Robot:_contents:__prop1;1. - :vartype capability_id: str - :ivar observability_mode: An indication of how the event should be mapped to OpenTelemetry. - Known values are: "none" and "log". - :vartype observability_mode: str or ~azure.mgmt.deviceregistry.models.EventsObservabilityMode - :ivar event_configuration: Protocol-specific configuration for the event. For OPC UA, this - could include configuration like, publishingInterval, samplingInterval, and queueSize. + :ivar event_configuration: Stringified JSON that contains connector-specific configuration for + the event. For OPC UA, this could include configuration like, publishingInterval, + samplingInterval, and queueSize. :vartype event_configuration: str + :ivar topic: Object that describes the topic information for the specific event. + :vartype topic: ~azure.mgmt.deviceregistry.models.Topic """ _validation = { + "name": {"required": True}, "event_notifier": {"required": True}, } _attribute_map = { "name": {"key": "name", "type": "str"}, "event_notifier": {"key": "eventNotifier", "type": "str"}, - "capability_id": {"key": "capabilityId", "type": "str"}, - "observability_mode": {"key": "observabilityMode", "type": "str"}, "event_configuration": {"key": "eventConfiguration", "type": "str"}, + "topic": {"key": "topic", "type": "Topic"}, } def __init__( self, *, + name: str, event_notifier: str, - name: Optional[str] = None, - capability_id: Optional[str] = None, - observability_mode: Union[str, "_models.EventsObservabilityMode"] = "none", event_configuration: Optional[str] = None, + topic: Optional["_models.Topic"] = None, **kwargs: Any ) -> None: """ - :keyword name: The name of the event. + :keyword name: The name of the event. Required. :paramtype name: str :keyword event_notifier: The address of the notifier of the event in the asset (e.g. URL) so that a client can access the event on the asset. Required. :paramtype event_notifier: str - :keyword capability_id: The path to the type definition of the capability (e.g. DTMI, OPC UA - information model node id, etc.), for example dtmi:com:example:Robot:_contents:__prop1;1. - :paramtype capability_id: str - :keyword observability_mode: An indication of how the event should be mapped to OpenTelemetry. - Known values are: "none" and "log". - :paramtype observability_mode: str or ~azure.mgmt.deviceregistry.models.EventsObservabilityMode - :keyword event_configuration: Protocol-specific configuration for the event. For OPC UA, this - could include configuration like, publishingInterval, samplingInterval, and queueSize. + :keyword event_configuration: Stringified JSON that contains connector-specific configuration + for the event. For OPC UA, this could include configuration like, publishingInterval, + samplingInterval, and queueSize. :paramtype event_configuration: str + :keyword topic: Object that describes the topic information for the specific event. + :paramtype topic: ~azure.mgmt.deviceregistry.models.Topic """ super().__init__(**kwargs) self.name = name self.event_notifier = event_notifier - self.capability_id = capability_id - self.observability_mode = observability_mode self.event_configuration = event_configuration + self.topic = topic + + +class Event(EventBase): + """Defines the event properties. + + All required parameters must be populated in order to send to server. + + :ivar name: The name of the event. Required. + :vartype name: str + :ivar event_notifier: The address of the notifier of the event in the asset (e.g. URL) so that + a client can access the event on the asset. Required. + :vartype event_notifier: str + :ivar event_configuration: Stringified JSON that contains connector-specific configuration for + the event. For OPC UA, this could include configuration like, publishingInterval, + samplingInterval, and queueSize. + :vartype event_configuration: str + :ivar topic: Object that describes the topic information for the specific event. + :vartype topic: ~azure.mgmt.deviceregistry.models.Topic + :ivar observability_mode: An indication of how the event should be mapped to OpenTelemetry. + Known values are: "None" and "Log". + :vartype observability_mode: str or ~azure.mgmt.deviceregistry.models.EventObservabilityMode + """ + + _validation = { + "name": {"required": True}, + "event_notifier": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "event_notifier": {"key": "eventNotifier", "type": "str"}, + "event_configuration": {"key": "eventConfiguration", "type": "str"}, + "topic": {"key": "topic", "type": "Topic"}, + "observability_mode": {"key": "observabilityMode", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + event_notifier: str, + event_configuration: Optional[str] = None, + topic: Optional["_models.Topic"] = None, + observability_mode: Union[str, "_models.EventObservabilityMode"] = "None", + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the event. Required. + :paramtype name: str + :keyword event_notifier: The address of the notifier of the event in the asset (e.g. URL) so + that a client can access the event on the asset. Required. + :paramtype event_notifier: str + :keyword event_configuration: Stringified JSON that contains connector-specific configuration + for the event. For OPC UA, this could include configuration like, publishingInterval, + samplingInterval, and queueSize. + :paramtype event_configuration: str + :keyword topic: Object that describes the topic information for the specific event. + :paramtype topic: ~azure.mgmt.deviceregistry.models.Topic + :keyword observability_mode: An indication of how the event should be mapped to OpenTelemetry. + Known values are: "None" and "Log". + :paramtype observability_mode: str or ~azure.mgmt.deviceregistry.models.EventObservabilityMode + """ + super().__init__( + name=name, event_notifier=event_notifier, event_configuration=event_configuration, topic=topic, **kwargs + ) + self.observability_mode = observability_mode class ExtendedLocation(_serialization.Model): @@ -1196,6 +1720,41 @@ def __init__(self, *, type: str, name: str, **kwargs: Any) -> None: self.name = name +class MessageSchemaReference(_serialization.Model): + """Defines the message schema reference properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar schema_registry_namespace: The message schema registry namespace. Required. + :vartype schema_registry_namespace: str + :ivar schema_name: The message schema name. Required. + :vartype schema_name: str + :ivar schema_version: The message schema version. Required. + :vartype schema_version: str + """ + + _validation = { + "schema_registry_namespace": {"required": True, "readonly": True}, + "schema_name": {"required": True, "readonly": True}, + "schema_version": {"required": True, "readonly": True}, + } + + _attribute_map = { + "schema_registry_namespace": {"key": "schemaRegistryNamespace", "type": "str"}, + "schema_name": {"key": "schemaName", "type": "str"}, + "schema_version": {"key": "schemaVersion", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.schema_registry_namespace = None + self.schema_name = None + self.schema_version = None + + class Operation(_serialization.Model): """Details of a REST API operation, returned from the Resource Provider Operations API. @@ -1320,10 +1879,15 @@ def __init__(self, **kwargs: Any) -> None: class OperationStatusResult(_serialization.Model): """The current status of an async operation. + Variables are only populated by the server, and will be ignored when sending a request. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified ID for the async operation. :vartype id: str + :ivar resource_id: Fully qualified ID of the resource against which the original async + operation was started. + :vartype resource_id: str :ivar name: Name of the async operation. :vartype name: str :ivar status: Operation status. Required. @@ -1341,12 +1905,14 @@ class OperationStatusResult(_serialization.Model): """ _validation = { + "resource_id": {"readonly": True}, "status": {"required": True}, "percent_complete": {"maximum": 100, "minimum": 0}, } _attribute_map = { "id": {"key": "id", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, "name": {"key": "name", "type": "str"}, "status": {"key": "status", "type": "str"}, "percent_complete": {"key": "percentComplete", "type": "float"}, @@ -1389,6 +1955,7 @@ def __init__( """ super().__init__(**kwargs) self.id = id + self.resource_id = None self.name = name self.status = status self.percent_complete = percent_complete @@ -1398,47 +1965,6 @@ def __init__( self.error = error -class OwnCertificate(_serialization.Model): - """Certificate or private key that can be used by the southbound connector connecting to the shop - floor/OT device. The accepted extensions are .der for certificates and .pfx/.pem for private - keys. - - :ivar cert_thumbprint: Certificate thumbprint. - :vartype cert_thumbprint: str - :ivar cert_secret_reference: Secret Reference name (cert and private key). - :vartype cert_secret_reference: str - :ivar cert_password_reference: Secret Reference Name (Pfx or Pem password). - :vartype cert_password_reference: str - """ - - _attribute_map = { - "cert_thumbprint": {"key": "certThumbprint", "type": "str"}, - "cert_secret_reference": {"key": "certSecretReference", "type": "str"}, - "cert_password_reference": {"key": "certPasswordReference", "type": "str"}, - } - - def __init__( - self, - *, - cert_thumbprint: Optional[str] = None, - cert_secret_reference: Optional[str] = None, - cert_password_reference: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword cert_thumbprint: Certificate thumbprint. - :paramtype cert_thumbprint: str - :keyword cert_secret_reference: Secret Reference name (cert and private key). - :paramtype cert_secret_reference: str - :keyword cert_password_reference: Secret Reference Name (Pfx or Pem password). - :paramtype cert_password_reference: str - """ - super().__init__(**kwargs) - self.cert_thumbprint = cert_thumbprint - self.cert_secret_reference = cert_secret_reference - self.cert_password_reference = cert_password_reference - - class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. @@ -1503,163 +2029,74 @@ def __init__( self.last_modified_at = last_modified_at -class TransportAuthentication(_serialization.Model): - """Definition of the authentication mechanism for the southbound connector. - - All required parameters must be populated in order to send to server. - - :ivar own_certificates: Defines a reference to a secret which contains all certificates and - private keys that can be used by the southbound connector connecting to the shop floor/OT - device. The accepted extensions are .der for certificates and .pfx/.pem for private keys. - Required. - :vartype own_certificates: list[~azure.mgmt.deviceregistry.models.OwnCertificate] - """ - - _validation = { - "own_certificates": {"required": True}, - } - - _attribute_map = { - "own_certificates": {"key": "ownCertificates", "type": "[OwnCertificate]"}, - } - - def __init__(self, *, own_certificates: List["_models.OwnCertificate"], **kwargs: Any) -> None: - """ - :keyword own_certificates: Defines a reference to a secret which contains all certificates and - private keys that can be used by the southbound connector connecting to the shop floor/OT - device. The accepted extensions are .der for certificates and .pfx/.pem for private keys. - Required. - :paramtype own_certificates: list[~azure.mgmt.deviceregistry.models.OwnCertificate] - """ - super().__init__(**kwargs) - self.own_certificates = own_certificates - - -class TransportAuthenticationUpdate(_serialization.Model): - """Definition of the authentication mechanism for the southbound connector. - - :ivar own_certificates: Defines a reference to a secret which contains all certificates and - private keys that can be used by the southbound connector connecting to the shop floor/OT - device. The accepted extensions are .der for certificates and .pfx/.pem for private keys. - :vartype own_certificates: list[~azure.mgmt.deviceregistry.models.OwnCertificate] - """ - - _attribute_map = { - "own_certificates": {"key": "ownCertificates", "type": "[OwnCertificate]"}, - } - - def __init__(self, *, own_certificates: Optional[List["_models.OwnCertificate"]] = None, **kwargs: Any) -> None: - """ - :keyword own_certificates: Defines a reference to a secret which contains all certificates and - private keys that can be used by the southbound connector connecting to the shop floor/OT - device. The accepted extensions are .der for certificates and .pfx/.pem for private keys. - :paramtype own_certificates: list[~azure.mgmt.deviceregistry.models.OwnCertificate] - """ - super().__init__(**kwargs) - self.own_certificates = own_certificates - - -class UserAuthentication(_serialization.Model): - """Definition of the client authentication mechanism to the server. +class Topic(_serialization.Model): + """Object that describes the topic information. All required parameters must be populated in order to send to server. - :ivar mode: Defines the mode to authenticate the user of the client at the server. Required. - Known values are: "Anonymous", "Certificate", and "UsernamePassword". - :vartype mode: str or ~azure.mgmt.deviceregistry.models.UserAuthenticationMode - :ivar username_password_credentials: Defines the username and password references when - UsernamePassword user authentication mode is selected. - :vartype username_password_credentials: - ~azure.mgmt.deviceregistry.models.UsernamePasswordCredentials - :ivar x509_credentials: Defines the certificate reference when Certificate user authentication - mode is selected. - :vartype x509_credentials: ~azure.mgmt.deviceregistry.models.X509Credentials + :ivar path: The topic path for messages published to an MQTT broker. Required. + :vartype path: str + :ivar retain: When set to 'Keep', messages published to an MQTT broker will have the retain + flag set. Default: 'Never'. Known values are: "Keep" and "Never". + :vartype retain: str or ~azure.mgmt.deviceregistry.models.TopicRetainType """ _validation = { - "mode": {"required": True}, + "path": {"required": True}, } _attribute_map = { - "mode": {"key": "mode", "type": "str"}, - "username_password_credentials": {"key": "usernamePasswordCredentials", "type": "UsernamePasswordCredentials"}, - "x509_credentials": {"key": "x509Credentials", "type": "X509Credentials"}, + "path": {"key": "path", "type": "str"}, + "retain": {"key": "retain", "type": "str"}, } def __init__( - self, - *, - mode: Union[str, "_models.UserAuthenticationMode"], - username_password_credentials: Optional["_models.UsernamePasswordCredentials"] = None, - x509_credentials: Optional["_models.X509Credentials"] = None, - **kwargs: Any + self, *, path: str, retain: Optional[Union[str, "_models.TopicRetainType"]] = None, **kwargs: Any ) -> None: """ - :keyword mode: Defines the mode to authenticate the user of the client at the server. Required. - Known values are: "Anonymous", "Certificate", and "UsernamePassword". - :paramtype mode: str or ~azure.mgmt.deviceregistry.models.UserAuthenticationMode - :keyword username_password_credentials: Defines the username and password references when - UsernamePassword user authentication mode is selected. - :paramtype username_password_credentials: - ~azure.mgmt.deviceregistry.models.UsernamePasswordCredentials - :keyword x509_credentials: Defines the certificate reference when Certificate user - authentication mode is selected. - :paramtype x509_credentials: ~azure.mgmt.deviceregistry.models.X509Credentials + :keyword path: The topic path for messages published to an MQTT broker. Required. + :paramtype path: str + :keyword retain: When set to 'Keep', messages published to an MQTT broker will have the retain + flag set. Default: 'Never'. Known values are: "Keep" and "Never". + :paramtype retain: str or ~azure.mgmt.deviceregistry.models.TopicRetainType """ super().__init__(**kwargs) - self.mode = mode - self.username_password_credentials = username_password_credentials - self.x509_credentials = x509_credentials + self.path = path + self.retain = retain -class UserAuthenticationUpdate(_serialization.Model): - """Definition of the client authentication mechanism to the server. +class TopicUpdate(_serialization.Model): + """Object that describes the topic information. - :ivar mode: Defines the mode to authenticate the user of the client at the server. Known values - are: "Anonymous", "Certificate", and "UsernamePassword". - :vartype mode: str or ~azure.mgmt.deviceregistry.models.UserAuthenticationMode - :ivar username_password_credentials: Defines the username and password references when - UsernamePassword user authentication mode is selected. - :vartype username_password_credentials: - ~azure.mgmt.deviceregistry.models.UsernamePasswordCredentialsUpdate - :ivar x509_credentials: Defines the certificate reference when Certificate user authentication - mode is selected. - :vartype x509_credentials: ~azure.mgmt.deviceregistry.models.X509CredentialsUpdate + :ivar path: The topic path for messages published to an MQTT broker. + :vartype path: str + :ivar retain: When set to 'Keep', messages published to an MQTT broker will have the retain + flag set. Default: 'Never'. Known values are: "Keep" and "Never". + :vartype retain: str or ~azure.mgmt.deviceregistry.models.TopicRetainType """ _attribute_map = { - "mode": {"key": "mode", "type": "str"}, - "username_password_credentials": { - "key": "usernamePasswordCredentials", - "type": "UsernamePasswordCredentialsUpdate", - }, - "x509_credentials": {"key": "x509Credentials", "type": "X509CredentialsUpdate"}, + "path": {"key": "path", "type": "str"}, + "retain": {"key": "retain", "type": "str"}, } def __init__( self, *, - mode: Optional[Union[str, "_models.UserAuthenticationMode"]] = None, - username_password_credentials: Optional["_models.UsernamePasswordCredentialsUpdate"] = None, - x509_credentials: Optional["_models.X509CredentialsUpdate"] = None, + path: Optional[str] = None, + retain: Optional[Union[str, "_models.TopicRetainType"]] = None, **kwargs: Any ) -> None: """ - :keyword mode: Defines the mode to authenticate the user of the client at the server. Known - values are: "Anonymous", "Certificate", and "UsernamePassword". - :paramtype mode: str or ~azure.mgmt.deviceregistry.models.UserAuthenticationMode - :keyword username_password_credentials: Defines the username and password references when - UsernamePassword user authentication mode is selected. - :paramtype username_password_credentials: - ~azure.mgmt.deviceregistry.models.UsernamePasswordCredentialsUpdate - :keyword x509_credentials: Defines the certificate reference when Certificate user - authentication mode is selected. - :paramtype x509_credentials: ~azure.mgmt.deviceregistry.models.X509CredentialsUpdate + :keyword path: The topic path for messages published to an MQTT broker. + :paramtype path: str + :keyword retain: When set to 'Keep', messages published to an MQTT broker will have the retain + flag set. Default: 'Never'. Known values are: "Keep" and "Never". + :paramtype retain: str or ~azure.mgmt.deviceregistry.models.TopicRetainType """ super().__init__(**kwargs) - self.mode = mode - self.username_password_credentials = username_password_credentials - self.x509_credentials = x509_credentials + self.path = path + self.retain = retain class UsernamePasswordCredentials(_serialization.Model): @@ -1667,60 +2104,60 @@ class UsernamePasswordCredentials(_serialization.Model): All required parameters must be populated in order to send to server. - :ivar username_reference: A reference to secret containing the username. Required. - :vartype username_reference: str - :ivar password_reference: A reference to secret containing the password. Required. - :vartype password_reference: str + :ivar username_secret_name: The name of the secret containing the username. Required. + :vartype username_secret_name: str + :ivar password_secret_name: The name of the secret containing the password. Required. + :vartype password_secret_name: str """ _validation = { - "username_reference": {"required": True}, - "password_reference": {"required": True}, + "username_secret_name": {"required": True}, + "password_secret_name": {"required": True}, } _attribute_map = { - "username_reference": {"key": "usernameReference", "type": "str"}, - "password_reference": {"key": "passwordReference", "type": "str"}, + "username_secret_name": {"key": "usernameSecretName", "type": "str"}, + "password_secret_name": {"key": "passwordSecretName", "type": "str"}, } - def __init__(self, *, username_reference: str, password_reference: str, **kwargs: Any) -> None: + def __init__(self, *, username_secret_name: str, password_secret_name: str, **kwargs: Any) -> None: """ - :keyword username_reference: A reference to secret containing the username. Required. - :paramtype username_reference: str - :keyword password_reference: A reference to secret containing the password. Required. - :paramtype password_reference: str + :keyword username_secret_name: The name of the secret containing the username. Required. + :paramtype username_secret_name: str + :keyword password_secret_name: The name of the secret containing the password. Required. + :paramtype password_secret_name: str """ super().__init__(**kwargs) - self.username_reference = username_reference - self.password_reference = password_reference + self.username_secret_name = username_secret_name + self.password_secret_name = password_secret_name class UsernamePasswordCredentialsUpdate(_serialization.Model): """The credentials for authentication mode UsernamePassword. - :ivar username_reference: A reference to secret containing the username. - :vartype username_reference: str - :ivar password_reference: A reference to secret containing the password. - :vartype password_reference: str + :ivar username_secret_name: The name of the secret containing the username. + :vartype username_secret_name: str + :ivar password_secret_name: The name of the secret containing the password. + :vartype password_secret_name: str """ _attribute_map = { - "username_reference": {"key": "usernameReference", "type": "str"}, - "password_reference": {"key": "passwordReference", "type": "str"}, + "username_secret_name": {"key": "usernameSecretName", "type": "str"}, + "password_secret_name": {"key": "passwordSecretName", "type": "str"}, } def __init__( - self, *, username_reference: Optional[str] = None, password_reference: Optional[str] = None, **kwargs: Any + self, *, username_secret_name: Optional[str] = None, password_secret_name: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword username_reference: A reference to secret containing the username. - :paramtype username_reference: str - :keyword password_reference: A reference to secret containing the password. - :paramtype password_reference: str + :keyword username_secret_name: The name of the secret containing the username. + :paramtype username_secret_name: str + :keyword password_secret_name: The name of the secret containing the password. + :paramtype password_secret_name: str """ super().__init__(**kwargs) - self.username_reference = username_reference - self.password_reference = password_reference + self.username_secret_name = username_secret_name + self.password_secret_name = password_secret_name class X509Credentials(_serialization.Model): @@ -1728,46 +2165,46 @@ class X509Credentials(_serialization.Model): All required parameters must be populated in order to send to server. - :ivar certificate_reference: A reference to secret containing the certificate and private key - (e.g. stored as .der/.pem or .der/.pfx). Required. - :vartype certificate_reference: str + :ivar certificate_secret_name: The name of the secret containing the certificate and private + key (e.g. stored as .der/.pem or .der/.pfx). Required. + :vartype certificate_secret_name: str """ _validation = { - "certificate_reference": {"required": True}, + "certificate_secret_name": {"required": True}, } _attribute_map = { - "certificate_reference": {"key": "certificateReference", "type": "str"}, + "certificate_secret_name": {"key": "certificateSecretName", "type": "str"}, } - def __init__(self, *, certificate_reference: str, **kwargs: Any) -> None: + def __init__(self, *, certificate_secret_name: str, **kwargs: Any) -> None: """ - :keyword certificate_reference: A reference to secret containing the certificate and private + :keyword certificate_secret_name: The name of the secret containing the certificate and private key (e.g. stored as .der/.pem or .der/.pfx). Required. - :paramtype certificate_reference: str + :paramtype certificate_secret_name: str """ super().__init__(**kwargs) - self.certificate_reference = certificate_reference + self.certificate_secret_name = certificate_secret_name class X509CredentialsUpdate(_serialization.Model): """The x509 certificate for authentication mode Certificate. - :ivar certificate_reference: A reference to secret containing the certificate and private key - (e.g. stored as .der/.pem or .der/.pfx). - :vartype certificate_reference: str + :ivar certificate_secret_name: The name of the secret containing the certificate and private + key (e.g. stored as .der/.pem or .der/.pfx). + :vartype certificate_secret_name: str """ _attribute_map = { - "certificate_reference": {"key": "certificateReference", "type": "str"}, + "certificate_secret_name": {"key": "certificateSecretName", "type": "str"}, } - def __init__(self, *, certificate_reference: Optional[str] = None, **kwargs: Any) -> None: + def __init__(self, *, certificate_secret_name: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword certificate_reference: A reference to secret containing the certificate and private + :keyword certificate_secret_name: The name of the secret containing the certificate and private key (e.g. stored as .der/.pem or .der/.pfx). - :paramtype certificate_reference: str + :paramtype certificate_secret_name: str """ super().__init__(**kwargs) - self.certificate_reference = certificate_reference + self.certificate_secret_name = certificate_secret_name diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/__init__.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/__init__.py index aadcb130f776..2cf5f274bfff 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/__init__.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/__init__.py @@ -9,6 +9,7 @@ from ._operations import Operations from ._asset_endpoint_profiles_operations import AssetEndpointProfilesOperations from ._assets_operations import AssetsOperations +from ._billing_containers_operations import BillingContainersOperations from ._operation_status_operations import OperationStatusOperations from ._patch import __all__ as _patch_all @@ -19,6 +20,7 @@ "Operations", "AssetEndpointProfilesOperations", "AssetsOperations", + "BillingContainersOperations", "OperationStatusOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/_asset_endpoint_profiles_operations.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/_asset_endpoint_profiles_operations.py index 9a0030040899..c9fe977b0010 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/_asset_endpoint_profiles_operations.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/_asset_endpoint_profiles_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +48,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -51,7 +56,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DeviceRegistry/assetEndpointProfiles" ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -69,7 +74,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +83,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceRegistry/assetEndpointProfiles", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -101,7 +106,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -110,7 +115,7 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/{assetEndpointProfileName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -141,7 +146,7 @@ def build_create_or_replace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -151,7 +156,7 @@ def build_create_or_replace_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/{assetEndpointProfileName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -184,7 +189,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -194,7 +199,7 @@ def build_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/{assetEndpointProfileName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -227,7 +232,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -236,7 +241,7 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/{assetEndpointProfileName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -295,7 +300,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AssetEndpoint api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AssetEndpointProfileListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -312,7 +317,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -328,7 +332,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -378,7 +381,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AssetEndpointProfileListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -396,7 +399,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -412,7 +414,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -457,7 +458,7 @@ def get( :rtype: ~azure.mgmt.deviceregistry.models.AssetEndpointProfile :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -479,7 +480,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -494,7 +494,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AssetEndpointProfile", pipeline_response) + deserialized = self._deserialize("AssetEndpointProfile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -507,8 +507,8 @@ def _create_or_replace_initial( asset_endpoint_profile_name: str, resource: Union[_models.AssetEndpointProfile, IO[bytes]], **kwargs: Any - ) -> _models.AssetEndpointProfile: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -521,7 +521,7 @@ def _create_or_replace_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AssetEndpointProfile] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -542,10 +542,10 @@ def _create_or_replace_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -553,18 +553,22 @@ def _create_or_replace_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AssetEndpointProfile", pipeline_response) - if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("AssetEndpointProfile", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -671,10 +675,11 @@ def begin_create_or_replace( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AssetEndpointProfile", pipeline_response) + deserialized = self._deserialize("AssetEndpointProfile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -704,8 +709,8 @@ def _update_initial( asset_endpoint_profile_name: str, properties: Union[_models.AssetEndpointProfileUpdate, IO[bytes]], **kwargs: Any - ) -> Optional[_models.AssetEndpointProfile]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -718,7 +723,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.AssetEndpointProfile]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -739,10 +744,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -750,19 +755,21 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AssetEndpointProfile", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -868,10 +875,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AssetEndpointProfile", pipeline_response) + deserialized = self._deserialize("AssetEndpointProfile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -895,10 +903,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, asset_endpoint_profile_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -910,7 +918,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -920,10 +928,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -931,6 +939,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -940,8 +952,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -967,7 +983,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, asset_endpoint_profile_name=asset_endpoint_profile_name, api_version=api_version, @@ -976,6 +992,7 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/_assets_operations.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/_assets_operations.py index 730c49337f49..e16a6bc841d2 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/_assets_operations.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/_assets_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,13 +48,13 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DeviceRegistry/assets") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -67,7 +72,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -76,7 +81,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceRegistry/assets", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -97,7 +102,7 @@ def build_get_request(resource_group_name: str, asset_name: str, subscription_id _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -106,7 +111,7 @@ def build_get_request(resource_group_name: str, asset_name: str, subscription_id "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceRegistry/assets/{assetName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -132,7 +137,7 @@ def build_create_or_replace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -142,7 +147,7 @@ def build_create_or_replace_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceRegistry/assets/{assetName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -168,7 +173,7 @@ def build_update_request(resource_group_name: str, asset_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -178,7 +183,7 @@ def build_update_request(resource_group_name: str, asset_name: str, subscription "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceRegistry/assets/{assetName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -204,7 +209,7 @@ def build_delete_request(resource_group_name: str, asset_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -213,7 +218,7 @@ def build_delete_request(resource_group_name: str, asset_name: str, subscription "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceRegistry/assets/{assetName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -266,7 +271,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Asset"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AssetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -283,7 +288,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -299,7 +303,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -346,7 +349,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AssetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -364,7 +367,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -380,7 +382,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -423,7 +424,7 @@ def get(self, resource_group_name: str, asset_name: str, **kwargs: Any) -> _mode :rtype: ~azure.mgmt.deviceregistry.models.Asset :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -445,7 +446,6 @@ def get(self, resource_group_name: str, asset_name: str, **kwargs: Any) -> _mode headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -460,7 +460,7 @@ def get(self, resource_group_name: str, asset_name: str, **kwargs: Any) -> _mode error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Asset", pipeline_response) + deserialized = self._deserialize("Asset", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -469,8 +469,8 @@ def get(self, resource_group_name: str, asset_name: str, **kwargs: Any) -> _mode def _create_or_replace_initial( self, resource_group_name: str, asset_name: str, resource: Union[_models.Asset, IO[bytes]], **kwargs: Any - ) -> _models.Asset: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -483,7 +483,7 @@ def _create_or_replace_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Asset] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -504,10 +504,10 @@ def _create_or_replace_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -515,18 +515,22 @@ def _create_or_replace_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Asset", pipeline_response) - if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("Asset", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -626,10 +630,11 @@ def begin_create_or_replace( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Asset", pipeline_response) + deserialized = self._deserialize("Asset", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -659,8 +664,8 @@ def _update_initial( asset_name: str, properties: Union[_models.AssetUpdate, IO[bytes]], **kwargs: Any - ) -> Optional[_models.Asset]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -673,7 +678,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.Asset]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -694,10 +699,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -705,19 +710,21 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Asset", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -820,10 +827,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Asset", pipeline_response) + deserialized = self._deserialize("Asset", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -847,10 +855,8 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, asset_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, asset_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -862,7 +868,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -872,10 +878,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -883,6 +889,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -892,8 +902,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, asset_name: str, **kwargs: Any) -> LROPoller[None]: @@ -917,7 +931,7 @@ def begin_delete(self, resource_group_name: str, asset_name: str, **kwargs: Any) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, asset_name=asset_name, api_version=api_version, @@ -926,6 +940,7 @@ def begin_delete(self, resource_group_name: str, asset_name: str, **kwargs: Any) params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/_billing_containers_operations.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/_billing_containers_operations.py new file mode 100644 index 000000000000..f500680d1bc2 --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/_billing_containers_operations.py @@ -0,0 +1,247 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DeviceRegistry/billingContainers" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(billing_container_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DeviceRegistry/billingContainers/{billingContainerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "billingContainerName": _SERIALIZER.url( + "billing_container_name", + billing_container_name, + "str", + max_length=64, + min_length=3, + pattern=r"^[0-9a-zA-Z][a-zA-Z0-9-]*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BillingContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.deviceregistry.DeviceRegistryMgmtClient`'s + :attr:`billing_containers` attribute. + """ + + models = _models + + 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_by_subscription(self, **kwargs: Any) -> Iterable["_models.BillingContainer"]: + """List BillingContainer resources by subscription ID. + + :return: An iterator like instance of either BillingContainer or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.deviceregistry.models.BillingContainer] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.BillingContainerListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BillingContainerListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, billing_container_name: str, **kwargs: Any) -> _models.BillingContainer: + """Get a BillingContainer. + + :param billing_container_name: Name of the billing container. Required. + :type billing_container_name: str + :return: BillingContainer or the result of cls(response) + :rtype: ~azure.mgmt.deviceregistry.models.BillingContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.BillingContainer] = kwargs.pop("cls", None) + + _request = build_get_request( + billing_container_name=billing_container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BillingContainer", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/_operation_status_operations.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/_operation_status_operations.py index 6516f7241769..b22dcc5242c4 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/_operation_status_operations.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/_operation_status_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +41,7 @@ def build_get_request(location: str, operation_id: str, subscription_id: str, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -47,7 +50,7 @@ def build_get_request(location: str, operation_id: str, subscription_id: str, ** "/subscriptions/{subscriptionId}/providers/Microsoft.DeviceRegistry/locations/{location}/operationStatuses/{operationId}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "location": _SERIALIZER.url("location", location, "str", min_length=1), "operationId": _SERIALIZER.url("operation_id", operation_id, "str", min_length=1), } @@ -86,7 +89,7 @@ def __init__(self, *args, **kwargs): def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.OperationStatusResult: """Returns the current status of an async operation. - :param location: The name of Azure region. Required. + :param location: The name of the Azure region. Required. :type location: str :param operation_id: The ID of an ongoing async operation. Required. :type operation_id: str @@ -94,7 +97,7 @@ def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.Operat :rtype: ~azure.mgmt.deviceregistry.models.OperationStatusResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -116,7 +119,6 @@ def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.Operat headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -131,7 +133,7 @@ def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.Operat error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OperationStatusResult", pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/_operations.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/_operations.py index 27ad5684f4f5..9c3cfb6b38eb 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/_operations.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -88,7 +91,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,7 +107,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -120,7 +122,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/create_asset_endpoint_profile.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/create_asset_endpoint_profile.py index 07481b6e6d1b..fc5add589630 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/create_asset_endpoint_profile.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/create_asset_endpoint_profile.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.deviceregistry import DeviceRegistryMgmtClient @@ -42,8 +40,9 @@ def main(): }, "location": "West Europe", "properties": { + "authentication": {"method": "Anonymous"}, + "endpointProfileType": "myEndpointProfileType", "targetAddress": "https://www.example.com/myTargetAddress", - "userAuthentication": {"mode": "Anonymous"}, }, "tags": {"site": "building-1"}, }, @@ -51,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_AssetEndpointProfile.json +# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/stable/2024-11-01/examples/Create_AssetEndpointProfile.json if __name__ == "__main__": main() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/create_asset_endpoint_profile_with_discovered_aep_ref.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/create_asset_endpoint_profile_with_discovered_aep_ref.py new file mode 100644 index 000000000000..f89656db736b --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/create_asset_endpoint_profile_with_discovered_aep_ref.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.deviceregistry import DeviceRegistryMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-deviceregistry +# USAGE + python create_asset_endpoint_profile_with_discovered_aep_ref.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DeviceRegistryMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.asset_endpoint_profiles.begin_create_or_replace( + resource_group_name="myResourceGroup", + asset_endpoint_profile_name="my-assetendpointprofile", + resource={ + "extendedLocation": { + "name": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1", + "type": "CustomLocation", + }, + "location": "West Europe", + "properties": { + "authentication": {"method": "Anonymous"}, + "discoveredAssetEndpointProfileRef": "discoveredAssetEndpointProfile1", + "endpointProfileType": "myEndpointProfileType", + "targetAddress": "https://www.example.com/myTargetAddress", + }, + "tags": {"site": "building-1"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/stable/2024-11-01/examples/Create_AssetEndpointProfile_With_DiscoveredAepRef.json +if __name__ == "__main__": + main() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/create_asset_with_discovered_asset_ref.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/create_asset_with_discovered_asset_ref.py new file mode 100644 index 000000000000..3e960b4b081e --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/create_asset_with_discovered_asset_ref.py @@ -0,0 +1,105 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.deviceregistry import DeviceRegistryMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-deviceregistry +# USAGE + python create_asset_with_discovered_asset_ref.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DeviceRegistryMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.assets.begin_create_or_replace( + resource_group_name="myResourceGroup", + asset_name="my-asset", + resource={ + "extendedLocation": { + "name": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1", + "type": "CustomLocation", + }, + "location": "West Europe", + "properties": { + "assetEndpointProfileRef": "myAssetEndpointProfile", + "datasets": [ + { + "dataPoints": [ + { + "dataPointConfiguration": '{"publishingInterval":8,"samplingInterval":8,"queueSize":4}', + "dataSource": "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1", + "name": "dataPoint1", + "observabilityMode": "Counter", + }, + { + "dataPointConfiguration": '{"publishingInterval":4,"samplingInterval":4,"queueSize":7}', + "dataSource": "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2", + "name": "dataPoint2", + "observabilityMode": "None", + }, + ], + "datasetConfiguration": '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + "name": "dataset1", + "topic": {"path": "/path/dataset1", "retain": "Keep"}, + } + ], + "defaultDatasetsConfiguration": '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + "defaultEventsConfiguration": '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + "defaultTopic": {"path": "/path/defaultTopic", "retain": "Keep"}, + "description": "This is a sample Asset", + "discoveredAssetRefs": ["discoveredAsset1", "discoveredAsset2"], + "displayName": "AssetDisplayName", + "documentationUri": "https://www.example.com/manual", + "enabled": True, + "events": [ + { + "eventConfiguration": '{"publishingInterval":7,"samplingInterval":1,"queueSize":8}', + "eventNotifier": "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3", + "name": "event1", + "observabilityMode": "None", + "topic": {"path": "/path/event1", "retain": "Keep"}, + }, + { + "eventConfiguration": '{"publishingInterval":7,"samplingInterval":8,"queueSize":4}', + "eventNotifier": "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4", + "name": "event2", + "observabilityMode": "Log", + }, + ], + "externalAssetId": "8ZBA6LRHU0A458969", + "hardwareRevision": "1.0", + "manufacturer": "Contoso", + "manufacturerUri": "https://www.contoso.com/manufacturerUri", + "model": "ContosoModel", + "productCode": "SA34VDG", + "serialNumber": "64-103816-519918-8", + "softwareRevision": "2.0", + }, + "tags": {"site": "building-1"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/stable/2024-11-01/examples/Create_Asset_With_DiscoveredAssetRef.json +if __name__ == "__main__": + main() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/create_asset_with_external_asset_id.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/create_asset_with_external_asset_id.py index 64f0c47ad7cb..de808d5bcce4 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/create_asset_with_external_asset_id.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/create_asset_with_external_asset_id.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.deviceregistry import DeviceRegistryMgmtClient @@ -42,40 +40,48 @@ def main(): }, "location": "West Europe", "properties": { - "assetEndpointProfileUri": "https://www.example.com/myAssetEndpointProfile", - "assetType": "MyAssetType", - "dataPoints": [ - { - "capabilityId": "dtmi:com:example:Thermostat:__temperature;1", - "dataPointConfiguration": '{"publishingInterval":8,"samplingInterval":8,"queueSize":4}', - "dataSource": "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1", - "observabilityMode": "counter", - }, + "assetEndpointProfileRef": "myAssetEndpointProfile", + "datasets": [ { - "capabilityId": "dtmi:com:example:Thermostat:__pressure;1", - "dataPointConfiguration": '{"publishingInterval":4,"samplingInterval":4,"queueSize":7}', - "dataSource": "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2", - "observabilityMode": "none", - }, + "dataPoints": [ + { + "dataPointConfiguration": '{"publishingInterval":8,"samplingInterval":8,"queueSize":4}', + "dataSource": "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1", + "name": "dataPoint1", + "observabilityMode": "Counter", + }, + { + "dataPointConfiguration": '{"publishingInterval":4,"samplingInterval":4,"queueSize":7}', + "dataSource": "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2", + "name": "dataPoint2", + "observabilityMode": "None", + }, + ], + "datasetConfiguration": '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + "name": "dataset1", + "topic": {"path": "/path/dataset1", "retain": "Keep"}, + } ], - "defaultDataPointsConfiguration": '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + "defaultDatasetsConfiguration": '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', "defaultEventsConfiguration": '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + "defaultTopic": {"path": "/path/defaultTopic", "retain": "Keep"}, "description": "This is a sample Asset", "displayName": "AssetDisplayName", "documentationUri": "https://www.example.com/manual", "enabled": True, "events": [ { - "capabilityId": "dtmi:com:example:Thermostat:__temperature;1", "eventConfiguration": '{"publishingInterval":7,"samplingInterval":1,"queueSize":8}', "eventNotifier": "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3", - "observabilityMode": "none", + "name": "event1", + "observabilityMode": "None", + "topic": {"path": "/path/event1", "retain": "Keep"}, }, { - "capabilityId": "dtmi:com:example:Thermostat:__pressure;1", "eventConfiguration": '{"publishingInterval":7,"samplingInterval":8,"queueSize":4}', "eventNotifier": "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4", - "observabilityMode": "log", + "name": "event2", + "observabilityMode": "Log", }, ], "externalAssetId": "8ZBA6LRHU0A458969", @@ -93,6 +99,6 @@ def main(): print(response) -# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_With_ExternalAssetId.json +# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/stable/2024-11-01/examples/Create_Asset_With_ExternalAssetId.json if __name__ == "__main__": main() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/create_asset_without_display_name.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/create_asset_without_display_name.py index ffa991ce75a1..d4f2d2df9aba 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/create_asset_without_display_name.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/create_asset_without_display_name.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.deviceregistry import DeviceRegistryMgmtClient @@ -42,39 +40,47 @@ def main(): }, "location": "West Europe", "properties": { - "assetEndpointProfileUri": "https://www.example.com/myAssetEndpointProfile", - "assetType": "MyAssetType", - "dataPoints": [ - { - "capabilityId": "dtmi:com:example:Thermostat:__temperature;1", - "dataPointConfiguration": '{"publishingInterval":8,"samplingInterval":8,"queueSize":4}', - "dataSource": "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1", - "observabilityMode": "counter", - }, + "assetEndpointProfileRef": "myAssetEndpointProfile", + "datasets": [ { - "capabilityId": "dtmi:com:example:Thermostat:__pressure;1", - "dataPointConfiguration": '{"publishingInterval":4,"samplingInterval":4,"queueSize":7}', - "dataSource": "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2", - "observabilityMode": "none", - }, + "dataPoints": [ + { + "dataPointConfiguration": '{"publishingInterval":8,"samplingInterval":8,"queueSize":4}', + "dataSource": "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1", + "name": "dataPoint1", + "observabilityMode": "Counter", + }, + { + "dataPointConfiguration": '{"publishingInterval":4,"samplingInterval":4,"queueSize":7}', + "dataSource": "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2", + "name": "dataPoint2", + "observabilityMode": "None", + }, + ], + "datasetConfiguration": '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + "name": "dataset1", + "topic": {"path": "/path/dataset1", "retain": "Keep"}, + } ], - "defaultDataPointsConfiguration": '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + "defaultDatasetsConfiguration": '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', "defaultEventsConfiguration": '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + "defaultTopic": {"path": "/path/defaultTopic", "retain": "Keep"}, "description": "This is a sample Asset", "documentationUri": "https://www.example.com/manual", "enabled": True, "events": [ { - "capabilityId": "dtmi:com:example:Thermostat:__temperature;1", "eventConfiguration": '{"publishingInterval":7,"samplingInterval":1,"queueSize":8}', "eventNotifier": "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3", - "observabilityMode": "none", + "name": "event1", + "observabilityMode": "None", + "topic": {"path": "/path/event1", "retain": "Keep"}, }, { - "capabilityId": "dtmi:com:example:Thermostat:__pressure;1", "eventConfiguration": '{"publishingInterval":7,"samplingInterval":8,"queueSize":4}', "eventNotifier": "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4", - "observabilityMode": "log", + "name": "event2", + "observabilityMode": "Log", }, ], "externalAssetId": "8ZBA6LRHU0A458969", @@ -92,6 +98,6 @@ def main(): print(response) -# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_Without_DisplayName.json +# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/stable/2024-11-01/examples/Create_Asset_Without_DisplayName.json if __name__ == "__main__": main() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/create_asset_without_external_asset_id.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/create_asset_without_external_asset_id.py index ceed4095e035..bb06330605c6 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/create_asset_without_external_asset_id.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/create_asset_without_external_asset_id.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.deviceregistry import DeviceRegistryMgmtClient @@ -42,40 +40,48 @@ def main(): }, "location": "West Europe", "properties": { - "assetEndpointProfileUri": "https://www.example.com/myAssetEndpointProfile", - "assetType": "MyAssetType", - "dataPoints": [ - { - "capabilityId": "dtmi:com:example:Thermostat:__temperature;1", - "dataPointConfiguration": '{"publishingInterval":8,"samplingInterval":8,"queueSize":4}', - "dataSource": "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1", - "observabilityMode": "counter", - }, + "assetEndpointProfileRef": "myAssetEndpointProfile", + "datasets": [ { - "capabilityId": "dtmi:com:example:Thermostat:__pressure;1", - "dataPointConfiguration": '{"publishingInterval":4,"samplingInterval":4,"queueSize":7}', - "dataSource": "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2", - "observabilityMode": "none", - }, + "dataPoints": [ + { + "dataPointConfiguration": '{"publishingInterval":8,"samplingInterval":8,"queueSize":4}', + "dataSource": "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1", + "name": "dataPoint1", + "observabilityMode": "Counter", + }, + { + "dataPointConfiguration": '{"publishingInterval":4,"samplingInterval":4,"queueSize":7}', + "dataSource": "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2", + "name": "dataPoint2", + "observabilityMode": "None", + }, + ], + "datasetConfiguration": '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + "name": "dataset1", + "topic": {"path": "/path/dataset1", "retain": "Keep"}, + } ], - "defaultDataPointsConfiguration": '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + "defaultDatasetsConfiguration": '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', "defaultEventsConfiguration": '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + "defaultTopic": {"path": "/path/defaultTopic", "retain": "Keep"}, "description": "This is a sample Asset", "displayName": "AssetDisplayName", "documentationUri": "https://www.example.com/manual", "enabled": True, "events": [ { - "capabilityId": "dtmi:com:example:Thermostat:__temperature;1", "eventConfiguration": '{"publishingInterval":7,"samplingInterval":1,"queueSize":8}', "eventNotifier": "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3", - "observabilityMode": "none", + "name": "event1", + "observabilityMode": "None", + "topic": {"path": "/path/event1", "retain": "Keep"}, }, { - "capabilityId": "dtmi:com:example:Thermostat:__pressure;1", "eventConfiguration": '{"publishingInterval":7,"samplingInterval":8,"queueSize":4}', "eventNotifier": "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4", - "observabilityMode": "log", + "name": "event2", + "observabilityMode": "Log", }, ], "hardwareRevision": "1.0", @@ -92,6 +98,6 @@ def main(): print(response) -# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_Without_ExternalAssetId.json +# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/stable/2024-11-01/examples/Create_Asset_Without_ExternalAssetId.json if __name__ == "__main__": main() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/delete_asset.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/delete_asset.py index fc068fd2d38a..37575b8ec562 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/delete_asset.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/delete_asset.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Delete_Asset.json +# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/stable/2024-11-01/examples/Delete_Asset.json if __name__ == "__main__": main() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/delete_asset_endpoint_profile.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/delete_asset_endpoint_profile.py index 2f192080098c..4d904daea273 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/delete_asset_endpoint_profile.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/delete_asset_endpoint_profile.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Delete_AssetEndpointProfile.json +# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/stable/2024-11-01/examples/Delete_AssetEndpointProfile.json if __name__ == "__main__": main() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/get_asset.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/get_asset.py index ee1bc0815e4e..d351c10cd5e9 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/get_asset.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/get_asset.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_Asset.json +# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/stable/2024-11-01/examples/Get_Asset.json if __name__ == "__main__": main() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/get_asset_endpoint_profile.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/get_asset_endpoint_profile.py index e2161dbd00da..6ed3df514a45 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/get_asset_endpoint_profile.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/get_asset_endpoint_profile.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_AssetEndpointProfile.json +# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/stable/2024-11-01/examples/Get_AssetEndpointProfile.json if __name__ == "__main__": main() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/get_asset_endpoint_profile_with_sync_status.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/get_asset_endpoint_profile_with_sync_status.py new file mode 100644 index 000000000000..0214d4d0e013 --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/get_asset_endpoint_profile_with_sync_status.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.deviceregistry import DeviceRegistryMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-deviceregistry +# USAGE + python get_asset_endpoint_profile_with_sync_status.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DeviceRegistryMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.asset_endpoint_profiles.get( + resource_group_name="myResourceGroup", + asset_endpoint_profile_name="my-assetendpointprofile", + ) + print(response) + + +# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/stable/2024-11-01/examples/Get_AssetEndpointProfile_With_SyncStatus.json +if __name__ == "__main__": + main() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/get_asset_with_sync_status.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/get_asset_with_sync_status.py index 7b69996aad39..93f4db9aac89 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/get_asset_with_sync_status.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/get_asset_with_sync_status.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_Asset_With_SyncStatus.json +# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/stable/2024-11-01/examples/Get_Asset_With_SyncStatus.json if __name__ == "__main__": main() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/get_billing_container.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/get_billing_container.py new file mode 100644 index 000000000000..4ca19b76636c --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/get_billing_container.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.deviceregistry import DeviceRegistryMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-deviceregistry +# USAGE + python get_billing_container.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DeviceRegistryMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.billing_containers.get( + billing_container_name="my-billingContainer", + ) + print(response) + + +# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/stable/2024-11-01/examples/Get_BillingContainer.json +if __name__ == "__main__": + main() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/get_operation_status.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/get_operation_status.py index 5436267b97a5..0e217a9c6db4 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/get_operation_status.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/get_operation_status.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_OperationStatus.json +# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/stable/2024-11-01/examples/Get_OperationStatus.json if __name__ == "__main__": main() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_asset_endpoint_profiles_resource_group.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_asset_endpoint_profiles_resource_group.py index 94c88e50e93a..f2cc091c72e2 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_asset_endpoint_profiles_resource_group.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_asset_endpoint_profiles_resource_group.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_AssetEndpointProfiles_ResourceGroup.json +# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/stable/2024-11-01/examples/List_AssetEndpointProfiles_ResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_asset_endpoint_profiles_subscription.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_asset_endpoint_profiles_subscription.py index 64fc4ab3cbd6..032bbca10cab 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_asset_endpoint_profiles_subscription.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_asset_endpoint_profiles_subscription.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_AssetEndpointProfiles_Subscription.json +# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/stable/2024-11-01/examples/List_AssetEndpointProfiles_Subscription.json if __name__ == "__main__": main() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_assets_resource_group.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_assets_resource_group.py index 67696b811ef2..00dffc85bf3c 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_assets_resource_group.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_assets_resource_group.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Assets_ResourceGroup.json +# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/stable/2024-11-01/examples/List_Assets_ResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_assets_subscription.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_assets_subscription.py index b720f0bcdc0f..f827e387e437 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_assets_subscription.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_assets_subscription.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Assets_Subscription.json +# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/stable/2024-11-01/examples/List_Assets_Subscription.json if __name__ == "__main__": main() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_billing_containers_subscription.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_billing_containers_subscription.py new file mode 100644 index 000000000000..dabfeb957ccd --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_billing_containers_subscription.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.deviceregistry import DeviceRegistryMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-deviceregistry +# USAGE + python list_billing_containers_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DeviceRegistryMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.billing_containers.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/stable/2024-11-01/examples/List_BillingContainers_Subscription.json +if __name__ == "__main__": + main() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_operations.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_operations.py index 555dd7b79f0d..768e6eb09eda 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_operations.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/list_operations.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Operations.json +# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/stable/2024-11-01/examples/List_Operations.json if __name__ == "__main__": main() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/update_asset.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/update_asset.py index ab4cd9423ada..a48917aa4145 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/update_asset.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/update_asset.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.deviceregistry import DeviceRegistryMgmtClient @@ -40,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Update_Asset.json +# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/stable/2024-11-01/examples/Update_Asset.json if __name__ == "__main__": main() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/update_asset_endpoint_profile.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/update_asset_endpoint_profile.py index 24e6bad672be..c315dd6866cf 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/update_asset_endpoint_profile.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_samples/update_asset_endpoint_profile.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.deviceregistry import DeviceRegistryMgmtClient @@ -40,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Update_AssetEndpointProfile.json +# x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/stable/2024-11-01/examples/Update_AssetEndpointProfile.json if __name__ == "__main__": main() diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/conftest.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/conftest.py new file mode 100644 index 000000000000..7c4f8c14e103 --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + deviceregistrymgmt_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + deviceregistrymgmt_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + deviceregistrymgmt_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + deviceregistrymgmt_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=deviceregistrymgmt_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=deviceregistrymgmt_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=deviceregistrymgmt_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=deviceregistrymgmt_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_asset_endpoint_profiles_operations.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_asset_endpoint_profiles_operations.py new file mode 100644 index 000000000000..43698abfa175 --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_asset_endpoint_profiles_operations.py @@ -0,0 +1,131 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.deviceregistry import DeviceRegistryMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDeviceRegistryMgmtAssetEndpointProfilesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DeviceRegistryMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_subscription(self, resource_group): + response = self.client.asset_endpoint_profiles.list_by_subscription( + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.asset_endpoint_profiles.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.asset_endpoint_profiles.get( + resource_group_name=resource_group.name, + asset_endpoint_profile_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_replace(self, resource_group): + response = self.client.asset_endpoint_profiles.begin_create_or_replace( + resource_group_name=resource_group.name, + asset_endpoint_profile_name="str", + resource={ + "extendedLocation": {"name": "str", "type": "str"}, + "location": "str", + "id": "str", + "name": "str", + "properties": { + "endpointProfileType": "str", + "targetAddress": "str", + "additionalConfiguration": "str", + "authentication": { + "method": "str", + "usernamePasswordCredentials": {"passwordSecretName": "str", "usernameSecretName": "str"}, + "x509Credentials": {"certificateSecretName": "str"}, + }, + "discoveredAssetEndpointProfileRef": "str", + "provisioningState": "str", + "status": {"errors": [{"code": 0, "message": "str"}]}, + "uuid": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-11-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.asset_endpoint_profiles.begin_update( + resource_group_name=resource_group.name, + asset_endpoint_profile_name="str", + properties={ + "properties": { + "additionalConfiguration": "str", + "authentication": { + "method": "str", + "usernamePasswordCredentials": {"passwordSecretName": "str", "usernameSecretName": "str"}, + "x509Credentials": {"certificateSecretName": "str"}, + }, + "endpointProfileType": "str", + "targetAddress": "str", + }, + "tags": {"str": "str"}, + }, + api_version="2024-11-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.asset_endpoint_profiles.begin_delete( + resource_group_name=resource_group.name, + asset_endpoint_profile_name="str", + api_version="2024-11-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_asset_endpoint_profiles_operations_async.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_asset_endpoint_profiles_operations_async.py new file mode 100644 index 000000000000..829ab602553a --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_asset_endpoint_profiles_operations_async.py @@ -0,0 +1,138 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.deviceregistry.aio import DeviceRegistryMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDeviceRegistryMgmtAssetEndpointProfilesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DeviceRegistryMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_subscription(self, resource_group): + response = self.client.asset_endpoint_profiles.list_by_subscription( + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.asset_endpoint_profiles.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.asset_endpoint_profiles.get( + resource_group_name=resource_group.name, + asset_endpoint_profile_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_replace(self, resource_group): + response = await ( + await self.client.asset_endpoint_profiles.begin_create_or_replace( + resource_group_name=resource_group.name, + asset_endpoint_profile_name="str", + resource={ + "extendedLocation": {"name": "str", "type": "str"}, + "location": "str", + "id": "str", + "name": "str", + "properties": { + "endpointProfileType": "str", + "targetAddress": "str", + "additionalConfiguration": "str", + "authentication": { + "method": "str", + "usernamePasswordCredentials": {"passwordSecretName": "str", "usernameSecretName": "str"}, + "x509Credentials": {"certificateSecretName": "str"}, + }, + "discoveredAssetEndpointProfileRef": "str", + "provisioningState": "str", + "status": {"errors": [{"code": 0, "message": "str"}]}, + "uuid": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-11-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.asset_endpoint_profiles.begin_update( + resource_group_name=resource_group.name, + asset_endpoint_profile_name="str", + properties={ + "properties": { + "additionalConfiguration": "str", + "authentication": { + "method": "str", + "usernamePasswordCredentials": {"passwordSecretName": "str", "usernameSecretName": "str"}, + "x509Credentials": {"certificateSecretName": "str"}, + }, + "endpointProfileType": "str", + "targetAddress": "str", + }, + "tags": {"str": "str"}, + }, + api_version="2024-11-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.asset_endpoint_profiles.begin_delete( + resource_group_name=resource_group.name, + asset_endpoint_profile_name="str", + api_version="2024-11-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_assets_operations.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_assets_operations.py new file mode 100644 index 000000000000..77940ad3f84c --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_assets_operations.py @@ -0,0 +1,219 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.deviceregistry import DeviceRegistryMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDeviceRegistryMgmtAssetsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DeviceRegistryMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_subscription(self, resource_group): + response = self.client.assets.list_by_subscription( + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.assets.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.assets.get( + resource_group_name=resource_group.name, + asset_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_replace(self, resource_group): + response = self.client.assets.begin_create_or_replace( + resource_group_name=resource_group.name, + asset_name="str", + resource={ + "extendedLocation": {"name": "str", "type": "str"}, + "location": "str", + "id": "str", + "name": "str", + "properties": { + "assetEndpointProfileRef": "str", + "attributes": {"str": {}}, + "datasets": [ + { + "name": "str", + "dataPoints": [ + { + "dataSource": "str", + "name": "str", + "dataPointConfiguration": "str", + "observabilityMode": "None", + } + ], + "datasetConfiguration": "str", + "topic": {"path": "str", "retain": "str"}, + } + ], + "defaultDatasetsConfiguration": "str", + "defaultEventsConfiguration": "str", + "defaultTopic": {"path": "str", "retain": "str"}, + "description": "str", + "discoveredAssetRefs": ["str"], + "displayName": "str", + "documentationUri": "str", + "enabled": bool, + "events": [ + { + "eventNotifier": "str", + "name": "str", + "eventConfiguration": "str", + "observabilityMode": "None", + "topic": {"path": "str", "retain": "str"}, + } + ], + "externalAssetId": "str", + "hardwareRevision": "str", + "manufacturer": "str", + "manufacturerUri": "str", + "model": "str", + "productCode": "str", + "provisioningState": "str", + "serialNumber": "str", + "softwareRevision": "str", + "status": { + "datasets": [ + { + "name": "str", + "messageSchemaReference": { + "schemaName": "str", + "schemaRegistryNamespace": "str", + "schemaVersion": "str", + }, + } + ], + "errors": [{"code": 0, "message": "str"}], + "events": [ + { + "name": "str", + "messageSchemaReference": { + "schemaName": "str", + "schemaRegistryNamespace": "str", + "schemaVersion": "str", + }, + } + ], + "version": 0, + }, + "uuid": "str", + "version": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-11-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.assets.begin_update( + resource_group_name=resource_group.name, + asset_name="str", + properties={ + "properties": { + "attributes": {"str": {}}, + "datasets": [ + { + "name": "str", + "dataPoints": [ + { + "dataSource": "str", + "name": "str", + "dataPointConfiguration": "str", + "observabilityMode": "None", + } + ], + "datasetConfiguration": "str", + "topic": {"path": "str", "retain": "str"}, + } + ], + "defaultDatasetsConfiguration": "str", + "defaultEventsConfiguration": "str", + "defaultTopic": {"path": "str", "retain": "str"}, + "description": "str", + "displayName": "str", + "documentationUri": "str", + "enabled": bool, + "events": [ + { + "eventNotifier": "str", + "name": "str", + "eventConfiguration": "str", + "observabilityMode": "None", + "topic": {"path": "str", "retain": "str"}, + } + ], + "hardwareRevision": "str", + "manufacturer": "str", + "manufacturerUri": "str", + "model": "str", + "productCode": "str", + "serialNumber": "str", + "softwareRevision": "str", + }, + "tags": {"str": "str"}, + }, + api_version="2024-11-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.assets.begin_delete( + resource_group_name=resource_group.name, + asset_name="str", + api_version="2024-11-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_assets_operations_async.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_assets_operations_async.py new file mode 100644 index 000000000000..eaaeaff31ae3 --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_assets_operations_async.py @@ -0,0 +1,226 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.deviceregistry.aio import DeviceRegistryMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDeviceRegistryMgmtAssetsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DeviceRegistryMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_subscription(self, resource_group): + response = self.client.assets.list_by_subscription( + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.assets.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.assets.get( + resource_group_name=resource_group.name, + asset_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_replace(self, resource_group): + response = await ( + await self.client.assets.begin_create_or_replace( + resource_group_name=resource_group.name, + asset_name="str", + resource={ + "extendedLocation": {"name": "str", "type": "str"}, + "location": "str", + "id": "str", + "name": "str", + "properties": { + "assetEndpointProfileRef": "str", + "attributes": {"str": {}}, + "datasets": [ + { + "name": "str", + "dataPoints": [ + { + "dataSource": "str", + "name": "str", + "dataPointConfiguration": "str", + "observabilityMode": "None", + } + ], + "datasetConfiguration": "str", + "topic": {"path": "str", "retain": "str"}, + } + ], + "defaultDatasetsConfiguration": "str", + "defaultEventsConfiguration": "str", + "defaultTopic": {"path": "str", "retain": "str"}, + "description": "str", + "discoveredAssetRefs": ["str"], + "displayName": "str", + "documentationUri": "str", + "enabled": bool, + "events": [ + { + "eventNotifier": "str", + "name": "str", + "eventConfiguration": "str", + "observabilityMode": "None", + "topic": {"path": "str", "retain": "str"}, + } + ], + "externalAssetId": "str", + "hardwareRevision": "str", + "manufacturer": "str", + "manufacturerUri": "str", + "model": "str", + "productCode": "str", + "provisioningState": "str", + "serialNumber": "str", + "softwareRevision": "str", + "status": { + "datasets": [ + { + "name": "str", + "messageSchemaReference": { + "schemaName": "str", + "schemaRegistryNamespace": "str", + "schemaVersion": "str", + }, + } + ], + "errors": [{"code": 0, "message": "str"}], + "events": [ + { + "name": "str", + "messageSchemaReference": { + "schemaName": "str", + "schemaRegistryNamespace": "str", + "schemaVersion": "str", + }, + } + ], + "version": 0, + }, + "uuid": "str", + "version": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-11-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.assets.begin_update( + resource_group_name=resource_group.name, + asset_name="str", + properties={ + "properties": { + "attributes": {"str": {}}, + "datasets": [ + { + "name": "str", + "dataPoints": [ + { + "dataSource": "str", + "name": "str", + "dataPointConfiguration": "str", + "observabilityMode": "None", + } + ], + "datasetConfiguration": "str", + "topic": {"path": "str", "retain": "str"}, + } + ], + "defaultDatasetsConfiguration": "str", + "defaultEventsConfiguration": "str", + "defaultTopic": {"path": "str", "retain": "str"}, + "description": "str", + "displayName": "str", + "documentationUri": "str", + "enabled": bool, + "events": [ + { + "eventNotifier": "str", + "name": "str", + "eventConfiguration": "str", + "observabilityMode": "None", + "topic": {"path": "str", "retain": "str"}, + } + ], + "hardwareRevision": "str", + "manufacturer": "str", + "manufacturerUri": "str", + "model": "str", + "productCode": "str", + "serialNumber": "str", + "softwareRevision": "str", + }, + "tags": {"str": "str"}, + }, + api_version="2024-11-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.assets.begin_delete( + resource_group_name=resource_group.name, + asset_name="str", + api_version="2024-11-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_billing_containers_operations.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_billing_containers_operations.py new file mode 100644 index 000000000000..9186ad3c4734 --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_billing_containers_operations.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.deviceregistry import DeviceRegistryMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDeviceRegistryMgmtBillingContainersOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DeviceRegistryMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_subscription(self, resource_group): + response = self.client.billing_containers.list_by_subscription( + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.billing_containers.get( + billing_container_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_billing_containers_operations_async.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_billing_containers_operations_async.py new file mode 100644 index 000000000000..467152d086f7 --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_billing_containers_operations_async.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.deviceregistry.aio import DeviceRegistryMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDeviceRegistryMgmtBillingContainersOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DeviceRegistryMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_subscription(self, resource_group): + response = self.client.billing_containers.list_by_subscription( + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.billing_containers.get( + billing_container_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_operation_status_operations.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_operation_status_operations.py new file mode 100644 index 000000000000..94e57facb520 --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_operation_status_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.deviceregistry import DeviceRegistryMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDeviceRegistryMgmtOperationStatusOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DeviceRegistryMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.operation_status.get( + location="str", + operation_id="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_operation_status_operations_async.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_operation_status_operations_async.py new file mode 100644 index 000000000000..89180d341a72 --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_operation_status_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.deviceregistry.aio import DeviceRegistryMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDeviceRegistryMgmtOperationStatusOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DeviceRegistryMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.operation_status.get( + location="str", + operation_id="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_operations.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_operations.py new file mode 100644 index 000000000000..0042b153f99b --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.deviceregistry import DeviceRegistryMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDeviceRegistryMgmtOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DeviceRegistryMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_operations_async.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_operations_async.py new file mode 100644 index 000000000000..7725c660a970 --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/generated_tests/test_device_registry_mgmt_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.deviceregistry.aio import DeviceRegistryMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDeviceRegistryMgmtOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DeviceRegistryMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/setup.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/setup.py index e2e5bda0d040..d48695cb5e69 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/setup.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/setup.py @@ -75,6 +75,7 @@ }, install_requires=[ "isodate>=0.6.1", + "typing-extensions>=4.6.0", "azure-common>=1.1", "azure-mgmt-core>=1.3.2", ],