diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/_meta.json b/sdk/deviceregistry/azure-mgmt-deviceregistry/_meta.json index 7cf4ecd7e565..14d423ba6cdb 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/_meta.json +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/_meta.json @@ -1,11 +1,7 @@ { - "commit": "1f6e89637068d59b5ae935de9a88d5742d12f8e6", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.7", - "use": [ - "@autorest/python@6.13.7", - "@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", - "readme": "specification/deviceregistry/resource-manager/readme.md" + "commit": "62e5ee267a4e0145c098aa0f1cb56e1d71953243", + "repository_url": "https://github.com/test-repo-billy/azure-rest-api-specs", + "typespec_src": "specification/deviceregistry/DeviceRegistry.Management", + "@azure-tools/typespec-python": "0.23.8", + "@autorest/python": "6.13.14" } \ No newline at end of file diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/__init__.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/__init__.py index 11d6fe8d17ce..2736b3aae031 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/__init__.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/__init__.py @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._device_registry_mgmt_client import DeviceRegistryMgmtClient +from ._client import DeviceRegistryMgmtClient from ._version import VERSION __version__ = VERSION diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_client.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_client.py new file mode 100644 index 000000000000..51b95f2bd9b9 --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_client.py @@ -0,0 +1,124 @@ +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.pipeline import policies +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy + +from ._configuration import DeviceRegistryMgmtClientConfiguration +from ._serialization import Deserializer, Serializer +from .operations import AssetEndpointProfilesOperations, AssetsOperations, OperationStatusOperations, Operations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class DeviceRegistryMgmtClient: # pylint: disable=client-accepts-api-version-keyword + """Microsoft.DeviceRegistry Resource Provider management API. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.deviceregistry.operations.Operations + :ivar operation_status: OperationStatusOperations operations + :vartype operation_status: azure.mgmt.deviceregistry.operations.OperationStatusOperations + :ivar assets: AssetsOperations operations + :vartype assets: azure.mgmt.deviceregistry.operations.AssetsOperations + :ivar asset_endpoint_profiles: AssetEndpointProfilesOperations operations + :vartype asset_endpoint_profiles: + azure.mgmt.deviceregistry.operations.AssetEndpointProfilesOperations + :param credential: Credential used to authenticate requests to the service. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: The API version to use for this operation. Default value is + "2023-11-01-preview". Note that overriding this default value may result in unsupported + behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DeviceRegistryMgmtClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.assets = AssetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.asset_endpoint_profiles = AssetEndpointProfilesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> "DeviceRegistryMgmtClient": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) 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..07608b26f5ae 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_configuration.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_configuration.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -24,12 +24,13 @@ class DeviceRegistryMgmtClientConfiguration: # pylint: disable=too-many-instanc Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. 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: The API version to use for this operation. Default value is + "2023-11-01-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_model_base.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_model_base.py new file mode 100644 index 000000000000..4b0f59f73e4c --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_model_base.py @@ -0,0 +1,875 @@ +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access, arguments-differ, signature-differs, broad-except + +import calendar +import decimal +import functools +import sys +import logging +import base64 +import re +import typing +import enum +import email.utils +from datetime import datetime, date, time, timedelta, timezone +from json import JSONEncoder +from typing_extensions import Self +import isodate +from azure.core.exceptions import DeserializationError +from azure.core import CaseInsensitiveEnumMeta +from azure.core.pipeline import PipelineResponse +from azure.core.serialization import _Null + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping + +_LOGGER = logging.getLogger(__name__) + +__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] + +TZ_UTC = timezone.utc +_T = typing.TypeVar("_T") + + +def _timedelta_as_isostr(td: timedelta) -> str: + """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' + + Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython + + :param timedelta td: The timedelta to convert + :rtype: str + :return: ISO8601 version of this timedelta + """ + + # Split seconds to larger units + seconds = td.total_seconds() + minutes, seconds = divmod(seconds, 60) + hours, minutes = divmod(minutes, 60) + days, hours = divmod(hours, 24) + + days, hours, minutes = list(map(int, (days, hours, minutes))) + seconds = round(seconds, 6) + + # Build date + date_str = "" + if days: + date_str = "%sD" % days + + if hours or minutes or seconds: + # Build time + time_str = "T" + + # Hours + bigger_exists = date_str or hours + if bigger_exists: + time_str += "{:02}H".format(hours) + + # Minutes + bigger_exists = bigger_exists or minutes + if bigger_exists: + time_str += "{:02}M".format(minutes) + + # Seconds + try: + if seconds.is_integer(): + seconds_string = "{:02}".format(int(seconds)) + else: + # 9 chars long w/ leading 0, 6 digits after decimal + seconds_string = "%09.6f" % seconds + # Remove trailing zeros + seconds_string = seconds_string.rstrip("0") + except AttributeError: # int.is_integer() raises + seconds_string = "{:02}".format(seconds) + + time_str += "{}S".format(seconds_string) + else: + time_str = "" + + return "P" + date_str + time_str + + +def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: + encoded = base64.b64encode(o).decode() + if format == "base64url": + return encoded.strip("=").replace("+", "-").replace("/", "_") + return encoded + + +def _serialize_datetime(o, format: typing.Optional[str] = None): + if hasattr(o, "year") and hasattr(o, "hour"): + if format == "rfc7231": + return email.utils.format_datetime(o, usegmt=True) + if format == "unix-timestamp": + return int(calendar.timegm(o.utctimetuple())) + + # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) + if not o.tzinfo: + iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() + else: + iso_formatted = o.astimezone(TZ_UTC).isoformat() + # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) + return iso_formatted.replace("+00:00", "Z") + # Next try datetime.date or datetime.time + return o.isoformat() + + +def _is_readonly(p): + try: + return p._visibility == ["read"] # pylint: disable=protected-access + except AttributeError: + return False + + +class SdkJSONEncoder(JSONEncoder): + """A JSON encoder that's capable of serializing datetime objects and bytes.""" + + def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): + super().__init__(*args, **kwargs) + self.exclude_readonly = exclude_readonly + self.format = format + + def default(self, o): # pylint: disable=too-many-return-statements + if _is_model(o): + if self.exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + return {k: v for k, v in o.items() if k not in readonly_props} + return dict(o.items()) + try: + return super(SdkJSONEncoder, self).default(o) + except TypeError: + if isinstance(o, _Null): + return None + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, self.format) + try: + # First try datetime.datetime + return _serialize_datetime(o, self.format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return super(SdkJSONEncoder, self).default(o) + + +_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") +_VALID_RFC7231 = re.compile( + r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" +) + + +def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + attr = attr.upper() + match = _VALID_DATE.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + return date_obj + + +def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize RFC7231 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + match = _VALID_RFC7231.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + return email.utils.parsedate_to_datetime(attr) + + +def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: + """Deserialize unix timestamp into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + return datetime.fromtimestamp(attr, TZ_UTC) + + +def _deserialize_date(attr: typing.Union[str, date]) -> date: + """Deserialize ISO-8601 formatted string into Date object. + :param str attr: response string to be deserialized. + :rtype: date + :returns: The date object from that input + """ + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + if isinstance(attr, date): + return attr + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore + + +def _deserialize_time(attr: typing.Union[str, time]) -> time: + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :returns: The time object from that input + """ + if isinstance(attr, time): + return attr + return isodate.parse_time(attr) + + +def _deserialize_bytes(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + return bytes(base64.b64decode(attr)) + + +def _deserialize_bytes_base64(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return bytes(base64.b64decode(encoded)) + + +def _deserialize_duration(attr): + if isinstance(attr, timedelta): + return attr + return isodate.parse_duration(attr) + + +def _deserialize_decimal(attr): + if isinstance(attr, decimal.Decimal): + return attr + return decimal.Decimal(str(attr)) + + +_DESERIALIZE_MAPPING = { + datetime: _deserialize_datetime, + date: _deserialize_date, + time: _deserialize_time, + bytes: _deserialize_bytes, + bytearray: _deserialize_bytes, + timedelta: _deserialize_duration, + typing.Any: lambda x: x, + decimal.Decimal: _deserialize_decimal, +} + +_DESERIALIZE_MAPPING_WITHFORMAT = { + "rfc3339": _deserialize_datetime, + "rfc7231": _deserialize_datetime_rfc7231, + "unix-timestamp": _deserialize_datetime_unix_timestamp, + "base64": _deserialize_bytes, + "base64url": _deserialize_bytes_base64, +} + + +def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): + if rf and rf._format: + return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) + return _DESERIALIZE_MAPPING.get(annotation) + + +def _get_type_alias_type(module_name: str, alias_name: str): + types = { + k: v + for k, v in sys.modules[module_name].__dict__.items() + if isinstance(v, typing._GenericAlias) # type: ignore + } + if alias_name not in types: + return alias_name + return types[alias_name] + + +def _get_model(module_name: str, model_name: str): + models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} + module_end = module_name.rsplit(".", 1)[0] + models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) + if isinstance(model_name, str): + model_name = model_name.split(".")[-1] + if model_name not in models: + return model_name + return models[model_name] + + +_UNSET = object() + + +class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object + def __init__(self, data: typing.Dict[str, typing.Any]) -> None: + self._data = data + + def __contains__(self, key: typing.Any) -> bool: + return key in self._data + + def __getitem__(self, key: str) -> typing.Any: + return self._data.__getitem__(key) + + def __setitem__(self, key: str, value: typing.Any) -> None: + self._data.__setitem__(key, value) + + def __delitem__(self, key: str) -> None: + self._data.__delitem__(key) + + def __iter__(self) -> typing.Iterator[typing.Any]: + return self._data.__iter__() + + def __len__(self) -> int: + return self._data.__len__() + + def __ne__(self, other: typing.Any) -> bool: + return not self.__eq__(other) + + def keys(self) -> typing.KeysView[str]: + return self._data.keys() + + def values(self) -> typing.ValuesView[typing.Any]: + return self._data.values() + + def items(self) -> typing.ItemsView[str, typing.Any]: + return self._data.items() + + def get(self, key: str, default: typing.Any = None) -> typing.Any: + try: + return self[key] + except KeyError: + return default + + @typing.overload + def pop(self, key: str) -> typing.Any: ... + + @typing.overload + def pop(self, key: str, default: _T) -> _T: ... + + @typing.overload + def pop(self, key: str, default: typing.Any) -> typing.Any: ... + + def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + if default is _UNSET: + return self._data.pop(key) + return self._data.pop(key, default) + + def popitem(self) -> typing.Tuple[str, typing.Any]: + return self._data.popitem() + + def clear(self) -> None: + self._data.clear() + + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: + self._data.update(*args, **kwargs) + + @typing.overload + def setdefault(self, key: str, default: None = None) -> None: ... + + @typing.overload + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... + + def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + if default is _UNSET: + return self._data.setdefault(key) + return self._data.setdefault(key, default) + + def __eq__(self, other: typing.Any) -> bool: + try: + other_model = self.__class__(other) + except Exception: + return False + return self._data == other_model._data + + def __repr__(self) -> str: + return str(self._data) + + +def _is_model(obj: typing.Any) -> bool: + return getattr(obj, "_is_model", False) + + +def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements + if isinstance(o, list): + return [_serialize(x, format) for x in o] + if isinstance(o, dict): + return {k: _serialize(v, format) for k, v in o.items()} + if isinstance(o, set): + return {_serialize(x, format) for x in o} + if isinstance(o, tuple): + return tuple(_serialize(x, format) for x in o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, format) + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, enum.Enum): + return o.value + try: + # First try datetime.datetime + return _serialize_datetime(o, format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return o + + +def _get_rest_field( + attr_to_rest_field: typing.Dict[str, "_RestField"], rest_name: str +) -> typing.Optional["_RestField"]: + try: + return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) + except StopIteration: + return None + + +def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: + if not rf: + return _serialize(value, None) + if rf._is_multipart_file_input: + return value + if rf._is_model: + return _deserialize(rf._type, value) + return _serialize(value, rf._format) + + +class Model(_MyMutableMapping): + _is_model = True + + def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: + class_name = self.__class__.__name__ + if len(args) > 1: + raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") + dict_to_pass = { + rest_field._rest_name: rest_field._default + for rest_field in self._attr_to_rest_field.values() + if rest_field._default is not _UNSET + } + if args: + dict_to_pass.update( + {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} + ) + else: + non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] + if non_attr_kwargs: + # actual type errors only throw the first wrong keyword arg they see, so following that. + raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") + dict_to_pass.update( + { + self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) + for k, v in kwargs.items() + if v is not None + } + ) + super().__init__(dict_to_pass) + + def copy(self) -> "Model": + return Model(self.__dict__) + + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: disable=unused-argument + # we know the last three classes in mro are going to be 'Model', 'dict', and 'object' + mros = cls.__mro__[:-3][::-1] # ignore model, dict, and object parents, and reverse the mro order + attr_to_rest_field: typing.Dict[str, _RestField] = { # map attribute name to rest_field property + k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") + } + annotations = { + k: v + for mro_class in mros + if hasattr(mro_class, "__annotations__") # pylint: disable=no-member + for k, v in mro_class.__annotations__.items() # pylint: disable=no-member + } + for attr, rf in attr_to_rest_field.items(): + rf._module = cls.__module__ + if not rf._type: + rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) + if not rf._rest_name_input: + rf._rest_name_input = attr + cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) + + return super().__new__(cls) # pylint: disable=no-value-for-parameter + + def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: + for base in cls.__bases__: + if hasattr(base, "__mapping__"): # pylint: disable=no-member + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore # pylint: disable=no-member + + @classmethod + def _get_discriminator(cls, exist_discriminators) -> typing.Optional[str]: + for v in cls.__dict__.values(): + if ( + isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators + ): # pylint: disable=protected-access + return v._rest_name # pylint: disable=protected-access + return None + + @classmethod + def _deserialize(cls, data, exist_discriminators): + if not hasattr(cls, "__mapping__"): # pylint: disable=no-member + return cls(data) + discriminator = cls._get_discriminator(exist_discriminators) + exist_discriminators.append(discriminator) + mapped_cls = cls.__mapping__.get(data.get(discriminator), cls) # pyright: ignore # pylint: disable=no-member + if mapped_cls == cls: + return cls(data) + return mapped_cls._deserialize(data, exist_discriminators) # pylint: disable=protected-access + + def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]: + """Return a dict that can be JSONify using json.dump. + + :keyword bool exclude_readonly: Whether to remove the readonly properties. + :returns: A dict JSON compatible object + :rtype: dict + """ + + result = {} + if exclude_readonly: + readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] + for k, v in self.items(): + if exclude_readonly and k in readonly_props: # pyright: ignore + continue + is_multipart_file_input = False + try: + is_multipart_file_input = next( + rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k + )._is_multipart_file_input + except StopIteration: + pass + result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) + return result + + @staticmethod + def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: + if v is None or isinstance(v, _Null): + return None + if isinstance(v, (list, tuple, set)): + return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) + if isinstance(v, dict): + return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} + return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v + + +def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): + if _is_model(obj): + return obj + return _deserialize(model_deserializer, obj) + + +def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): + if obj is None: + return obj + return _deserialize_with_callable(if_obj_deserializer, obj) + + +def _deserialize_with_union(deserializers, obj): + for deserializer in deserializers: + try: + return _deserialize(deserializer, obj) + except DeserializationError: + pass + raise DeserializationError() + + +def _deserialize_dict( + value_deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj: typing.Dict[typing.Any, typing.Any], +): + if obj is None: + return obj + return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} + + +def _deserialize_multiple_sequence( + entry_deserializers: typing.List[typing.Optional[typing.Callable]], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) + + +def _deserialize_sequence( + deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) + + +def _get_deserialize_callable_from_annotation( # pylint: disable=R0911, R0915, R0912 + annotation: typing.Any, + module: typing.Optional[str], + rf: typing.Optional["_RestField"] = None, +) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + if not annotation or annotation in [int, float]: + return None + + # is it a type alias? + if isinstance(annotation, str): + if module is not None: + annotation = _get_type_alias_type(module, annotation) + + # is it a forward ref / in quotes? + if isinstance(annotation, (str, typing.ForwardRef)): + try: + model_name = annotation.__forward_arg__ # type: ignore + except AttributeError: + model_name = annotation + if module is not None: + annotation = _get_model(module, model_name) + + try: + if module and _is_model(annotation): + if rf: + rf._is_model = True + + return functools.partial(_deserialize_model, annotation) # pyright: ignore + except Exception: + pass + + # is it a literal? + try: + if annotation.__origin__ is typing.Literal: # pyright: ignore + return None + except AttributeError: + pass + + # is it optional? + try: + if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_with_optional, if_obj_deserializer) + except AttributeError: + pass + + if getattr(annotation, "__origin__", None) is typing.Union: + # initial ordering is we make `string` the last deserialization option, because it is often them most generic + deserializers = [ + _get_deserialize_callable_from_annotation(arg, module, rf) + for arg in sorted( + annotation.__args__, key=lambda x: hasattr(x, "__name__") and x.__name__ == "str" # pyright: ignore + ) + ] + + return functools.partial(_deserialize_with_union, deserializers) + + try: + if annotation._name == "Dict": # pyright: ignore + value_deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[1], module, rf # pyright: ignore + ) + + return functools.partial( + _deserialize_dict, + value_deserializer, + module, + ) + except (AttributeError, IndexError): + pass + try: + if annotation._name in ["List", "Set", "Tuple", "Sequence"]: # pyright: ignore + if len(annotation.__args__) > 1: # pyright: ignore + + entry_deserializers = [ + _get_deserialize_callable_from_annotation(dt, module, rf) + for dt in annotation.__args__ # pyright: ignore + ] + return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) + deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[0], module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_sequence, deserializer, module) + except (TypeError, IndexError, AttributeError, SyntaxError): + pass + + def _deserialize_default( + deserializer, + obj, + ): + if obj is None: + return obj + try: + return _deserialize_with_callable(deserializer, obj) + except Exception: + pass + return obj + + if get_deserializer(annotation, rf): + return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) + + return functools.partial(_deserialize_default, annotation) + + +def _deserialize_with_callable( + deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], + value: typing.Any, +): + try: + if value is None or isinstance(value, _Null): + return None + if deserializer is None: + return value + if isinstance(deserializer, CaseInsensitiveEnumMeta): + try: + return deserializer(value) + except ValueError: + # for unknown value, return raw value + return value + if isinstance(deserializer, type) and issubclass(deserializer, Model): + return deserializer._deserialize(value, []) + return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) + except Exception as e: + raise DeserializationError() from e + + +def _deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + if isinstance(value, PipelineResponse): + value = value.http_response.json() + if rf is None and format: + rf = _RestField(format=format) + if not isinstance(deserializer, functools.partial): + deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) + return _deserialize_with_callable(deserializer, value) + + +class _RestField: + def __init__( + self, + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + is_discriminator: bool = False, + visibility: typing.Optional[typing.List[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + ): + self._type = type + self._rest_name_input = name + self._module: typing.Optional[str] = None + self._is_discriminator = is_discriminator + self._visibility = visibility + self._is_model = False + self._default = default + self._format = format + self._is_multipart_file_input = is_multipart_file_input + + @property + def _class_type(self) -> typing.Any: + return getattr(self._type, "args", [None])[0] + + @property + def _rest_name(self) -> str: + if self._rest_name_input is None: + raise ValueError("Rest name was never set") + return self._rest_name_input + + def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin + # by this point, type and rest_name will have a value bc we default + # them in __new__ of the Model class + item = obj.get(self._rest_name) + if item is None: + return item + if self._is_model: + return item + return _deserialize(self._type, _serialize(item, self._format), rf=self) + + def __set__(self, obj: Model, value) -> None: + if value is None: + # we want to wipe out entries if users set attr to None + try: + obj.__delitem__(self._rest_name) + except KeyError: + pass + return + if self._is_model: + if not _is_model(value): + value = _deserialize(self._type, value) + obj.__setitem__(self._rest_name, value) + return + obj.__setitem__(self._rest_name, _serialize(value, self._format)) + + def _get_deserialize_callable_from_annotation( + self, annotation: typing.Any + ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + return _get_deserialize_callable_from_annotation(annotation, self._module, self) + + +def rest_field( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[typing.List[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, +) -> typing.Any: + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + ) + + +def rest_discriminator( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin +) -> typing.Any: + return _RestField(name=name, type=type, is_discriminator=True) diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_version.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_version.py index e5754a47ce68..be71c81bd282 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_version.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/_version.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/__init__.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/__init__.py index 59834c530efb..85a536da8adc 100644 --- a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/__init__.py +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/__init__.py @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._device_registry_mgmt_client import DeviceRegistryMgmtClient +from ._client import DeviceRegistryMgmtClient try: from ._patch import __all__ as _patch_all diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/_client.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/_client.py new file mode 100644 index 000000000000..ce4166186067 --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/_client.py @@ -0,0 +1,126 @@ +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.pipeline import policies +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy + +from .._serialization import Deserializer, Serializer +from ._configuration import DeviceRegistryMgmtClientConfiguration +from .operations import AssetEndpointProfilesOperations, AssetsOperations, OperationStatusOperations, Operations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class DeviceRegistryMgmtClient: # pylint: disable=client-accepts-api-version-keyword + """Microsoft.DeviceRegistry Resource Provider management API. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.deviceregistry.aio.operations.Operations + :ivar operation_status: OperationStatusOperations operations + :vartype operation_status: azure.mgmt.deviceregistry.aio.operations.OperationStatusOperations + :ivar assets: AssetsOperations operations + :vartype assets: azure.mgmt.deviceregistry.aio.operations.AssetsOperations + :ivar asset_endpoint_profiles: AssetEndpointProfilesOperations operations + :vartype asset_endpoint_profiles: + azure.mgmt.deviceregistry.aio.operations.AssetEndpointProfilesOperations + :param credential: Credential used to authenticate requests to the service. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: The API version to use for this operation. Default value is + "2023-11-01-preview". Note that overriding this default value may result in unsupported + behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DeviceRegistryMgmtClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.assets = AssetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.asset_endpoint_profiles = AssetEndpointProfilesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "DeviceRegistryMgmtClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) 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..0c1aa91f556a 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -24,12 +24,13 @@ class DeviceRegistryMgmtClientConfiguration: # pylint: disable=too-many-instanc Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. 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: The API version to use for this operation. Default value is + "2023-11-01-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ 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..285d6449a1a6 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 @@ -2,14 +2,14 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._operations import Operations -from ._asset_endpoint_profiles_operations import AssetEndpointProfilesOperations -from ._assets_operations import AssetsOperations -from ._operation_status_operations import OperationStatusOperations +from ._operations import OperationStatusOperations +from ._operations import AssetsOperations +from ._operations import AssetEndpointProfilesOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -17,9 +17,9 @@ __all__ = [ "Operations", - "AssetEndpointProfilesOperations", - "AssetsOperations", "OperationStatusOperations", + "AssetsOperations", + "AssetEndpointProfilesOperations", ] __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/aio/operations/_operations.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/aio/operations/_operations.py index 9fad95233545..a5fdde91013b 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 @@ -3,10 +3,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python 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 +from io import IOBase +import json +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,18 +22,40 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request -from ...operations._operations import build_list_request +from ..._model_base import SdkJSONEncoder, _deserialize +from ...operations._operations import ( + build_asset_endpoint_profiles_create_or_replace_request, + build_asset_endpoint_profiles_delete_request, + build_asset_endpoint_profiles_get_request, + build_asset_endpoint_profiles_list_by_resource_group_request, + build_asset_endpoint_profiles_list_by_subscription_request, + build_asset_endpoint_profiles_update_request, + build_assets_create_or_replace_request, + build_assets_delete_request, + build_assets_get_request, + build_assets_list_by_resource_group_request, + build_assets_list_by_subscription_request, + build_assets_update_request, + build_operation_status_get_request, + build_operations_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]] +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object class Operations: @@ -43,8 +68,6 @@ class Operations: :attr:`operations` 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") @@ -54,19 +77,50 @@ def __init__(self, *args, **kwargs) -> None: @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: + # pylint: disable=line-too-long """List the operations for the provider. - :return: An iterator like instance of either Operation or the result of cls(response) + :return: An iterator like instance of Operation :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.deviceregistry.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "actionType": "str", # Optional. Enum. Indicates the action type. "Internal" + refers to actions that are for internal only APIs. "Internal" + "display": { + "description": "str", # Optional. The short, localized friendly + description of the operation; suitable for tool tips and detailed views. + "operation": "str", # Optional. The concise, localized friendly name + for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + Machine", "Restart Virtual Machine". + "provider": "str", # Optional. The localized friendly form of the + resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + Compute". + "resource": "str" # Optional. The localized friendly name of the + resource type related to this operation. E.g. "Virtual Machines" or "Job + Schedule Collections". + }, + "isDataAction": bool, # Optional. Whether the operation applies to + data-plane. This is "true" for data-plane operations and "false" for Azure + Resource Manager/control-plane operations. + "name": "str", # Optional. The name of the operation, as per Resource-Based + Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + "Microsoft.Compute/virtualMachines/capture/action". + "origin": "str" # Optional. The intended executor of the operation; as in + Resource Based Access Control (RBAC) and audit logs UX. Default value is + "user,system". Known values are: "user", "system", and "user,system". + } """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -77,12 +131,11 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - _request = build_list_request( - api_version=api_version, + _request = build_operations_list_request( + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -98,17 +151,4711 @@ 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 + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Operation], deserialized["value"]) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.deviceregistry.aio.DeviceRegistryMgmtClient`'s + :attr:`operation_status` attribute. + """ + + 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_async + async def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.OperationStatusResult: + """Returns the current status of an async operation. + + :param location: The location name. Required. + :type location: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :return: OperationStatusResult. The OperationStatusResult is compatible with MutableMapping + :rtype: ~azure.mgmt.deviceregistry.models.OperationStatusResult + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "operations": [ + ... + ], + "status": "str", # Operation status. Required. + "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. + "error": { + "additionalInfo": [ + { + "info": {}, # Optional. The additional info. + "type": "str" # Optional. The additional info type. + } + ], + "code": "str", # Optional. The error code. + "details": [ + ... + ], + "message": "str", # Optional. The error message. + "target": "str" # Optional. The error target. + }, + "id": "str", # Optional. Fully qualified ID for the async operation. + "name": "str", # Optional. Name of the async operation. + "percentComplete": 0, # Optional. Percent of the operation that is complete. + "startTime": "2020-02-20 00:00:00" # Optional. The start time of the + operation. + } + """ + 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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + _request = build_operation_status_get_request( + location=location, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = kwargs.pop("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]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.OperationStatusResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class AssetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.deviceregistry.aio.DeviceRegistryMgmtClient`'s + :attr:`assets` attribute. + """ + + 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_async + async def get(self, resource_group_name: str, asset_name: str, **kwargs: Any) -> _models.Asset: + # pylint: disable=line-too-long + """Get a Asset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_name: Asset name parameter. Required. + :type asset_name: str + :return: Asset. The Asset is compatible with MutableMapping + :rtype: ~azure.mgmt.deviceregistry.models.Asset + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + 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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Asset] = kwargs.pop("cls", None) + + _request = build_assets_get_request( + resource_group_name=resource_group_name, + asset_name=asset_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = kwargs.pop("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]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Asset, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_replace_initial( + self, resource_group_name: str, asset_name: str, resource: Union[_models.Asset, JSON, IO[bytes]], **kwargs: Any + ) -> JSON: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_assets_create_or_replace_request( + resource_group_name=resource_group_name, + asset_name=asset_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + 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, 201]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = _deserialize(JSON, response.json()) + + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(JSON, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_replace( + self, + resource_group_name: str, + asset_name: str, + resource: _models.Asset, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Asset]: + # pylint: disable=line-too-long + """Create a Asset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_name: Asset name parameter. Required. + :type asset_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.deviceregistry.models.Asset + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Asset. The Asset is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.deviceregistry.models.Asset] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + resource = { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + + # response body for status code(s): 200, 201 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @overload + async def begin_create_or_replace( + self, + resource_group_name: str, + asset_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Asset]: + # pylint: disable=line-too-long + """Create a Asset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_name: Asset name parameter. Required. + :type asset_name: str + :param resource: Resource create parameters. Required. + :type resource: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Asset. The Asset is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.deviceregistry.models.Asset] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 201 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @overload + async def begin_create_or_replace( + self, + resource_group_name: str, + asset_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Asset]: + # pylint: disable=line-too-long + """Create a Asset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_name: Asset name parameter. Required. + :type asset_name: str + :param resource: Resource create parameters. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Asset. The Asset is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.deviceregistry.models.Asset] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 201 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @distributed_trace_async + async def begin_create_or_replace( + self, resource_group_name: str, asset_name: str, resource: Union[_models.Asset, JSON, IO[bytes]], **kwargs: Any + ) -> AsyncLROPoller[_models.Asset]: + # pylint: disable=line-too-long + """Create a Asset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_name: Asset name parameter. Required. + :type asset_name: str + :param resource: Resource create parameters. Is one of the following types: Asset, JSON, + IO[bytes] Required. + :type resource: ~azure.mgmt.deviceregistry.models.Asset or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Asset. The Asset is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.deviceregistry.models.Asset] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + resource = { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + + # response body for status code(s): 200, 201 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Asset] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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._create_or_replace_initial( + resource_group_name=resource_group_name, + asset_name=asset_name, + resource=resource, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Asset, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Asset].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Asset]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + asset_name: str, + properties: Union[_models.AssetUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> Optional[JSON]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_assets_update_request( + resource_group_name=resource_group_name, + asset_name=asset_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + 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, 202]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = _deserialize(JSON, response.json()) + + 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")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + asset_name: str, + properties: _models.AssetUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Asset]: + # pylint: disable=line-too-long + """Update a Asset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_name: Asset name parameter. Required. + :type asset_name: str + :param properties: The resource properties to be updated. Required. + :type properties: ~azure.mgmt.deviceregistry.models.AssetUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Asset. The Asset is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.deviceregistry.models.Asset] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + properties = { + "properties": { + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str" # Optional. Revision number of the + software. + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + + # response body for status code(s): 200, 202 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + asset_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Asset]: + # pylint: disable=line-too-long + """Update a Asset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_name: Asset name parameter. Required. + :type asset_name: str + :param properties: The resource properties to be updated. Required. + :type properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Asset. The Asset is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.deviceregistry.models.Asset] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 202 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + asset_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Asset]: + # pylint: disable=line-too-long + """Update a Asset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_name: Asset name parameter. Required. + :type asset_name: str + :param properties: The resource properties to be updated. Required. + :type properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Asset. The Asset is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.deviceregistry.models.Asset] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 202 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + asset_name: str, + properties: Union[_models.AssetUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Asset]: + # pylint: disable=line-too-long + """Update a Asset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_name: Asset name parameter. Required. + :type asset_name: str + :param properties: The resource properties to be updated. Is one of the following types: + AssetUpdate, JSON, IO[bytes] Required. + :type properties: ~azure.mgmt.deviceregistry.models.AssetUpdate or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Asset. The Asset is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.deviceregistry.models.Asset] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + properties = { + "properties": { + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str" # Optional. Revision number of the + software. + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + + # response body for status code(s): 200, 202 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Asset] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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._update_initial( + resource_group_name=resource_group_name, + asset_name=asset_name, + properties=properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Asset, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Asset].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Asset]( + 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: 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 = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_assets_delete_request( + resource_group_name=resource_group_name, + asset_name=asset_name, + subscription_id=self._config.subscription_id, + api_version=self._config.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 [202, 204]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + 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")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, asset_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Delete a Asset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_name: Asset name parameter. Required. + :type asset_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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 + resource_group_name=resource_group_name, + asset_name=asset_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Asset"]: + # pylint: disable=line-too-long + """List Asset resources by resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of Asset + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.deviceregistry.models.Asset] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Asset]] = 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_assets_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.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) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Asset], deserialized["value"]) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Asset"]: + # pylint: disable=line-too-long + """List Asset resources by subscription ID. + + :return: An iterator like instance of Asset + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.deviceregistry.models.Asset] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Asset]] = 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_assets_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.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) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Asset], deserialized["value"]) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class AssetEndpointProfilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.deviceregistry.aio.DeviceRegistryMgmtClient`'s + :attr:`asset_endpoint_profiles` attribute. + """ + + 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_async + async def get( + self, resource_group_name: str, asset_endpoint_profile_name: str, **kwargs: Any + ) -> _models.AssetEndpointProfile: + # pylint: disable=line-too-long + """Get a AssetEndpointProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_endpoint_profile_name: Asset Endpoint Profile name parameter. Required. + :type asset_endpoint_profile_name: str + :return: AssetEndpointProfile. The AssetEndpointProfile is compatible with MutableMapping + :rtype: ~azure.mgmt.deviceregistry.models.AssetEndpointProfile + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + 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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AssetEndpointProfile] = kwargs.pop("cls", None) + + _request = build_asset_endpoint_profiles_get_request( + resource_group_name=resource_group_name, + asset_endpoint_profile_name=asset_endpoint_profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = kwargs.pop("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]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.AssetEndpointProfile, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_replace_initial( + self, + resource_group_name: str, + asset_endpoint_profile_name: str, + resource: Union[_models.AssetEndpointProfile, JSON, IO[bytes]], + **kwargs: Any + ) -> JSON: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_asset_endpoint_profiles_create_or_replace_request( + resource_group_name=resource_group_name, + asset_endpoint_profile_name=asset_endpoint_profile_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + 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, 201]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = _deserialize(JSON, response.json()) + + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(JSON, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_replace( + self, + resource_group_name: str, + asset_endpoint_profile_name: str, + resource: _models.AssetEndpointProfile, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AssetEndpointProfile]: + # pylint: disable=line-too-long + """Create a AssetEndpointProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_endpoint_profile_name: Asset Endpoint Profile name parameter. Required. + :type asset_endpoint_profile_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.deviceregistry.models.AssetEndpointProfile + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AssetEndpointProfile. The + AssetEndpointProfile is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.deviceregistry.models.AssetEndpointProfile] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + resource = { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + + # response body for status code(s): 200, 201 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @overload + async def begin_create_or_replace( + self, + resource_group_name: str, + asset_endpoint_profile_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AssetEndpointProfile]: + # pylint: disable=line-too-long + """Create a AssetEndpointProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_endpoint_profile_name: Asset Endpoint Profile name parameter. Required. + :type asset_endpoint_profile_name: str + :param resource: Resource create parameters. Required. + :type resource: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AssetEndpointProfile. The + AssetEndpointProfile is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.deviceregistry.models.AssetEndpointProfile] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 201 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @overload + async def begin_create_or_replace( + self, + resource_group_name: str, + asset_endpoint_profile_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AssetEndpointProfile]: + # pylint: disable=line-too-long + """Create a AssetEndpointProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_endpoint_profile_name: Asset Endpoint Profile name parameter. Required. + :type asset_endpoint_profile_name: str + :param resource: Resource create parameters. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AssetEndpointProfile. The + AssetEndpointProfile is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.deviceregistry.models.AssetEndpointProfile] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 201 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @distributed_trace_async + async def begin_create_or_replace( + self, + resource_group_name: str, + asset_endpoint_profile_name: str, + resource: Union[_models.AssetEndpointProfile, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AssetEndpointProfile]: + # pylint: disable=line-too-long + """Create a AssetEndpointProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_endpoint_profile_name: Asset Endpoint Profile name parameter. Required. + :type asset_endpoint_profile_name: str + :param resource: Resource create parameters. Is one of the following types: + AssetEndpointProfile, JSON, IO[bytes] Required. + :type resource: ~azure.mgmt.deviceregistry.models.AssetEndpointProfile or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns AssetEndpointProfile. The + AssetEndpointProfile is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.deviceregistry.models.AssetEndpointProfile] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + resource = { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + + # response body for status code(s): 200, 201 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AssetEndpointProfile] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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._create_or_replace_initial( + resource_group_name=resource_group_name, + asset_endpoint_profile_name=asset_endpoint_profile_name, + resource=resource, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AssetEndpointProfile, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.AssetEndpointProfile].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AssetEndpointProfile]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + asset_endpoint_profile_name: str, + properties: Union[_models.AssetEndpointProfileUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> Optional[JSON]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_asset_endpoint_profiles_update_request( + resource_group_name=resource_group_name, + asset_endpoint_profile_name=asset_endpoint_profile_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + 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, 202]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = _deserialize(JSON, response.json()) + + 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")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + asset_endpoint_profile_name: str, + properties: _models.AssetEndpointProfileUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AssetEndpointProfile]: + # pylint: disable=line-too-long + """Update a AssetEndpointProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_endpoint_profile_name: Asset Endpoint Profile name parameter. Required. + :type asset_endpoint_profile_name: str + :param properties: The resource properties to be updated. Required. + :type properties: ~azure.mgmt.deviceregistry.models.AssetEndpointProfileUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AssetEndpointProfile. The + AssetEndpointProfile is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.deviceregistry.models.AssetEndpointProfile] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + properties = { + "properties": { + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "targetAddress": "str", # Optional. The local valid URI specifying + the network address/DNS name of a southbound device. The scheme part of the + targetAddress URI specifies the type of the device. The + additionalConfiguration field holds further connector type specific + configuration. + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + } + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + + # response body for status code(s): 200, 202 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + asset_endpoint_profile_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AssetEndpointProfile]: + # pylint: disable=line-too-long + """Update a AssetEndpointProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_endpoint_profile_name: Asset Endpoint Profile name parameter. Required. + :type asset_endpoint_profile_name: str + :param properties: The resource properties to be updated. Required. + :type properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AssetEndpointProfile. The + AssetEndpointProfile is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.deviceregistry.models.AssetEndpointProfile] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 202 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + asset_endpoint_profile_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AssetEndpointProfile]: + # pylint: disable=line-too-long + """Update a AssetEndpointProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_endpoint_profile_name: Asset Endpoint Profile name parameter. Required. + :type asset_endpoint_profile_name: str + :param properties: The resource properties to be updated. Required. + :type properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AssetEndpointProfile. The + AssetEndpointProfile is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.deviceregistry.models.AssetEndpointProfile] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 202 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + asset_endpoint_profile_name: str, + properties: Union[_models.AssetEndpointProfileUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AssetEndpointProfile]: + # pylint: disable=line-too-long + """Update a AssetEndpointProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_endpoint_profile_name: Asset Endpoint Profile name parameter. Required. + :type asset_endpoint_profile_name: str + :param properties: The resource properties to be updated. Is one of the following types: + AssetEndpointProfileUpdate, JSON, IO[bytes] Required. + :type properties: ~azure.mgmt.deviceregistry.models.AssetEndpointProfileUpdate or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns AssetEndpointProfile. The + AssetEndpointProfile is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.deviceregistry.models.AssetEndpointProfile] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + properties = { + "properties": { + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "targetAddress": "str", # Optional. The local valid URI specifying + the network address/DNS name of a southbound device. The scheme part of the + targetAddress URI specifies the type of the device. The + additionalConfiguration field holds further connector type specific + configuration. + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + } + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + + # response body for status code(s): 200, 202 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AssetEndpointProfile] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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._update_initial( + resource_group_name=resource_group_name, + asset_endpoint_profile_name=asset_endpoint_profile_name, + properties=properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AssetEndpointProfile, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.AssetEndpointProfile].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AssetEndpointProfile]( + 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_endpoint_profile_name: str, **kwargs: Any + ) -> None: + 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 = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_asset_endpoint_profiles_delete_request( + resource_group_name=resource_group_name, + asset_endpoint_profile_name=asset_endpoint_profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.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 [202, 204]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + 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")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, asset_endpoint_profile_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a AssetEndpointProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_endpoint_profile_name: Asset Endpoint Profile name parameter. Required. + :type asset_endpoint_profile_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + 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 + resource_group_name=resource_group_name, + asset_endpoint_profile_name=asset_endpoint_profile_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AssetEndpointProfile"]: + # pylint: disable=line-too-long + """List AssetEndpointProfile resources by resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of AssetEndpointProfile + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.deviceregistry.models.AssetEndpointProfile] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AssetEndpointProfile]] = 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_asset_endpoint_profiles_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.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) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.AssetEndpointProfile], deserialized["value"]) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AssetEndpointProfile"]: + # pylint: disable=line-too-long + """List AssetEndpointProfile resources by subscription ID. + + :return: An iterator like instance of AssetEndpointProfile + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.deviceregistry.models.AssetEndpointProfile] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AssetEndpointProfile]] = 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_asset_endpoint_profiles_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.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) + return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.AssetEndpointProfile], deserialized["value"]) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -120,8 +4867,10 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response 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..7383f9718d53 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 @@ -2,57 +2,59 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._models_py3 import Asset -from ._models_py3 import AssetEndpointProfile -from ._models_py3 import AssetEndpointProfileListResult -from ._models_py3 import AssetEndpointProfileProperties -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 AssetStatusError -from ._models_py3 import AssetUpdate -from ._models_py3 import AssetUpdateProperties -from ._models_py3 import DataPoint -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import Event -from ._models_py3 import ExtendedLocation -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 Resource -from ._models_py3 import SystemData -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 ._models import ArmOperationStatusResourceProvisioningState +from ._models import ArmResource +from ._models import ArmResourceBase +from ._models import Asset +from ._models import AssetEndpointProfile +from ._models import AssetEndpointProfileListResult +from ._models import AssetEndpointProfileProperties +from ._models import AssetEndpointProfileUpdate +from ._models import AssetEndpointProfileUpdateProperties +from ._models import AssetListResult +from ._models import AssetProperties +from ._models import AssetStatus +from ._models import AssetStatusError +from ._models import AssetUpdate +from ._models import AssetUpdateProperties +from ._models import DataPoint +from ._models import ErrorAdditionalInfo +from ._models import ErrorDetail +from ._models import ErrorResponse +from ._models import Event +from ._models import ExtendedLocation +from ._models import Operation +from ._models import OperationDisplay +from ._models import OperationStatusResult +from ._models import OwnCertificate +from ._models import PagedOperation +from ._models import SystemData +from ._models import TrackedResourceBase +from ._models import TransportAuthentication +from ._models import UserAuthentication +from ._models import UsernamePasswordCredentials +from ._models import X509Credentials -from ._device_registry_mgmt_client_enums import ActionType -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 Origin -from ._device_registry_mgmt_client_enums import ProvisioningState -from ._device_registry_mgmt_client_enums import UserAuthenticationMode +from ._enums import ActionType +from ._enums import CreatedByType +from ._enums import DataPointsObservabilityMode +from ._enums import EventsObservabilityMode +from ._enums import Origin +from ._enums import ProvisioningState +from ._enums import ResourceProvisioningState +from ._enums import UserAuthenticationMode from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ + "ArmOperationStatusResourceProvisioningState", + "ArmResource", + "ArmResourceBase", "Asset", "AssetEndpointProfile", "AssetEndpointProfileListResult", @@ -73,26 +75,22 @@ "ExtendedLocation", "Operation", "OperationDisplay", - "OperationListResult", "OperationStatusResult", "OwnCertificate", - "Resource", + "PagedOperation", "SystemData", - "TrackedResource", + "TrackedResourceBase", "TransportAuthentication", - "TransportAuthenticationUpdate", "UserAuthentication", - "UserAuthenticationUpdate", "UsernamePasswordCredentials", - "UsernamePasswordCredentialsUpdate", "X509Credentials", - "X509CredentialsUpdate", "ActionType", "CreatedByType", "DataPointsObservabilityMode", "EventsObservabilityMode", "Origin", "ProvisioningState", + "ResourceProvisioningState", "UserAuthenticationMode", ] __all__.extend([p for p in _patch_all if p not in __all__]) diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/models/_enums.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/models/_enums.py new file mode 100644 index 000000000000..28116a2e1304 --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/models/_enums.py @@ -0,0 +1,102 @@ +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" + + INTERNAL = "Internal" + """Actions are for internal-only APIs.""" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The kind of entity that created the resource.""" + + USER = "User" + """The entity was created by a user.""" + APPLICATION = "Application" + """The entity was created by an application.""" + MANAGED_IDENTITY = "ManagedIdentity" + """The entity was created by a managed identity.""" + KEY = "Key" + """The entity was created by a key.""" + + +class DataPointsObservabilityMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the data point observability mode.""" + + NONE = "none" + """No mapping to OpenTelemetry.""" + COUNTER = "counter" + """Map as counter to OpenTelemetry.""" + GAUGE = "gauge" + """Map as gauge to OpenTelemetry.""" + HISTOGRAM = "histogram" + """Map as histogram to OpenTelemetry.""" + LOG = "log" + """Map as log to OpenTelemetry.""" + + +class EventsObservabilityMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the event observability mode.""" + + NONE = "none" + """No mapping to OpenTelemetry.""" + LOG = "log" + """Map as log to OpenTelemetry.""" + + +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system". + """ + + USER = "user" + """Indicates the operation is initiated by a user.""" + SYSTEM = "system" + """Indicates the operation is initiated by a system.""" + USER_SYSTEM = "user,system" + """Indicates the operation is initiated by a user or system.""" + + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning status of the resource.""" + + SUCCEEDED = "Succeeded" + """Resource has been created.""" + FAILED = "Failed" + """Resource creation failed.""" + CANCELED = "Canceled" + """Resource creation was canceled.""" + ACCEPTED = "Accepted" + """Resource has been accepted by the server.""" + + +class ResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of a resource type.""" + + SUCCEEDED = "Succeeded" + """Resource has been created.""" + FAILED = "Failed" + """Resource creation failed.""" + CANCELED = "Canceled" + """Resource creation was canceled.""" + + +class UserAuthenticationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The mode to authenticate the user of the client at the server.""" + + 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.""" diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/models/_models.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/models/_models.py new file mode 100644 index 000000000000..16c896558fd2 --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/models/_models.py @@ -0,0 +1,1543 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +from typing import Any, Dict, List, Mapping, Optional, TYPE_CHECKING, Union, overload + +from .. import _model_base +from .._model_base import rest_field + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + + +class ArmOperationStatusResourceProvisioningState(_model_base.Model): # pylint: disable=name-too-long + """Standard Azure Resource Manager operation status response. + + Readonly 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 status: The operation status. Required. Known values are: "Succeeded", "Failed", and + "Canceled". + :vartype status: str or ~azure.mgmt.deviceregistry.models.ResourceProvisioningState + :ivar name: The name of the operationStatus resource. + :vartype name: str + :ivar start_time: Operation start time. + :vartype start_time: ~datetime.datetime + :ivar end_time: Operation complete time. + :vartype end_time: ~datetime.datetime + :ivar percent_complete: The progress made toward completing the operation. + :vartype percent_complete: float + :ivar error: Errors that occurred if the operation ended with Canceled or Failed status. + :vartype error: ~azure.mgmt.deviceregistry.models.ErrorDetail + """ + + status: Union[str, "_models.ResourceProvisioningState"] = rest_field() + """The operation status. Required. Known values are: \"Succeeded\", \"Failed\", and \"Canceled\".""" + name: Optional[str] = rest_field(visibility=["read"]) + """The name of the operationStatus resource.""" + start_time: Optional[datetime.datetime] = rest_field(name="startTime", visibility=["read"], format="rfc3339") + """Operation start time.""" + end_time: Optional[datetime.datetime] = rest_field(name="endTime", visibility=["read"], format="rfc3339") + """Operation complete time.""" + percent_complete: Optional[float] = rest_field(name="percentComplete", visibility=["read"]) + """The progress made toward completing the operation.""" + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read"]) + """Errors that occurred if the operation ended with Canceled or Failed status.""" + + @overload + def __init__( + self, + *, + status: Union[str, "_models.ResourceProvisioningState"], + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class ArmResourceBase(_model_base.Model): + """Base class used for type definitions.""" + + +class ArmResource(ArmResourceBase): + """Common properties for all Azure Resource Manager resources. + + Readonly 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 resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + Required. + :vartype id: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". Required. + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.deviceregistry.models.SystemData + """ + + id: str = rest_field(visibility=["read"]) + """Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + Required.""" + type: str = rest_field(visibility=["read"]) + """The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or + \"Microsoft.Storage/storageAccounts\". Required.""" + system_data: Optional["_models.SystemData"] = rest_field(name="systemData", visibility=["read"]) + """Azure Resource Manager metadata containing createdBy and modifiedBy information.""" + + +class TrackedResourceBase(ArmResource): + """The resource model definition for an Azure Resource Manager tracked top level resource. + + Readonly 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 resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + Required. + :vartype id: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". Required. + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.deviceregistry.models.SystemData + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + location: str = rest_field(visibility=["read", "create"]) + """The geo-location where the resource lives. Required.""" + tags: Optional[Dict[str, str]] = rest_field() + """Resource tags.""" + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class Asset(TrackedResourceBase): + """Asset definition. + + Readonly 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 resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + Required. + :vartype id: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". Required. + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.deviceregistry.models.SystemData + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.deviceregistry.models.AssetProperties + :ivar extended_location: The extended location. Required. + :vartype extended_location: ~azure.mgmt.deviceregistry.models.ExtendedLocation + """ + + properties: Optional["_models.AssetProperties"] = rest_field(visibility=["read", "create"]) + """The resource-specific properties for this resource.""" + extended_location: "_models.ExtendedLocation" = rest_field(name="extendedLocation", visibility=["read", "create"]) + """The extended location. Required.""" + + @overload + def __init__( + self, + *, + location: str, + extended_location: "_models.ExtendedLocation", + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.AssetProperties"] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class AssetEndpointProfile(TrackedResourceBase): + """Asset Endpoint Profile definition. + + Readonly 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 resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + Required. + :vartype id: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". Required. + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.deviceregistry.models.SystemData + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.deviceregistry.models.AssetEndpointProfileProperties + :ivar extended_location: The extended location. Required. + :vartype extended_location: ~azure.mgmt.deviceregistry.models.ExtendedLocation + """ + + properties: Optional["_models.AssetEndpointProfileProperties"] = rest_field(visibility=["read", "create"]) + """The resource-specific properties for this resource.""" + extended_location: "_models.ExtendedLocation" = rest_field(name="extendedLocation", visibility=["read", "create"]) + """The extended location. Required.""" + + @overload + def __init__( + self, + *, + location: str, + extended_location: "_models.ExtendedLocation", + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.AssetEndpointProfileProperties"] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class AssetEndpointProfileListResult(_model_base.Model): + """The response of a AssetEndpointProfile list operation. + + All required parameters must be populated in order to send to server. + + :ivar value: The AssetEndpointProfile items on this page. Required. + :vartype value: list[~azure.mgmt.deviceregistry.models.AssetEndpointProfile] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + value: List["_models.AssetEndpointProfile"] = rest_field() + """The AssetEndpointProfile items on this page. Required.""" + next_link: Optional[str] = rest_field(name="nextLink") + """The link to the next page of items.""" + + @overload + def __init__( + self, + *, + value: List["_models.AssetEndpointProfile"], + next_link: Optional[str] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class AssetEndpointProfileProperties(_model_base.Model): + """Defines the Asset Endpoint Profile properties. + + Readonly 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 uuid: Globally unique, immutable, non-reusable id. + :vartype uuid: str + :ivar target_address: The local valid URI specifying the network address/DNS name of a + southbound device. The scheme part of the targetAddress URI specifies the type of the device. + 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). + :vartype additional_configuration: str + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Succeeded", + "Failed", "Canceled", and "Accepted". + :vartype provisioning_state: str or ~azure.mgmt.deviceregistry.models.ProvisioningState + """ + + uuid: Optional[str] = rest_field(visibility=["read"]) + """Globally unique, immutable, non-reusable id.""" + target_address: str = rest_field(name="targetAddress") + """The local valid URI specifying the network address/DNS name of a southbound device. The scheme + part of the targetAddress URI specifies the type of the device. The additionalConfiguration + field holds further connector type specific configuration. Required.""" + user_authentication: Optional["_models.UserAuthentication"] = rest_field(name="userAuthentication") + """Defines the client authentication mechanism to the server.""" + transport_authentication: Optional["_models.TransportAuthentication"] = rest_field(name="transportAuthentication") + """Defines the authentication mechanism for the southbound connector connecting to the shop + floor/OT device.""" + additional_configuration: Optional[str] = rest_field(name="additionalConfiguration") + """Contains connectivity type specific further configuration (e.g. OPC UA, Modbus, ONVIF).""" + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the resource. Known values are: \"Succeeded\", \"Failed\", \"Canceled\", + and \"Accepted\".""" + + @overload + def __init__( + self, + *, + target_address: str, + user_authentication: Optional["_models.UserAuthentication"] = None, + transport_authentication: Optional["_models.TransportAuthentication"] = None, + additional_configuration: Optional[str] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class AssetEndpointProfileUpdate(_model_base.Model): + """The type used for update operations of the AssetEndpointProfile. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar properties: + :vartype properties: ~azure.mgmt.deviceregistry.models.AssetEndpointProfileUpdateProperties + """ + + tags: Optional[Dict[str, str]] = rest_field() + """Resource tags.""" + properties: Optional["_models.AssetEndpointProfileUpdateProperties"] = rest_field() + + @overload + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.AssetEndpointProfileUpdateProperties"] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class AssetEndpointProfileUpdateProperties(_model_base.Model): + """The updatable properties of the AssetEndpointProfile. + + :ivar target_address: The local valid URI specifying the network address/DNS name of a + 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.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). + :vartype additional_configuration: str + """ + + target_address: Optional[str] = rest_field(name="targetAddress") + """The local valid URI specifying the network address/DNS name of a southbound device. The scheme + part of the targetAddress URI specifies the type of the device. The additionalConfiguration + field holds further connector type specific configuration.""" + user_authentication: Optional["_models.UserAuthentication"] = rest_field(name="userAuthentication") + """Defines the client authentication mechanism to the server.""" + transport_authentication: Optional["_models.TransportAuthentication"] = rest_field(name="transportAuthentication") + """Defines the authentication mechanism for the southbound connector connecting to the shop + floor/OT device.""" + additional_configuration: Optional[str] = rest_field(name="additionalConfiguration") + """Contains connectivity type specific further configuration (e.g. OPC UA, Modbus, ONVIF).""" + + @overload + def __init__( + self, + *, + target_address: Optional[str] = None, + user_authentication: Optional["_models.UserAuthentication"] = None, + transport_authentication: Optional["_models.TransportAuthentication"] = None, + additional_configuration: Optional[str] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class AssetListResult(_model_base.Model): + """The response of a Asset list operation. + + All required parameters must be populated in order to send to server. + + :ivar value: The Asset items on this page. Required. + :vartype value: list[~azure.mgmt.deviceregistry.models.Asset] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + value: List["_models.Asset"] = rest_field() + """The Asset items on this page. Required.""" + next_link: Optional[str] = rest_field(name="nextLink") + """The link to the next page of items.""" + + @overload + def __init__( + self, + *, + value: List["_models.Asset"], + next_link: Optional[str] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class AssetProperties(_model_base.Model): # pylint: disable=too-many-instance-attributes + """Defines the asset properties. + + Readonly 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 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. + :vartype external_asset_id: str + :ivar display_name: Human-readable display name. + :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 + 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 + :ivar version: An integer that is incremented each time the resource is modified. + :vartype version: int + :ivar manufacturer: Asset manufacturer name. + :vartype manufacturer: str + :ivar manufacturer_uri: Asset manufacturer URI. + :vartype manufacturer_uri: str + :ivar model: Asset model name. + :vartype model: str + :ivar product_code: Asset product code. + :vartype product_code: str + :ivar hardware_revision: Revision number of the hardware. + :vartype hardware_revision: str + :ivar software_revision: Revision number of the software. + :vartype software_revision: str + :ivar documentation_uri: Reference to the documentation. + :vartype documentation_uri: str + :ivar serial_number: Asset serial number. + :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. + :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. + :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". + :vartype provisioning_state: str or ~azure.mgmt.deviceregistry.models.ProvisioningState + """ + + uuid: Optional[str] = rest_field(visibility=["read"]) + """Globally unique, immutable, non-reusable id.""" + asset_type: Optional[str] = rest_field(name="assetType") + """Resource path to asset type (model) definition.""" + enabled: Optional[bool] = rest_field() + """Enabled/Disabled status of the asset.""" + external_asset_id: Optional[str] = rest_field(name="externalAssetId", visibility=["read", "create"]) + """Asset id provided by the customer.""" + display_name: Optional[str] = rest_field(name="displayName") + """Human-readable display name.""" + description: Optional[str] = rest_field() + """Human-readable description of the asset.""" + asset_endpoint_profile_uri: str = rest_field(name="assetEndpointProfileUri", visibility=["read", "create"]) + """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.""" + version: Optional[int] = rest_field(visibility=["read"]) + """An integer that is incremented each time the resource is modified.""" + manufacturer: Optional[str] = rest_field() + """Asset manufacturer name.""" + manufacturer_uri: Optional[str] = rest_field(name="manufacturerUri") + """Asset manufacturer URI.""" + model: Optional[str] = rest_field() + """Asset model name.""" + product_code: Optional[str] = rest_field(name="productCode") + """Asset product code.""" + hardware_revision: Optional[str] = rest_field(name="hardwareRevision") + """Revision number of the hardware.""" + software_revision: Optional[str] = rest_field(name="softwareRevision") + """Revision number of the software.""" + documentation_uri: Optional[str] = rest_field(name="documentationUri") + """Reference to the documentation.""" + serial_number: Optional[str] = rest_field(name="serialNumber") + """Asset serial number.""" + attributes: Optional[Dict[str, Any]] = rest_field() + """A set of key-value pairs that contain custom attributes set by the customer.""" + default_data_points_configuration: Optional[str] = rest_field(name="defaultDataPointsConfiguration") + """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.""" + default_events_configuration: Optional[str] = rest_field(name="defaultEventsConfiguration") + """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.""" + data_points: Optional[List["_models.DataPoint"]] = rest_field(name="dataPoints") + """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.""" + events: Optional[List["_models.Event"]] = rest_field() + """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.""" + status: Optional["_models.AssetStatus"] = rest_field(visibility=["read"]) + """Read only object to reflect changes that have occurred on the Edge. Similar to Kubernetes + status property for custom resources.""" + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the resource. Known values are: \"Succeeded\", \"Failed\", \"Canceled\", + and \"Accepted\".""" + + @overload + def __init__( + self, + *, + asset_endpoint_profile_uri: str, + asset_type: Optional[str] = None, + enabled: Optional[bool] = None, + external_asset_id: Optional[str] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + manufacturer: Optional[str] = None, + manufacturer_uri: Optional[str] = None, + model: Optional[str] = None, + product_code: Optional[str] = None, + hardware_revision: Optional[str] = None, + software_revision: Optional[str] = None, + documentation_uri: Optional[str] = None, + serial_number: Optional[str] = None, + attributes: Optional[Dict[str, Any]] = None, + default_data_points_configuration: Optional[str] = None, + default_events_configuration: Optional[str] = None, + data_points: Optional[List["_models.DataPoint"]] = None, + events: Optional[List["_models.Event"]] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class AssetStatus(_model_base.Model): + """Defines the asset status properties. + + :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 + 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. + :vartype version: int + """ + + errors: Optional[List["_models.AssetStatusError"]] = rest_field() + """Array object to transfer and persist errors that originate from the Edge.""" + version: Optional[int] = rest_field() + """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.""" + + @overload + def __init__( + self, + *, + errors: Optional[List["_models.AssetStatusError"]] = None, + version: Optional[int] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class AssetStatusError(_model_base.Model): + """Defines the asset status error properties. + + :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: “capability Id 'foo' does not exist”). + :vartype message: str + """ + + code: Optional[int] = rest_field() + """Error code for classification of errors (ex: 400, 404, 500, etc.).""" + message: Optional[str] = rest_field() + """Human readable helpful error message to provide additional context for error (ex: “capability + Id 'foo' does not exist”).""" + + @overload + def __init__( + self, + *, + code: Optional[int] = None, + message: Optional[str] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class AssetUpdate(_model_base.Model): + """The type used for update operations of the Asset. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar properties: + :vartype properties: ~azure.mgmt.deviceregistry.models.AssetUpdateProperties + """ + + tags: Optional[Dict[str, str]] = rest_field() + """Resource tags.""" + properties: Optional["_models.AssetUpdateProperties"] = rest_field() + + @overload + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.AssetUpdateProperties"] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class AssetUpdateProperties(_model_base.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. + :vartype display_name: str + :ivar description: Human-readable description of the asset. + :vartype description: str + :ivar manufacturer: Asset manufacturer name. + :vartype manufacturer: str + :ivar manufacturer_uri: Asset manufacturer URI. + :vartype manufacturer_uri: str + :ivar model: Asset model name. + :vartype model: str + :ivar product_code: Asset product code. + :vartype product_code: str + :ivar hardware_revision: Revision number of the hardware. + :vartype hardware_revision: str + :ivar software_revision: Revision number of the software. + :vartype software_revision: str + :ivar documentation_uri: Reference to the documentation. + :vartype documentation_uri: str + :ivar serial_number: Asset serial number. + :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. + :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. + :vartype events: list[~azure.mgmt.deviceregistry.models.Event] + """ + + asset_type: Optional[str] = rest_field(name="assetType") + """Resource path to asset type (model) definition.""" + enabled: Optional[bool] = rest_field() + """Enabled/Disabled status of the asset.""" + display_name: Optional[str] = rest_field(name="displayName") + """Human-readable display name.""" + description: Optional[str] = rest_field() + """Human-readable description of the asset.""" + manufacturer: Optional[str] = rest_field() + """Asset manufacturer name.""" + manufacturer_uri: Optional[str] = rest_field(name="manufacturerUri") + """Asset manufacturer URI.""" + model: Optional[str] = rest_field() + """Asset model name.""" + product_code: Optional[str] = rest_field(name="productCode") + """Asset product code.""" + hardware_revision: Optional[str] = rest_field(name="hardwareRevision") + """Revision number of the hardware.""" + software_revision: Optional[str] = rest_field(name="softwareRevision") + """Revision number of the software.""" + documentation_uri: Optional[str] = rest_field(name="documentationUri") + """Reference to the documentation.""" + serial_number: Optional[str] = rest_field(name="serialNumber") + """Asset serial number.""" + attributes: Optional[Dict[str, Any]] = rest_field() + """A set of key-value pairs that contain custom attributes set by the customer.""" + default_data_points_configuration: Optional[str] = rest_field(name="defaultDataPointsConfiguration") + """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.""" + default_events_configuration: Optional[str] = rest_field(name="defaultEventsConfiguration") + """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.""" + data_points: Optional[List["_models.DataPoint"]] = rest_field(name="dataPoints") + """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.""" + events: Optional[List["_models.Event"]] = rest_field() + """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.""" + + @overload + def __init__( + self, + *, + asset_type: Optional[str] = None, + enabled: Optional[bool] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + manufacturer: Optional[str] = None, + manufacturer_uri: Optional[str] = None, + model: Optional[str] = None, + product_code: Optional[str] = None, + hardware_revision: Optional[str] = None, + software_revision: Optional[str] = None, + documentation_uri: Optional[str] = None, + serial_number: Optional[str] = None, + attributes: Optional[Dict[str, Any]] = None, + default_data_points_configuration: Optional[str] = None, + default_events_configuration: Optional[str] = None, + data_points: Optional[List["_models.DataPoint"]] = None, + events: Optional[List["_models.Event"]] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class DataPoint(_model_base.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. + :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 observability_mode: An indication of how the data point should be mapped to + 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 + """ + + name: Optional[str] = rest_field() + """The name of the data point.""" + data_source: str = rest_field(name="dataSource") + """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.""" + capability_id: Optional[str] = rest_field(name="capabilityId") + """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.""" + observability_mode: Optional[Union[str, "_models.DataPointsObservabilityMode"]] = rest_field( + name="observabilityMode" + ) + """An indication of how the data point should be mapped to OpenTelemetry. Known values are: + \"none\", \"counter\", \"gauge\", \"histogram\", and \"log\".""" + data_point_configuration: Optional[str] = rest_field(name="dataPointConfiguration") + """Protocol-specific configuration for the data point. For OPC UA, this could include + configuration like, publishingInterval, samplingInterval, and queueSize.""" + + @overload + def __init__( + self, + *, + data_source: str, + name: Optional[str] = None, + capability_id: Optional[str] = None, + observability_mode: Optional[Union[str, "_models.DataPointsObservabilityMode"]] = None, + data_point_configuration: Optional[str] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class ErrorAdditionalInfo(_model_base.Model): + """The resource management error additional info. + + Readonly variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: any + """ + + type: Optional[str] = rest_field(visibility=["read"]) + """The additional info type.""" + info: Optional[Any] = rest_field(visibility=["read"]) + """The additional info.""" + + +class ErrorDetail(_model_base.Model): + """The error detail. + + Readonly variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.deviceregistry.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.deviceregistry.models.ErrorAdditionalInfo] + """ + + code: Optional[str] = rest_field(visibility=["read"]) + """The error code.""" + message: Optional[str] = rest_field(visibility=["read"]) + """The error message.""" + target: Optional[str] = rest_field(visibility=["read"]) + """The error target.""" + details: Optional[List["_models.ErrorDetail"]] = rest_field(visibility=["read"]) + """The error details.""" + additional_info: Optional[List["_models.ErrorAdditionalInfo"]] = rest_field( + name="additionalInfo", visibility=["read"] + ) + """The error additional info.""" + + +class ErrorResponse(_model_base.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. + + :ivar error: The error object. + :vartype error: ~azure.mgmt.deviceregistry.models.ErrorDetail + """ + + error: Optional["_models.ErrorDetail"] = rest_field() + """The error object.""" + + @overload + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class Event(_model_base.Model): + """Defines the event properties. + + All required parameters must be populated in order to send to server. + + :ivar name: The name of the event. + :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. + :vartype event_configuration: str + """ + + name: Optional[str] = rest_field() + """The name of the event.""" + event_notifier: str = rest_field(name="eventNotifier") + """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.""" + capability_id: Optional[str] = rest_field(name="capabilityId") + """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.""" + observability_mode: Optional[Union[str, "_models.EventsObservabilityMode"]] = rest_field(name="observabilityMode") + """An indication of how the event should be mapped to OpenTelemetry. Known values are: \"none\" + and \"log\".""" + event_configuration: Optional[str] = rest_field(name="eventConfiguration") + """Protocol-specific configuration for the event. For OPC UA, this could include configuration + like, publishingInterval, samplingInterval, and queueSize.""" + + @overload + def __init__( + self, + *, + event_notifier: str, + name: Optional[str] = None, + capability_id: Optional[str] = None, + observability_mode: Optional[Union[str, "_models.EventsObservabilityMode"]] = None, + event_configuration: Optional[str] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class ExtendedLocation(_model_base.Model): + """The extended location. + + All required parameters must be populated in order to send to server. + + :ivar type: The extended location type. Required. + :vartype type: str + :ivar name: The extended location name. Required. + :vartype name: str + """ + + type: str = rest_field() + """The extended location type. Required.""" + name: str = rest_field() + """The extended location name. Required.""" + + @overload + def __init__( + self, + *, + type: str, + name: str, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class Operation(_model_base.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Readonly variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for Azure Resource Manager/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.deviceregistry.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + and "user,system". + :vartype origin: str or ~azure.mgmt.deviceregistry.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. "Internal" + :vartype action_type: str or ~azure.mgmt.deviceregistry.models.ActionType + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + \"Microsoft.Compute/virtualMachines/write\", + \"Microsoft.Compute/virtualMachines/capture/action\".""" + is_data_action: Optional[bool] = rest_field(name="isDataAction", visibility=["read"]) + """Whether the operation applies to data-plane. This is \"true\" for data-plane operations and + \"false\" for Azure Resource Manager/control-plane operations.""" + display: Optional["_models.OperationDisplay"] = rest_field() + """Localized display information for this particular operation.""" + origin: Optional[Union[str, "_models.Origin"]] = rest_field(visibility=["read"]) + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is \"user,system\". Known values are: \"user\", \"system\", and + \"user,system\".""" + action_type: Optional[Union[str, "_models.ActionType"]] = rest_field(name="actionType") + """Enum. Indicates the action type. \"Internal\" refers to actions that are for internal only + APIs. \"Internal\"""" + + @overload + def __init__( + self, + *, + display: Optional["_models.OperationDisplay"] = None, + action_type: Optional[Union[str, "_models.ActionType"]] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class OperationDisplay(_model_base.Model): + """Localized display information for and operation. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str + """ + + provider: Optional[str] = rest_field() + """The localized friendly form of the resource provider name, e.g. \"Microsoft Monitoring + Insights\" or \"Microsoft Compute\".""" + resource: Optional[str] = rest_field() + """The localized friendly name of the resource type related to this operation. E.g. \"Virtual + Machines\" or \"Job Schedule Collections\".""" + operation: Optional[str] = rest_field() + """The concise, localized friendly name for the operation; suitable for dropdowns. E.g. \"Create + or Update Virtual Machine\", \"Restart Virtual Machine\".""" + description: Optional[str] = rest_field() + """The short, localized friendly description of the operation; suitable for tool tips and detailed + views.""" + + @overload + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class OperationStatusResult(_model_base.Model): + """The current status of an async operation. + + 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 name: Name of the async operation. + :vartype name: str + :ivar status: Operation status. Required. + :vartype status: str + :ivar percent_complete: Percent of the operation that is complete. + :vartype percent_complete: int + :ivar start_time: The start time of the operation. + :vartype start_time: ~datetime.datetime + :ivar end_time: The end time of the operation. + :vartype end_time: ~datetime.datetime + :ivar operations: The operations list. Required. + :vartype operations: list[~azure.mgmt.deviceregistry.models.OperationStatusResult] + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.deviceregistry.models.ErrorDetail + """ + + id: Optional[str] = rest_field() + """Fully qualified ID for the async operation.""" + name: Optional[str] = rest_field() + """Name of the async operation.""" + status: str = rest_field() + """Operation status. Required.""" + percent_complete: Optional[int] = rest_field(name="percentComplete") + """Percent of the operation that is complete.""" + start_time: Optional[datetime.datetime] = rest_field(name="startTime", format="rfc3339") + """The start time of the operation.""" + end_time: Optional[datetime.datetime] = rest_field(name="endTime", format="rfc3339") + """The end time of the operation.""" + operations: List["_models.OperationStatusResult"] = rest_field() + """The operations list. Required.""" + error: Optional["_models.ErrorDetail"] = rest_field() + """If present, details of the operation error.""" + + @overload + def __init__( + self, + *, + status: str, + operations: List["_models.OperationStatusResult"], + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + percent_complete: Optional[int] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + error: Optional["_models.ErrorDetail"] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class OwnCertificate(_model_base.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 + """ + + cert_thumbprint: Optional[str] = rest_field(name="certThumbprint") + """Certificate thumbprint.""" + cert_secret_reference: Optional[str] = rest_field(name="certSecretReference") + """Secret Reference name (cert and private key).""" + cert_password_reference: Optional[str] = rest_field(name="certPasswordReference") + """Secret Reference Name (Pfx or Pem password).""" + + @overload + def __init__( + self, + *, + cert_thumbprint: Optional[str] = None, + cert_secret_reference: Optional[str] = None, + cert_password_reference: Optional[str] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class PagedOperation(_model_base.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link + to get the next set of results. + + All required parameters must be populated in order to send to server. + + :ivar value: The Operation items on this page. Required. + :vartype value: list[~azure.mgmt.deviceregistry.models.Operation] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + value: List["_models.Operation"] = rest_field() + """The Operation items on this page. Required.""" + next_link: Optional[str] = rest_field(name="nextLink") + """The link to the next page of items.""" + + @overload + def __init__( + self, + *, + value: List["_models.Operation"], + next_link: Optional[str] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class SystemData(_model_base.Model): + """Metadata pertaining to creation and last modification of the resource. + + Readonly variables are only populated by the server, and will be ignored when sending a request. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.deviceregistry.models.CreatedByType + :ivar created_at: The type of identity that created the resource. + :vartype created_at: ~datetime.date + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.deviceregistry.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.date + """ + + created_by: Optional[str] = rest_field(name="createdBy", visibility=["read"]) + """The identity that created the resource.""" + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="createdByType", visibility=["read"] + ) + """The type of identity that created the resource. Known values are: \"User\", \"Application\", + \"ManagedIdentity\", and \"Key\".""" + created_at: Optional[datetime.date] = rest_field(name="createdAt", visibility=["read"]) + """The type of identity that created the resource.""" + last_modified_by: Optional[str] = rest_field(name="lastModifiedBy", visibility=["read"]) + """The identity that last modified the resource.""" + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="lastModifiedByType", visibility=["read"] + ) + """The type of identity that last modified the resource. Known values are: \"User\", + \"Application\", \"ManagedIdentity\", and \"Key\".""" + last_modified_at: Optional[datetime.date] = rest_field(name="lastModifiedAt", visibility=["read"]) + """The timestamp of resource last modification (UTC).""" + + +class TransportAuthentication(_model_base.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] + """ + + own_certificates: List["_models.OwnCertificate"] = rest_field(name="ownCertificates") + """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.""" + + @overload + def __init__( + self, + *, + own_certificates: List["_models.OwnCertificate"], + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class UserAuthentication(_model_base.Model): + """Definition of the client authentication mechanism to the server. + + 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 + """ + + mode: Union[str, "_models.UserAuthenticationMode"] = rest_field() + """Defines the mode to authenticate the user of the client at the server. Required. Known values + are: \"Anonymous\", \"Certificate\", and \"UsernamePassword\".""" + username_password_credentials: Optional["_models.UsernamePasswordCredentials"] = rest_field( + name="usernamePasswordCredentials" + ) + """Defines the username and password references when UsernamePassword user authentication mode is + selected.""" + x509_credentials: Optional["_models.X509Credentials"] = rest_field(name="x509Credentials") + """Defines the certificate reference when Certificate user authentication mode is selected.""" + + @overload + def __init__( + self, + *, + mode: Union[str, "_models.UserAuthenticationMode"], + username_password_credentials: Optional["_models.UsernamePasswordCredentials"] = None, + x509_credentials: Optional["_models.X509Credentials"] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class UsernamePasswordCredentials(_model_base.Model): + """The credentials for authentication mode UsernamePassword. + + 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 + """ + + username_reference: str = rest_field(name="usernameReference") + """A reference to secret containing the username. Required.""" + password_reference: str = rest_field(name="passwordReference") + """A reference to secret containing the password. Required.""" + + @overload + def __init__( + self, + *, + username_reference: str, + password_reference: str, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class X509Credentials(_model_base.Model): + """The x509 certificate for authentication mode Certificate. + + 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 + """ + + certificate_reference: str = rest_field(name="certificateReference") + """A reference to secret containing the certificate and private key (e.g. stored as .der/.pem or + .der/.pfx). Required.""" + + @overload + def __init__( + self, + *, + certificate_reference: str, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) 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..285d6449a1a6 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 @@ -2,14 +2,14 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._operations import Operations -from ._asset_endpoint_profiles_operations import AssetEndpointProfilesOperations -from ._assets_operations import AssetsOperations -from ._operation_status_operations import OperationStatusOperations +from ._operations import OperationStatusOperations +from ._operations import AssetsOperations +from ._operations import AssetEndpointProfilesOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -17,9 +17,9 @@ __all__ = [ "Operations", - "AssetEndpointProfilesOperations", - "AssetsOperations", "OperationStatusOperations", + "AssetsOperations", + "AssetEndpointProfilesOperations", ] __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/operations/_operations.py b/sdk/deviceregistry/azure-mgmt-deviceregistry/azure/mgmt/deviceregistry/operations/_operations.py index 27ad5684f4f5..69f4e68aa621 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 @@ -3,10 +3,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python 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 +from io import IOBase +import json +import sys +from typing import Any, Callable, Dict, IO, Iterable, List, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -19,24 +22,30 @@ ) 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.polling import LROPoller, NoPolling, PollingMethod +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 azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._model_base import SdkJSONEncoder, _deserialize 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]] +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request(**kwargs: Any) -> HttpRequest: +def build_operations_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -44,7 +53,379 @@ def build_list_request(**kwargs: Any) -> HttpRequest: accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.DeviceRegistry/operations") + _url = "/providers/Microsoft.DeviceRegistry/operations" + + # 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_operation_status_get_request( + location: str, operation_id: 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", "2023-11-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/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"), + "location": _SERIALIZER.url("location", location, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_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_assets_get_request( + resource_group_name: str, asset_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", "2023-11-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/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"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "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_assets_create_or_replace_request( + resource_group_name: str, asset_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/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"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_assets_update_request( + resource_group_name: str, asset_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/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"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_assets_delete_request( + resource_group_name: str, asset_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", "2023-11-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/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"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "assetName": _SERIALIZER.url("asset_name", asset_name, "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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_assets_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_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", "2023-11-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = ( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceRegistry/assets" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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_assets_list_by_subscription_request( # pylint: disable=name-too-long + 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", "2023-11-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DeviceRegistry/assets" + 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_asset_endpoint_profiles_get_request( # pylint: disable=name-too-long + resource_group_name: str, asset_endpoint_profile_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", "2023-11-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/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"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "assetEndpointProfileName": _SERIALIZER.url("asset_endpoint_profile_name", asset_endpoint_profile_name, "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_asset_endpoint_profiles_create_or_replace_request( # pylint: disable=name-too-long + resource_group_name: str, asset_endpoint_profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/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"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "assetEndpointProfileName": _SERIALIZER.url("asset_endpoint_profile_name", asset_endpoint_profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_asset_endpoint_profiles_update_request( # pylint: disable=name-too-long + resource_group_name: str, asset_endpoint_profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/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"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "assetEndpointProfileName": _SERIALIZER.url("asset_endpoint_profile_name", asset_endpoint_profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_asset_endpoint_profiles_delete_request( # pylint: disable=name-too-long + resource_group_name: str, asset_endpoint_profile_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", "2023-11-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/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"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "assetEndpointProfileName": _SERIALIZER.url("asset_endpoint_profile_name", asset_endpoint_profile_name, "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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_asset_endpoint_profiles_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_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", "2023-11-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceRegistry/assetEndpointProfiles" # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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_asset_endpoint_profiles_list_by_subscription_request( # pylint: disable=name-too-long + 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", "2023-11-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DeviceRegistry/assetEndpointProfiles" + 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") @@ -65,8 +446,6 @@ class Operations: :attr:`operations` 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") @@ -76,19 +455,50 @@ def __init__(self, *args, **kwargs): @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: + # pylint: disable=line-too-long """List the operations for the provider. - :return: An iterator like instance of either Operation or the result of cls(response) + :return: An iterator like instance of Operation :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.deviceregistry.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "actionType": "str", # Optional. Enum. Indicates the action type. "Internal" + refers to actions that are for internal only APIs. "Internal" + "display": { + "description": "str", # Optional. The short, localized friendly + description of the operation; suitable for tool tips and detailed views. + "operation": "str", # Optional. The concise, localized friendly name + for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + Machine", "Restart Virtual Machine". + "provider": "str", # Optional. The localized friendly form of the + resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + Compute". + "resource": "str" # Optional. The localized friendly name of the + resource type related to this operation. E.g. "Virtual Machines" or "Job + Schedule Collections". + }, + "isDataAction": bool, # Optional. Whether the operation applies to + data-plane. This is "true" for data-plane operations and "false" for Azure + Resource Manager/control-plane operations. + "name": "str", # Optional. The name of the operation, as per Resource-Based + Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + "Microsoft.Compute/virtualMachines/capture/action". + "origin": "str" # Optional. The intended executor of the operation; as in + Resource Based Access Control (RBAC) and audit logs UX. Default value is + "user,system". Known values are: "user", "system", and "user,system". + } """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -99,12 +509,11 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - _request = build_list_request( - api_version=api_version, + _request = build_operations_list_request( + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -120,17 +529,4701 @@ 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 + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Operation], deserialized["value"]) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.deviceregistry.DeviceRegistryMgmtClient`'s + :attr:`operation_status` attribute. + """ + + 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 get(self, location: str, operation_id: str, **kwargs: Any) -> _models.OperationStatusResult: + """Returns the current status of an async operation. + + :param location: The location name. Required. + :type location: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :return: OperationStatusResult. The OperationStatusResult is compatible with MutableMapping + :rtype: ~azure.mgmt.deviceregistry.models.OperationStatusResult + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "operations": [ + ... + ], + "status": "str", # Operation status. Required. + "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. + "error": { + "additionalInfo": [ + { + "info": {}, # Optional. The additional info. + "type": "str" # Optional. The additional info type. + } + ], + "code": "str", # Optional. The error code. + "details": [ + ... + ], + "message": "str", # Optional. The error message. + "target": "str" # Optional. The error target. + }, + "id": "str", # Optional. Fully qualified ID for the async operation. + "name": "str", # Optional. Name of the async operation. + "percentComplete": 0, # Optional. Percent of the operation that is complete. + "startTime": "2020-02-20 00:00:00" # Optional. The start time of the + operation. + } + """ + 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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + _request = build_operation_status_get_request( + location=location, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = kwargs.pop("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]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.OperationStatusResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class AssetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.deviceregistry.DeviceRegistryMgmtClient`'s + :attr:`assets` attribute. + """ + + 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 get(self, resource_group_name: str, asset_name: str, **kwargs: Any) -> _models.Asset: + # pylint: disable=line-too-long + """Get a Asset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_name: Asset name parameter. Required. + :type asset_name: str + :return: Asset. The Asset is compatible with MutableMapping + :rtype: ~azure.mgmt.deviceregistry.models.Asset + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + 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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Asset] = kwargs.pop("cls", None) + + _request = build_assets_get_request( + resource_group_name=resource_group_name, + asset_name=asset_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = kwargs.pop("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]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Asset, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_replace_initial( + self, resource_group_name: str, asset_name: str, resource: Union[_models.Asset, JSON, IO[bytes]], **kwargs: Any + ) -> JSON: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_assets_create_or_replace_request( + resource_group_name=resource_group_name, + asset_name=asset_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + 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, 201]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = _deserialize(JSON, response.json()) + + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(JSON, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_replace( + self, + resource_group_name: str, + asset_name: str, + resource: _models.Asset, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Asset]: + # pylint: disable=line-too-long + """Create a Asset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_name: Asset name parameter. Required. + :type asset_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.deviceregistry.models.Asset + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Asset. The Asset is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.deviceregistry.models.Asset] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + resource = { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + + # response body for status code(s): 200, 201 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @overload + def begin_create_or_replace( + self, + resource_group_name: str, + asset_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Asset]: + # pylint: disable=line-too-long + """Create a Asset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_name: Asset name parameter. Required. + :type asset_name: str + :param resource: Resource create parameters. Required. + :type resource: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Asset. The Asset is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.deviceregistry.models.Asset] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 201 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @overload + def begin_create_or_replace( + self, + resource_group_name: str, + asset_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Asset]: + # pylint: disable=line-too-long + """Create a Asset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_name: Asset name parameter. Required. + :type asset_name: str + :param resource: Resource create parameters. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Asset. The Asset is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.deviceregistry.models.Asset] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 201 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @distributed_trace + def begin_create_or_replace( + self, resource_group_name: str, asset_name: str, resource: Union[_models.Asset, JSON, IO[bytes]], **kwargs: Any + ) -> LROPoller[_models.Asset]: + # pylint: disable=line-too-long + """Create a Asset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_name: Asset name parameter. Required. + :type asset_name: str + :param resource: Resource create parameters. Is one of the following types: Asset, JSON, + IO[bytes] Required. + :type resource: ~azure.mgmt.deviceregistry.models.Asset or JSON or IO[bytes] + :return: An instance of LROPoller that returns Asset. The Asset is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.deviceregistry.models.Asset] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + resource = { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + + # response body for status code(s): 200, 201 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Asset] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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._create_or_replace_initial( + resource_group_name=resource_group_name, + asset_name=asset_name, + resource=resource, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Asset, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Asset].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Asset]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + asset_name: str, + properties: Union[_models.AssetUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> Optional[JSON]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_assets_update_request( + resource_group_name=resource_group_name, + asset_name=asset_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + 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, 202]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = _deserialize(JSON, response.json()) + + 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")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + asset_name: str, + properties: _models.AssetUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Asset]: + # pylint: disable=line-too-long + """Update a Asset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_name: Asset name parameter. Required. + :type asset_name: str + :param properties: The resource properties to be updated. Required. + :type properties: ~azure.mgmt.deviceregistry.models.AssetUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Asset. The Asset is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.deviceregistry.models.Asset] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + properties = { + "properties": { + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str" # Optional. Revision number of the + software. + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + + # response body for status code(s): 200, 202 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @overload + def begin_update( + self, + resource_group_name: str, + asset_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Asset]: + # pylint: disable=line-too-long + """Update a Asset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_name: Asset name parameter. Required. + :type asset_name: str + :param properties: The resource properties to be updated. Required. + :type properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Asset. The Asset is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.deviceregistry.models.Asset] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 202 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @overload + def begin_update( + self, + resource_group_name: str, + asset_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Asset]: + # pylint: disable=line-too-long + """Update a Asset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_name: Asset name parameter. Required. + :type asset_name: str + :param properties: The resource properties to be updated. Required. + :type properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Asset. The Asset is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.deviceregistry.models.Asset] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 202 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + asset_name: str, + properties: Union[_models.AssetUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Asset]: + # pylint: disable=line-too-long + """Update a Asset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_name: Asset name parameter. Required. + :type asset_name: str + :param properties: The resource properties to be updated. Is one of the following types: + AssetUpdate, JSON, IO[bytes] Required. + :type properties: ~azure.mgmt.deviceregistry.models.AssetUpdate or JSON or IO[bytes] + :return: An instance of LROPoller that returns Asset. The Asset is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.deviceregistry.models.Asset] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + properties = { + "properties": { + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str" # Optional. Revision number of the + software. + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + + # response body for status code(s): 200, 202 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Asset] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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._update_initial( + resource_group_name=resource_group_name, + asset_name=asset_name, + properties=properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Asset, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Asset].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Asset]( + 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: 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 = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_assets_delete_request( + resource_group_name=resource_group_name, + asset_name=asset_name, + subscription_id=self._config.subscription_id, + api_version=self._config.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 [202, 204]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + 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")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, asset_name: str, **kwargs: Any) -> LROPoller[None]: + """Delete a Asset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_name: Asset name parameter. Required. + :type asset_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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 + resource_group_name=resource_group_name, + asset_name=asset_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Asset"]: + # pylint: disable=line-too-long + """List Asset resources by resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of Asset + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.deviceregistry.models.Asset] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Asset]] = 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_assets_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.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) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Asset], deserialized["value"]) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Asset"]: + # pylint: disable=line-too-long + """List Asset resources by subscription ID. + + :return: An iterator like instance of Asset + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.deviceregistry.models.Asset] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "assetEndpointProfileUri": "str", # 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. + "assetType": "str", # Optional. Resource path to asset type (model) + definition. + "attributes": { + "str": {} # Optional. A set of key-value pairs that contain + custom attributes set by the customer. + }, + "dataPoints": [ + { + "dataSource": "str", # 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. + "capabilityId": "str", # Optional. 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. + "dataPointConfiguration": "str", # Optional. + Protocol-specific configuration for the data point. For OPC UA, this + could include configuration like, publishingInterval, + samplingInterval, and queueSize. + "name": "str", # Optional. The name of the data + point. + "observabilityMode": "str" # Optional. An indication + of how the data point should be mapped to OpenTelemetry. Known values + are: "none", "counter", "gauge", "histogram", and "log". + } + ], + "defaultDataPointsConfiguration": "str", # Optional. + 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. + "defaultEventsConfiguration": "str", # Optional. 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. + "description": "str", # Optional. Human-readable description of the + asset. + "displayName": "str", # Optional. Human-readable display name. + "documentationUri": "str", # Optional. Reference to the + documentation. + "enabled": bool, # Optional. Enabled/Disabled status of the asset. + "events": [ + { + "eventNotifier": "str", # 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. + "capabilityId": "str", # Optional. 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. + "eventConfiguration": "str", # Optional. + Protocol-specific configuration for the event. For OPC UA, this could + include configuration like, publishingInterval, samplingInterval, and + queueSize. + "name": "str", # Optional. The name of the event. + "observabilityMode": "str" # Optional. An indication + of how the event should be mapped to OpenTelemetry. Known values are: + "none" and "log". + } + ], + "externalAssetId": "str", # Optional. Asset id provided by the + customer. + "hardwareRevision": "str", # Optional. Revision number of the + hardware. + "manufacturer": "str", # Optional. Asset manufacturer name. + "manufacturerUri": "str", # Optional. Asset manufacturer URI. + "model": "str", # Optional. Asset model name. + "productCode": "str", # Optional. Asset product code. + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "serialNumber": "str", # Optional. Asset serial number. + "softwareRevision": "str", # Optional. Revision number of the + software. + "status": { + "errors": [ + { + "code": 0, # Optional. Error code for + classification of errors (ex: 400, 404, 500, etc.). + "message": "str" # Optional. Human readable + helpful error message to provide additional context for error + (ex: "u201ccapability Id 'foo' does not exist"u201d). + } + ], + "version": 0 # Optional. 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. + }, + "uuid": "str", # Optional. Globally unique, immutable, non-reusable + id. + "version": 0 # Optional. An integer that is incremented each time + the resource is modified. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Asset]] = 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_assets_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.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) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Asset], deserialized["value"]) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class AssetEndpointProfilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.deviceregistry.DeviceRegistryMgmtClient`'s + :attr:`asset_endpoint_profiles` attribute. + """ + + 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 get( + self, resource_group_name: str, asset_endpoint_profile_name: str, **kwargs: Any + ) -> _models.AssetEndpointProfile: + # pylint: disable=line-too-long + """Get a AssetEndpointProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_endpoint_profile_name: Asset Endpoint Profile name parameter. Required. + :type asset_endpoint_profile_name: str + :return: AssetEndpointProfile. The AssetEndpointProfile is compatible with MutableMapping + :rtype: ~azure.mgmt.deviceregistry.models.AssetEndpointProfile + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + 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 = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AssetEndpointProfile] = kwargs.pop("cls", None) + + _request = build_asset_endpoint_profiles_get_request( + resource_group_name=resource_group_name, + asset_endpoint_profile_name=asset_endpoint_profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = kwargs.pop("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]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.AssetEndpointProfile, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_replace_initial( + self, + resource_group_name: str, + asset_endpoint_profile_name: str, + resource: Union[_models.AssetEndpointProfile, JSON, IO[bytes]], + **kwargs: Any + ) -> JSON: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_asset_endpoint_profiles_create_or_replace_request( + resource_group_name=resource_group_name, + asset_endpoint_profile_name=asset_endpoint_profile_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + 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, 201]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = _deserialize(JSON, response.json()) + + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(JSON, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_replace( + self, + resource_group_name: str, + asset_endpoint_profile_name: str, + resource: _models.AssetEndpointProfile, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AssetEndpointProfile]: + # pylint: disable=line-too-long + """Create a AssetEndpointProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_endpoint_profile_name: Asset Endpoint Profile name parameter. Required. + :type asset_endpoint_profile_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.deviceregistry.models.AssetEndpointProfile + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AssetEndpointProfile. The AssetEndpointProfile + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.deviceregistry.models.AssetEndpointProfile] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + resource = { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + + # response body for status code(s): 200, 201 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @overload + def begin_create_or_replace( + self, + resource_group_name: str, + asset_endpoint_profile_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AssetEndpointProfile]: + # pylint: disable=line-too-long + """Create a AssetEndpointProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_endpoint_profile_name: Asset Endpoint Profile name parameter. Required. + :type asset_endpoint_profile_name: str + :param resource: Resource create parameters. Required. + :type resource: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AssetEndpointProfile. The AssetEndpointProfile + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.deviceregistry.models.AssetEndpointProfile] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 201 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @overload + def begin_create_or_replace( + self, + resource_group_name: str, + asset_endpoint_profile_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AssetEndpointProfile]: + # pylint: disable=line-too-long + """Create a AssetEndpointProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_endpoint_profile_name: Asset Endpoint Profile name parameter. Required. + :type asset_endpoint_profile_name: str + :param resource: Resource create parameters. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AssetEndpointProfile. The AssetEndpointProfile + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.deviceregistry.models.AssetEndpointProfile] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 201 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @distributed_trace + def begin_create_or_replace( + self, + resource_group_name: str, + asset_endpoint_profile_name: str, + resource: Union[_models.AssetEndpointProfile, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AssetEndpointProfile]: + # pylint: disable=line-too-long + """Create a AssetEndpointProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_endpoint_profile_name: Asset Endpoint Profile name parameter. Required. + :type asset_endpoint_profile_name: str + :param resource: Resource create parameters. Is one of the following types: + AssetEndpointProfile, JSON, IO[bytes] Required. + :type resource: ~azure.mgmt.deviceregistry.models.AssetEndpointProfile or JSON or IO[bytes] + :return: An instance of LROPoller that returns AssetEndpointProfile. The AssetEndpointProfile + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.deviceregistry.models.AssetEndpointProfile] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + resource = { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + + # response body for status code(s): 200, 201 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AssetEndpointProfile] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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._create_or_replace_initial( + resource_group_name=resource_group_name, + asset_endpoint_profile_name=asset_endpoint_profile_name, + resource=resource, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AssetEndpointProfile, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.AssetEndpointProfile].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AssetEndpointProfile]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + asset_endpoint_profile_name: str, + properties: Union[_models.AssetEndpointProfileUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> Optional[JSON]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_asset_endpoint_profiles_update_request( + resource_group_name=resource_group_name, + asset_endpoint_profile_name=asset_endpoint_profile_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + 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, 202]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = _deserialize(JSON, response.json()) + + 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")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + asset_endpoint_profile_name: str, + properties: _models.AssetEndpointProfileUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AssetEndpointProfile]: + # pylint: disable=line-too-long + """Update a AssetEndpointProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_endpoint_profile_name: Asset Endpoint Profile name parameter. Required. + :type asset_endpoint_profile_name: str + :param properties: The resource properties to be updated. Required. + :type properties: ~azure.mgmt.deviceregistry.models.AssetEndpointProfileUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AssetEndpointProfile. The AssetEndpointProfile + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.deviceregistry.models.AssetEndpointProfile] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + properties = { + "properties": { + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "targetAddress": "str", # Optional. The local valid URI specifying + the network address/DNS name of a southbound device. The scheme part of the + targetAddress URI specifies the type of the device. The + additionalConfiguration field holds further connector type specific + configuration. + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + } + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + + # response body for status code(s): 200, 202 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @overload + def begin_update( + self, + resource_group_name: str, + asset_endpoint_profile_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AssetEndpointProfile]: + # pylint: disable=line-too-long + """Update a AssetEndpointProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_endpoint_profile_name: Asset Endpoint Profile name parameter. Required. + :type asset_endpoint_profile_name: str + :param properties: The resource properties to be updated. Required. + :type properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AssetEndpointProfile. The AssetEndpointProfile + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.deviceregistry.models.AssetEndpointProfile] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 202 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @overload + def begin_update( + self, + resource_group_name: str, + asset_endpoint_profile_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AssetEndpointProfile]: + # pylint: disable=line-too-long + """Update a AssetEndpointProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_endpoint_profile_name: Asset Endpoint Profile name parameter. Required. + :type asset_endpoint_profile_name: str + :param properties: The resource properties to be updated. Required. + :type properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AssetEndpointProfile. The AssetEndpointProfile + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.deviceregistry.models.AssetEndpointProfile] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 202 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + asset_endpoint_profile_name: str, + properties: Union[_models.AssetEndpointProfileUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AssetEndpointProfile]: + # pylint: disable=line-too-long + """Update a AssetEndpointProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_endpoint_profile_name: Asset Endpoint Profile name parameter. Required. + :type asset_endpoint_profile_name: str + :param properties: The resource properties to be updated. Is one of the following types: + AssetEndpointProfileUpdate, JSON, IO[bytes] Required. + :type properties: ~azure.mgmt.deviceregistry.models.AssetEndpointProfileUpdate or JSON or + IO[bytes] + :return: An instance of LROPoller that returns AssetEndpointProfile. The AssetEndpointProfile + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.deviceregistry.models.AssetEndpointProfile] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + properties = { + "properties": { + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "targetAddress": "str", # Optional. The local valid URI specifying + the network address/DNS name of a southbound device. The scheme part of the + targetAddress URI specifies the type of the device. The + additionalConfiguration field holds further connector type specific + configuration. + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + } + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + + # response body for status code(s): 200, 202 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AssetEndpointProfile] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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._update_initial( + resource_group_name=resource_group_name, + asset_endpoint_profile_name=asset_endpoint_profile_name, + properties=properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AssetEndpointProfile, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.AssetEndpointProfile].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AssetEndpointProfile]( + 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_endpoint_profile_name: str, **kwargs: Any + ) -> None: + 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 = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_asset_endpoint_profiles_delete_request( + resource_group_name=resource_group_name, + asset_endpoint_profile_name=asset_endpoint_profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.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 [202, 204]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + 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")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, asset_endpoint_profile_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete a AssetEndpointProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param asset_endpoint_profile_name: Asset Endpoint Profile name parameter. Required. + :type asset_endpoint_profile_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + 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 + resource_group_name=resource_group_name, + asset_endpoint_profile_name=asset_endpoint_profile_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.AssetEndpointProfile"]: + # pylint: disable=line-too-long + """List AssetEndpointProfile resources by resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of AssetEndpointProfile + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.deviceregistry.models.AssetEndpointProfile] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AssetEndpointProfile]] = 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_asset_endpoint_profiles_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.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) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.AssetEndpointProfile], deserialized["value"]) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AssetEndpointProfile"]: + # pylint: disable=line-too-long + """List AssetEndpointProfile resources by subscription ID. + + :return: An iterator like instance of AssetEndpointProfile + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.deviceregistry.models.AssetEndpointProfile] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "extendedLocation": { + "name": "str", # The extended location name. Required. + "type": "str" # The extended location type. Required. + }, + "id": "str", # Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + Required. + "location": "str", # The geo-location where the resource lives. Required. + "type": "str", # The type of the resource. E.g. + "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + Required. + "properties": { + "targetAddress": "str", # The local valid URI specifying the network + address/DNS name of a southbound device. The scheme part of the targetAddress + URI specifies the type of the device. The additionalConfiguration field holds + further connector type specific configuration. Required. + "additionalConfiguration": "str", # Optional. Contains connectivity + type specific further configuration (e.g. OPC UA, Modbus, ONVIF). + "provisioningState": "str", # Optional. Provisioning state of the + resource. Known values are: "Succeeded", "Failed", "Canceled", and + "Accepted". + "transportAuthentication": { + "ownCertificates": [ + { + "certPasswordReference": "str", # Optional. + Secret Reference Name (Pfx or Pem password). + "certSecretReference": "str", # Optional. + Secret Reference name (cert and private key). + "certThumbprint": "str" # Optional. + Certificate thumbprint. + } + ] + }, + "userAuthentication": { + "mode": "str", # Defines the mode to authenticate the user + of the client at the server. Required. Known values are: "Anonymous", + "Certificate", and "UsernamePassword". + "usernamePasswordCredentials": { + "passwordReference": "str", # A reference to secret + containing the password. Required. + "usernameReference": "str" # A reference to secret + containing the username. Required. + }, + "x509Credentials": { + "certificateReference": "str" # A reference to + secret containing the certificate and private key (e.g. stored as + .der/.pem or .der/.pfx). Required. + } + }, + "uuid": "str" # Optional. Globally unique, immutable, non-reusable + id. + }, + "systemData": { + "createdAt": "2020-02-20", # Optional. The type of identity that + created the resource. + "createdBy": "str", # Optional. The identity that created the + resource. + "createdByType": "str", # Optional. The type of identity that + created the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + "lastModifiedAt": "2020-02-20", # Optional. The timestamp of + resource last modification (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified + the resource. + "lastModifiedByType": "str" # Optional. The type of identity that + last modified the resource. Known values are: "User", "Application", + "ManagedIdentity", and "Key". + }, + "tags": { + "str": "str" # Optional. Resource tags. + } + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AssetEndpointProfile]] = 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_asset_endpoint_profiles_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.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) + return _request def extract_data(pipeline_response): - deserialized = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.AssetEndpointProfile], deserialized["value"]) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -142,8 +5235,10 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/deviceregistry/azure-mgmt-deviceregistry/tsp-location.yaml b/sdk/deviceregistry/azure-mgmt-deviceregistry/tsp-location.yaml new file mode 100644 index 000000000000..2e8b79c1ae66 --- /dev/null +++ b/sdk/deviceregistry/azure-mgmt-deviceregistry/tsp-location.yaml @@ -0,0 +1,5 @@ +repo: test-repo-billy/azure-rest-api-specs +commit: 62e5ee267a4e0145c098aa0f1cb56e1d71953243 +directory: specification/deviceregistry/DeviceRegistry.Management +additionalDirectories: [] +