diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/_meta.json b/sdk/hybridcompute/azure-mgmt-hybridcompute/_meta.json index b7d1fb8d7d36..bce125f2eebf 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/_meta.json +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/_meta.json @@ -1,11 +1,11 @@ { - "commit": "270d3cd664cca3ddc8511f92d3851a715e2c61db", + "commit": "fd24ab8b273cde9cd1f608c6ac69fd352679f3e0", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.9.7", "use": [ - "@autorest/python@6.2.16", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.7.1", + "@autorest/modelerfour@4.26.2" ], - "autorest_command": "autorest specification/hybridcompute/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 --tag=package-2022-03 --use=@autorest/python@6.2.16 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/hybridcompute/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", "readme": "specification/hybridcompute/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/_configuration.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/_configuration.py index fde6c33ae9a6..3c2f2ce7a57d 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/_configuration.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -35,14 +29,14 @@ class HybridComputeManagementClientConfiguration(Configuration): # pylint: disa :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 "2022-03-10". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-10-03-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(HybridComputeManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", "2022-03-10") + api_version: str = kwargs.pop("api_version", "2023-10-03-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/_hybrid_compute_management_client.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/_hybrid_compute_management_client.py index 8a0077896e44..3f4cb427a5b6 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/_hybrid_compute_management_client.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/_hybrid_compute_management_client.py @@ -16,9 +16,16 @@ from ._configuration import HybridComputeManagementClientConfiguration from ._serialization import Deserializer, Serializer from .operations import ( + AgentVersionOperations, + ExtensionMetadataOperations, HybridComputeManagementClientOperationsMixin, + HybridIdentityMetadataOperations, + LicenseProfilesOperations, + LicensesOperations, MachineExtensionsOperations, + MachineRunCommandsOperations, MachinesOperations, + NetworkProfileOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, @@ -35,12 +42,27 @@ class HybridComputeManagementClient( ): # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Hybrid Compute Management Client. + :ivar licenses: LicensesOperations operations + :vartype licenses: azure.mgmt.hybridcompute.operations.LicensesOperations :ivar machines: MachinesOperations operations :vartype machines: azure.mgmt.hybridcompute.operations.MachinesOperations + :ivar license_profiles: LicenseProfilesOperations operations + :vartype license_profiles: azure.mgmt.hybridcompute.operations.LicenseProfilesOperations :ivar machine_extensions: MachineExtensionsOperations operations :vartype machine_extensions: azure.mgmt.hybridcompute.operations.MachineExtensionsOperations + :ivar extension_metadata: ExtensionMetadataOperations operations + :vartype extension_metadata: azure.mgmt.hybridcompute.operations.ExtensionMetadataOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.hybridcompute.operations.Operations + :ivar network_profile: NetworkProfileOperations operations + :vartype network_profile: azure.mgmt.hybridcompute.operations.NetworkProfileOperations + :ivar hybrid_identity_metadata: HybridIdentityMetadataOperations operations + :vartype hybrid_identity_metadata: + azure.mgmt.hybridcompute.operations.HybridIdentityMetadataOperations + :ivar agent_version: AgentVersionOperations operations + :vartype agent_version: azure.mgmt.hybridcompute.operations.AgentVersionOperations + :ivar machine_run_commands: MachineRunCommandsOperations operations + :vartype machine_run_commands: azure.mgmt.hybridcompute.operations.MachineRunCommandsOperations :ivar private_link_scopes: PrivateLinkScopesOperations operations :vartype private_link_scopes: azure.mgmt.hybridcompute.operations.PrivateLinkScopesOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations @@ -55,8 +77,8 @@ class HybridComputeManagementClient( :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2022-03-10". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-10-03-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. @@ -72,17 +94,32 @@ def __init__( self._config = HybridComputeManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False + self.licenses = LicensesOperations(self._client, self._config, self._serialize, self._deserialize) self.machines = MachinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.license_profiles = LicenseProfilesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.machine_extensions = MachineExtensionsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.extension_metadata = ExtensionMetadataOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.network_profile = NetworkProfileOperations(self._client, self._config, self._serialize, self._deserialize) + self.hybrid_identity_metadata = HybridIdentityMetadataOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.agent_version = AgentVersionOperations(self._client, self._config, self._serialize, self._deserialize) + self.machine_run_commands = MachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.private_link_scopes = PrivateLinkScopesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -122,5 +159,5 @@ def __enter__(self) -> "HybridComputeManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details) -> None: + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/_serialization.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/_serialization.py index f17c068e833e..4bae2292227b 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/_serialization.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/_serialization.py @@ -629,7 +629,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if xml_desc.get("attr", False): if xml_ns: ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) serialized.set(xml_name, new_attr) # type: ignore continue if xml_desc.get("text", False): @@ -662,8 +662,9 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _serialized.update(_new_attr) # type: ignore _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) @@ -741,6 +742,8 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. :rtype: str :raises: TypeError if serialization fails. :raises: ValueError if data is None @@ -749,10 +752,8 @@ def query(self, name, data, data_type, **kwargs): # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get("skip_quote", False) + return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -891,6 +892,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. :rtype: list, str """ if isinstance(data, str): @@ -903,9 +906,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -950,7 +958,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: @@ -1271,7 +1281,7 @@ def _extract_name_from_internal_type(internal_type): xml_name = internal_type_xml_map.get("name", internal_type.__name__) xml_ns = internal_type_xml_map.get("ns", None) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) return xml_name @@ -1295,7 +1305,7 @@ def xml_key_extractor(attr, attr_desc, data): # Integrate namespace if necessary xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) # If it's an attribute, that's simple if xml_desc.get("attr", False): diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/_vendor.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/_vendor.py index b26bf832e7d5..7857973c34b3 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/_vendor.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/_vendor.py @@ -6,7 +6,7 @@ # -------------------------------------------------------------------------- from abc import ABC -from typing import List, TYPE_CHECKING, cast +from typing import TYPE_CHECKING from azure.core.pipeline.transport import HttpRequest @@ -27,18 +27,6 @@ def _convert_request(request, files=None): return request -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) - - class HybridComputeManagementClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/_version.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/_version.py index 142a0420b39b..e5754a47ce68 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/_version.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/_configuration.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/_configuration.py index fb08dae516ef..df758a1dae2b 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/_configuration.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -35,14 +29,14 @@ class HybridComputeManagementClientConfiguration(Configuration): # pylint: disa :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 "2022-03-10". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-10-03-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(HybridComputeManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", "2022-03-10") + api_version: str = kwargs.pop("api_version", "2023-10-03-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/_hybrid_compute_management_client.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/_hybrid_compute_management_client.py index c91d02fe633f..321ac7365eda 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/_hybrid_compute_management_client.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/_hybrid_compute_management_client.py @@ -16,9 +16,16 @@ from .._serialization import Deserializer, Serializer from ._configuration import HybridComputeManagementClientConfiguration from .operations import ( + AgentVersionOperations, + ExtensionMetadataOperations, HybridComputeManagementClientOperationsMixin, + HybridIdentityMetadataOperations, + LicenseProfilesOperations, + LicensesOperations, MachineExtensionsOperations, + MachineRunCommandsOperations, MachinesOperations, + NetworkProfileOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, @@ -35,13 +42,30 @@ class HybridComputeManagementClient( ): # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Hybrid Compute Management Client. + :ivar licenses: LicensesOperations operations + :vartype licenses: azure.mgmt.hybridcompute.aio.operations.LicensesOperations :ivar machines: MachinesOperations operations :vartype machines: azure.mgmt.hybridcompute.aio.operations.MachinesOperations + :ivar license_profiles: LicenseProfilesOperations operations + :vartype license_profiles: azure.mgmt.hybridcompute.aio.operations.LicenseProfilesOperations :ivar machine_extensions: MachineExtensionsOperations operations :vartype machine_extensions: azure.mgmt.hybridcompute.aio.operations.MachineExtensionsOperations + :ivar extension_metadata: ExtensionMetadataOperations operations + :vartype extension_metadata: + azure.mgmt.hybridcompute.aio.operations.ExtensionMetadataOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.hybridcompute.aio.operations.Operations + :ivar network_profile: NetworkProfileOperations operations + :vartype network_profile: azure.mgmt.hybridcompute.aio.operations.NetworkProfileOperations + :ivar hybrid_identity_metadata: HybridIdentityMetadataOperations operations + :vartype hybrid_identity_metadata: + azure.mgmt.hybridcompute.aio.operations.HybridIdentityMetadataOperations + :ivar agent_version: AgentVersionOperations operations + :vartype agent_version: azure.mgmt.hybridcompute.aio.operations.AgentVersionOperations + :ivar machine_run_commands: MachineRunCommandsOperations operations + :vartype machine_run_commands: + azure.mgmt.hybridcompute.aio.operations.MachineRunCommandsOperations :ivar private_link_scopes: PrivateLinkScopesOperations operations :vartype private_link_scopes: azure.mgmt.hybridcompute.aio.operations.PrivateLinkScopesOperations @@ -57,8 +81,8 @@ class HybridComputeManagementClient( :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2022-03-10". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-10-03-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. @@ -74,17 +98,32 @@ def __init__( self._config = HybridComputeManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False + self.licenses = LicensesOperations(self._client, self._config, self._serialize, self._deserialize) self.machines = MachinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.license_profiles = LicenseProfilesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.machine_extensions = MachineExtensionsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.extension_metadata = ExtensionMetadataOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.network_profile = NetworkProfileOperations(self._client, self._config, self._serialize, self._deserialize) + self.hybrid_identity_metadata = HybridIdentityMetadataOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.agent_version = AgentVersionOperations(self._client, self._config, self._serialize, self._deserialize) + self.machine_run_commands = MachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.private_link_scopes = PrivateLinkScopesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -124,5 +163,5 @@ async def __aenter__(self) -> "HybridComputeManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/__init__.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/__init__.py index 4709c0d6c162..0a1d56088a0d 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/__init__.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/__init__.py @@ -6,10 +6,17 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from ._licenses_operations import LicensesOperations from ._machines_operations import MachinesOperations +from ._license_profiles_operations import LicenseProfilesOperations from ._machine_extensions_operations import MachineExtensionsOperations from ._hybrid_compute_management_client_operations import HybridComputeManagementClientOperationsMixin +from ._extension_metadata_operations import ExtensionMetadataOperations from ._operations import Operations +from ._network_profile_operations import NetworkProfileOperations +from ._hybrid_identity_metadata_operations import HybridIdentityMetadataOperations +from ._agent_version_operations import AgentVersionOperations +from ._machine_run_commands_operations import MachineRunCommandsOperations from ._private_link_scopes_operations import PrivateLinkScopesOperations from ._private_link_resources_operations import PrivateLinkResourcesOperations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations @@ -19,10 +26,17 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ + "LicensesOperations", "MachinesOperations", + "LicenseProfilesOperations", "MachineExtensionsOperations", "HybridComputeManagementClientOperationsMixin", + "ExtensionMetadataOperations", "Operations", + "NetworkProfileOperations", + "HybridIdentityMetadataOperations", + "AgentVersionOperations", + "MachineRunCommandsOperations", "PrivateLinkScopesOperations", "PrivateLinkResourcesOperations", "PrivateEndpointConnectionsOperations", diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_agent_version_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_agent_version_operations.py new file mode 100644 index 000000000000..f3008ff91b46 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_agent_version_operations.py @@ -0,0 +1,168 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._agent_version_operations import build_get_request, build_list_request +from .._vendor import HybridComputeManagementClientMixinABC + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AgentVersionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridcompute.aio.HybridComputeManagementClient`'s + :attr:`agent_version` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list(self, os_type: str, **kwargs: Any) -> _models.AgentVersionsList: + """Gets all Agent Versions along with the download link currently present. + + :param os_type: Defines the os type. Required. + :type os_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AgentVersionsList or the result of cls(response) + :rtype: ~azure.mgmt.hybridcompute.models.AgentVersionsList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AgentVersionsList] = kwargs.pop("cls", None) + + request = build_list_request( + os_type=os_type, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AgentVersionsList", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {"url": "/providers/Microsoft.HybridCompute/osType/{osType}/agentVersions"} + + @distributed_trace_async + async def get(self, os_type: str, version: str, **kwargs: Any) -> _models.AgentVersion: + """Gets an Agent Version along with the download link currently present. + + :param os_type: Defines the os type. Required. + :type os_type: str + :param version: Defines the agent version. To get latest, use latest or else a specific agent + version. Required. + :type version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AgentVersion or the result of cls(response) + :rtype: ~azure.mgmt.hybridcompute.models.AgentVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AgentVersion] = kwargs.pop("cls", None) + + request = build_get_request( + os_type=os_type, + version=version, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AgentVersion", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/providers/Microsoft.HybridCompute/osType/{osType}/agentVersions/{version}"} diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_extension_metadata_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_extension_metadata_operations.py new file mode 100644 index 000000000000..4af771926b60 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_extension_metadata_operations.py @@ -0,0 +1,220 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._extension_metadata_operations import build_get_request, build_list_request +from .._vendor import HybridComputeManagementClientMixinABC + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ExtensionMetadataOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridcompute.aio.HybridComputeManagementClient`'s + :attr:`extension_metadata` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, location: str, publisher: str, extension_type: str, version: str, **kwargs: Any + ) -> _models.ExtensionValue: + """Gets an Extension Metadata based on location, publisher, extensionType and version. + + :param location: The location of the Extension being received. Required. + :type location: str + :param publisher: The publisher of the Extension being received. Required. + :type publisher: str + :param extension_type: The extensionType of the Extension being received. Required. + :type extension_type: str + :param version: The version of the Extension being received. Required. + :type version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ExtensionValue or the result of cls(response) + :rtype: ~azure.mgmt.hybridcompute.models.ExtensionValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ExtensionValue] = kwargs.pop("cls", None) + + request = build_get_request( + location=location, + publisher=publisher, + extension_type=extension_type, + version=version, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ExtensionValue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.HybridCompute/locations/{location}/publishers/{publisher}/extensionTypes/{extensionType}/versions/{version}" + } + + @distributed_trace + def list( + self, location: str, publisher: str, extension_type: str, **kwargs: Any + ) -> AsyncIterable["_models.ExtensionValue"]: + """Gets all Extension versions based on location, publisher, extensionType. + + :param location: The location of the Extension being received. Required. + :type location: str + :param publisher: The publisher of the Extension being received. Required. + :type publisher: str + :param extension_type: The extensionType of the Extension being received. Required. + :type extension_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExtensionValue or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridcompute.models.ExtensionValue] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ExtensionValueListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + location=location, + publisher=publisher, + extension_type=extension_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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 = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ExtensionValueListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.HybridCompute/locations/{location}/publishers/{publisher}/extensionTypes/{extensionType}/versions" + } diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_hybrid_compute_management_client_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_hybrid_compute_management_client_operations.py index 9ed92a8644c4..835969a7914c 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_hybrid_compute_management_client_operations.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_hybrid_compute_management_client_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -31,10 +31,6 @@ from ...operations._hybrid_compute_management_client_operations import build_upgrade_extensions_request from .._vendor import HybridComputeManagementClientMixinABC -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,16 +54,14 @@ async def _upgrade_extensions_initial( # pylint: disable=inconsistent-return-st _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(extension_upgrade_parameters, (IO, bytes)): + if isinstance(extension_upgrade_parameters, (IOBase, bytes)): _content = extension_upgrade_parameters else: _json = self._serialize.body(extension_upgrade_parameters, "MachineExtensionUpgrade") @@ -87,8 +81,9 @@ async def _upgrade_extensions_initial( # pylint: disable=inconsistent-return-st request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -98,8 +93,16 @@ async def _upgrade_extensions_initial( # pylint: disable=inconsistent-return-st error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) 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")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, response_headers) _upgrade_extensions_initial.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/upgradeExtensions" @@ -193,7 +196,7 @@ async def begin_upgrade_extensions( :param machine_name: The name of the hybrid machine. Required. :type machine_name: str :param extension_upgrade_parameters: Parameters supplied to the Upgrade Extensions operation. - Is either a model type or a IO type. Required. + Is either a MachineExtensionUpgrade type or a IO type. Required. :type extension_upgrade_parameters: ~azure.mgmt.hybridcompute.models.MachineExtensionUpgrade or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -214,9 +217,7 @@ async def begin_upgrade_extensions( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_hybrid_identity_metadata_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_hybrid_identity_metadata_operations.py new file mode 100644 index 000000000000..c216c4e4a567 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_hybrid_identity_metadata_operations.py @@ -0,0 +1,221 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._hybrid_identity_metadata_operations import build_get_request, build_list_by_machines_request +from .._vendor import HybridComputeManagementClientMixinABC + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class HybridIdentityMetadataOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridcompute.aio.HybridComputeManagementClient`'s + :attr:`hybrid_identity_metadata` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, machine_name: str, metadata_name: str, **kwargs: Any + ) -> _models.HybridIdentityMetadata: + """Gets HybridIdentityMetadata. + + Implements HybridIdentityMetadata GET method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param metadata_name: Name of the HybridIdentityMetadata. Required. + :type metadata_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HybridIdentityMetadata or the result of cls(response) + :rtype: ~azure.mgmt.hybridcompute.models.HybridIdentityMetadata + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.HybridIdentityMetadata] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + metadata_name=metadata_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("HybridIdentityMetadata", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/hybridIdentityMetadata/{metadataName}" + } + + @distributed_trace + def list_by_machines( + self, resource_group_name: str, machine_name: str, **kwargs: Any + ) -> AsyncIterable["_models.HybridIdentityMetadata"]: + """Implements GET HybridIdentityMetadata in a machine. + + Returns the list of HybridIdentityMetadata of the given machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either HybridIdentityMetadata or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridcompute.models.HybridIdentityMetadata] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.HybridIdentityMetadataList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_machines_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_machines.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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 = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("HybridIdentityMetadataList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_machines.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/hybridIdentityMetadata" + } diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_license_profiles_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_license_profiles_operations.py new file mode 100644 index 000000000000..9d645f07c833 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_license_profiles_operations.py @@ -0,0 +1,842 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from 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._license_profiles_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) +from .._vendor import HybridComputeManagementClientMixinABC + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class LicenseProfilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridcompute.aio.HybridComputeManagementClient`'s + :attr:`license_profiles` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_or_update_initial( + self, resource_group_name: str, machine_name: str, parameters: Union[_models.LicenseProfile, IO], **kwargs: Any + ) -> _models.LicenseProfile: + error_map = { + 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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + license_profile_name: Literal["default"] = kwargs.pop("license_profile_name", "default") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LicenseProfile] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LicenseProfile") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + license_profile_name=license_profile_name, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("LicenseProfile", pipeline_response) + + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("LicenseProfile", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/licenseProfiles/{licenseProfileName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + machine_name: str, + parameters: _models.LicenseProfile, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LicenseProfile]: + """The operation to create or update a license profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param parameters: Parameters supplied to the Create or Update license profile operation. + Required. + :type parameters: ~azure.mgmt.hybridcompute.models.LicenseProfile + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword license_profile_name: The name of the license profile. Default value is "default". + Note that overriding this default value may result in unsupported behavior. + :paramtype license_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either LicenseProfile or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.LicenseProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + machine_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LicenseProfile]: + """The operation to create or update a license profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param parameters: Parameters supplied to the Create or Update license profile operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword license_profile_name: The name of the license profile. Default value is "default". + Note that overriding this default value may result in unsupported behavior. + :paramtype license_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either LicenseProfile or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.LicenseProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, machine_name: str, parameters: Union[_models.LicenseProfile, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.LicenseProfile]: + """The operation to create or update a license profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param parameters: Parameters supplied to the Create or Update license profile operation. Is + either a LicenseProfile type or a IO type. Required. + :type parameters: ~azure.mgmt.hybridcompute.models.LicenseProfile or IO + :keyword license_profile_name: The name of the license profile. Default value is "default". + Note that overriding this default value may result in unsupported behavior. + :paramtype license_profile_name: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either LicenseProfile or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.LicenseProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", self._config.api_version)) + license_profile_name: Literal["default"] = kwargs.pop("license_profile_name", "default") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LicenseProfile] = 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_update_initial( + resource_group_name=resource_group_name, + machine_name=machine_name, + parameters=parameters, + api_version=api_version, + license_profile_name=license_profile_name, + 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): + deserialized = self._deserialize("LicenseProfile", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + 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.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/licenseProfiles/{licenseProfileName}" + } + + async def _update_initial( + self, + resource_group_name: str, + machine_name: str, + parameters: Union[_models.LicenseProfileUpdate, IO], + **kwargs: Any + ) -> Optional[_models.LicenseProfile]: + error_map = { + 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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + license_profile_name: Literal["default"] = kwargs.pop("license_profile_name", "default") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.LicenseProfile]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LicenseProfileUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + license_profile_name=license_profile_name, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("LicenseProfile", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/licenseProfiles/{licenseProfileName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + machine_name: str, + parameters: _models.LicenseProfileUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LicenseProfile]: + """The operation to update a license profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param parameters: Parameters supplied to the Update license profile operation. Required. + :type parameters: ~azure.mgmt.hybridcompute.models.LicenseProfileUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword license_profile_name: The name of the license profile. Default value is "default". + Note that overriding this default value may result in unsupported behavior. + :paramtype license_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either LicenseProfile or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.LicenseProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + machine_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LicenseProfile]: + """The operation to update a license profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param parameters: Parameters supplied to the Update license profile operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword license_profile_name: The name of the license profile. Default value is "default". + Note that overriding this default value may result in unsupported behavior. + :paramtype license_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either LicenseProfile or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.LicenseProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + machine_name: str, + parameters: Union[_models.LicenseProfileUpdate, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.LicenseProfile]: + """The operation to update a license profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param parameters: Parameters supplied to the Update license profile operation. Is either a + LicenseProfileUpdate type or a IO type. Required. + :type parameters: ~azure.mgmt.hybridcompute.models.LicenseProfileUpdate or IO + :keyword license_profile_name: The name of the license profile. Default value is "default". + Note that overriding this default value may result in unsupported behavior. + :paramtype license_profile_name: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either LicenseProfile or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.LicenseProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", self._config.api_version)) + license_profile_name: Literal["default"] = kwargs.pop("license_profile_name", "default") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LicenseProfile] = 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, + machine_name=machine_name, + parameters=parameters, + api_version=api_version, + license_profile_name=license_profile_name, + 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): + deserialized = self._deserialize("LicenseProfile", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + 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.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/licenseProfiles/{licenseProfileName}" + } + + @distributed_trace_async + async def get(self, resource_group_name: str, machine_name: str, **kwargs: Any) -> _models.LicenseProfile: + """Retrieves information about the view of a license profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :keyword license_profile_name: The name of the license profile. Default value is "default". + Note that overriding this default value may result in unsupported behavior. + :paramtype license_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LicenseProfile or the result of cls(response) + :rtype: ~azure.mgmt.hybridcompute.models.LicenseProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + license_profile_name: Literal["default"] = kwargs.pop("license_profile_name", "default") + cls: ClsType[_models.LicenseProfile] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + license_profile_name=license_profile_name, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LicenseProfile", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/licenseProfiles/{licenseProfileName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, machine_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + license_profile_name: Literal["default"] = kwargs.pop("license_profile_name", "default") + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + license_profile_name=license_profile_name, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/licenseProfiles/{licenseProfileName}" + } + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, machine_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """The operation to delete a license profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :keyword license_profile_name: The name of the license profile. Default value is "default". + Note that overriding this default value may result in unsupported behavior. + :paramtype license_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + license_profile_name: Literal["default"] = kwargs.pop("license_profile_name", "default") + 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, + machine_name=machine_name, + api_version=api_version, + license_profile_name=license_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, {}) + + 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.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/licenseProfiles/{licenseProfileName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, machine_name: str, **kwargs: Any + ) -> AsyncIterable["_models.LicenseProfile"]: + """The operation to get all license profiles of a non-Azure machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the machine. Required. + :type machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LicenseProfile or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridcompute.models.LicenseProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LicenseProfilesListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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 = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("LicenseProfilesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/licenseProfiles" + } diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_licenses_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_licenses_operations.py new file mode 100644 index 000000000000..c933b91183c9 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_licenses_operations.py @@ -0,0 +1,1020 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from 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._licenses_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, + build_validate_license_request, +) +from .._vendor import HybridComputeManagementClientMixinABC + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class LicensesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridcompute.aio.HybridComputeManagementClient`'s + :attr:`licenses` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _validate_license_initial(self, parameters: Union[_models.License, IO], **kwargs: Any) -> _models.License: + error_map = { + 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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.License] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "License") + + request = build_validate_license_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._validate_license_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("License", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _validate_license_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.HybridCompute/validateLicense" + } + + @overload + async def begin_validate_license( + self, parameters: _models.License, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.License]: + """The operation to validate a license. + + :param parameters: Parameters supplied to the license validation operation. Required. + :type parameters: ~azure.mgmt.hybridcompute.models.License + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either License or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.License] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate_license( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.License]: + """The operation to validate a license. + + :param parameters: Parameters supplied to the license validation operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either License or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.License] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_license( + self, parameters: Union[_models.License, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.License]: + """The operation to validate a license. + + :param parameters: Parameters supplied to the license validation operation. Is either a License + type or a IO type. Required. + :type parameters: ~azure.mgmt.hybridcompute.models.License or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either License or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.License] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.License] = 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._validate_license_initial( + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("License", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + 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.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_validate_license.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.HybridCompute/validateLicense" + } + + async def _create_or_update_initial( + self, resource_group_name: str, license_name: str, parameters: Union[_models.License, IO], **kwargs: Any + ) -> _models.License: + error_map = { + 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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.License] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "License") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + license_name=license_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("License", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/licenses/{licenseName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + license_name: str, + parameters: _models.License, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.License]: + """The operation to create or update a license. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param license_name: The name of the license. Required. + :type license_name: str + :param parameters: Parameters supplied to the Create license operation. Required. + :type parameters: ~azure.mgmt.hybridcompute.models.License + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either License or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.License] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + license_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.License]: + """The operation to create or update a license. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param license_name: The name of the license. Required. + :type license_name: str + :param parameters: Parameters supplied to the Create license operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either License or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.License] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, license_name: str, parameters: Union[_models.License, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.License]: + """The operation to create or update a license. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param license_name: The name of the license. Required. + :type license_name: str + :param parameters: Parameters supplied to the Create license operation. Is either a License + type or a IO type. Required. + :type parameters: ~azure.mgmt.hybridcompute.models.License or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either License or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.License] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.License] = 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_update_initial( + resource_group_name=resource_group_name, + license_name=license_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("License", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + 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.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/licenses/{licenseName}" + } + + async def _update_initial( + self, resource_group_name: str, license_name: str, parameters: Union[_models.LicenseUpdate, IO], **kwargs: Any + ) -> _models.License: + error_map = { + 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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.License] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LicenseUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + license_name=license_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("License", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/licenses/{licenseName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + license_name: str, + parameters: _models.LicenseUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.License]: + """The operation to update a license. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param license_name: The name of the license. Required. + :type license_name: str + :param parameters: Parameters supplied to the Update license operation. Required. + :type parameters: ~azure.mgmt.hybridcompute.models.LicenseUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either License or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.License] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + license_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.License]: + """The operation to update a license. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param license_name: The name of the license. Required. + :type license_name: str + :param parameters: Parameters supplied to the Update license operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either License or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.License] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, license_name: str, parameters: Union[_models.LicenseUpdate, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.License]: + """The operation to update a license. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param license_name: The name of the license. Required. + :type license_name: str + :param parameters: Parameters supplied to the Update license operation. Is either a + LicenseUpdate type or a IO type. Required. + :type parameters: ~azure.mgmt.hybridcompute.models.LicenseUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either License or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.License] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.License] = 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, + license_name=license_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("License", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + 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.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/licenses/{licenseName}" + } + + @distributed_trace_async + async def get(self, resource_group_name: str, license_name: str, **kwargs: Any) -> _models.License: + """Retrieves information about the view of a license. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param license_name: The name of the license. Required. + :type license_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: License or the result of cls(response) + :rtype: ~azure.mgmt.hybridcompute.models.License + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.License] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + license_name=license_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("License", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/licenses/{licenseName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, license_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + license_name=license_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/licenses/{licenseName}" + } + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, license_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """The operation to delete a license. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param license_name: The name of the license. Required. + :type license_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + 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, + license_name=license_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + 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.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/licenses/{licenseName}" + } + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.License"]: + """The operation to get all licenses of a non-Azure machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either License or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridcompute.models.License] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LicensesListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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 = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("LicensesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/licenses" + } + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.License"]: + """The operation to get all licenses of a non-Azure machine. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either License or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridcompute.models.License] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LicensesListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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 = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("LicensesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.HybridCompute/licenses" + } diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_machine_extensions_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_machine_extensions_operations.py index 9222583a9bcc..576789a7db7a 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_machine_extensions_operations.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_machine_extensions_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -40,10 +40,6 @@ ) from .._vendor import HybridComputeManagementClientMixinABC -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -86,16 +82,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.MachineExtension]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(extension_parameters, (IO, bytes)): + if isinstance(extension_parameters, (IOBase, bytes)): _content = extension_parameters else: _json = self._serialize.body(extension_parameters, "MachineExtension") @@ -116,8 +110,9 @@ async def _create_or_update_initial( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -242,7 +237,7 @@ async def begin_create_or_update( :param extension_name: The name of the machine extension. Required. :type extension_name: str :param extension_parameters: Parameters supplied to the Create Machine Extension operation. Is - either a model type or a IO type. Required. + either a MachineExtension type or a IO type. Required. :type extension_parameters: ~azure.mgmt.hybridcompute.models.MachineExtension or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -263,9 +258,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -330,16 +323,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.MachineExtension]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(extension_parameters, (IO, bytes)): + if isinstance(extension_parameters, (IOBase, bytes)): _content = extension_parameters else: _json = self._serialize.body(extension_parameters, "MachineExtensionUpdate") @@ -360,8 +351,9 @@ async def _update_initial( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -372,11 +364,19 @@ async def _update_initial( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize("MachineExtension", pipeline_response) + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, response_headers) return deserialized @@ -486,7 +486,7 @@ async def begin_update( :param extension_name: The name of the machine extension. Required. :type extension_name: str :param extension_parameters: Parameters supplied to the Create Machine Extension operation. Is - either a model type or a IO type. Required. + either a MachineExtensionUpdate type or a IO type. Required. :type extension_parameters: ~azure.mgmt.hybridcompute.models.MachineExtensionUpdate or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -507,9 +507,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -569,9 +567,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -587,8 +583,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -598,8 +595,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) 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")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, response_headers) _delete_initial.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/extensions/{extensionName}" @@ -633,9 +638,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) 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) @@ -705,9 +708,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None) request = build_get_request( @@ -723,8 +724,9 @@ async def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -767,9 +769,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MachineExtensionsListResult] = kwargs.pop("cls", None) error_map = { @@ -824,8 +824,9 @@ async def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_machine_run_commands_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_machine_run_commands_operations.py new file mode 100644 index 000000000000..08ba40131466 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_machine_run_commands_operations.py @@ -0,0 +1,848 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from 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._machine_run_commands_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) +from .._vendor import HybridComputeManagementClientMixinABC + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class MachineRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridcompute.aio.HybridComputeManagementClient`'s + :attr:`machine_run_commands` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_or_update_initial( + self, + resource_group_name: str, + machine_name: str, + run_command_name: str, + run_command_properties: Union[_models.MachineRunCommand, IO], + **kwargs: Any + ) -> _models.MachineRunCommand: + error_map = { + 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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MachineRunCommand] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_command_properties, (IOBase, bytes)): + _content = run_command_properties + else: + _json = self._serialize.body(run_command_properties, "MachineRunCommand") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + run_command_name=run_command_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("MachineRunCommand", pipeline_response) + + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("MachineRunCommand", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands/{runCommandName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + machine_name: str, + run_command_name: str, + run_command_properties: _models.MachineRunCommand, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MachineRunCommand]: + """The operation to create or update a run command. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param run_command_name: The name of the run command. Required. + :type run_command_name: str + :param run_command_properties: Parameters supplied to the Create Run Command. Required. + :type run_command_properties: ~azure.mgmt.hybridcompute.models.MachineRunCommand + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MachineRunCommand or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.MachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + machine_name: str, + run_command_name: str, + run_command_properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MachineRunCommand]: + """The operation to create or update a run command. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param run_command_name: The name of the run command. Required. + :type run_command_name: str + :param run_command_properties: Parameters supplied to the Create Run Command. Required. + :type run_command_properties: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MachineRunCommand or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.MachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + machine_name: str, + run_command_name: str, + run_command_properties: Union[_models.MachineRunCommand, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.MachineRunCommand]: + """The operation to create or update a run command. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param run_command_name: The name of the run command. Required. + :type run_command_name: str + :param run_command_properties: Parameters supplied to the Create Run Command. Is either a + MachineRunCommand type or a IO type. Required. + :type run_command_properties: ~azure.mgmt.hybridcompute.models.MachineRunCommand or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MachineRunCommand or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.MachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MachineRunCommand] = 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_update_initial( + resource_group_name=resource_group_name, + machine_name=machine_name, + run_command_name=run_command_name, + run_command_properties=run_command_properties, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("MachineRunCommand", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands/{runCommandName}" + } + + async def _update_initial( + self, + resource_group_name: str, + machine_name: str, + run_command_name: str, + run_command_properties: Union[_models.MachineRunCommandUpdate, IO], + **kwargs: Any + ) -> Optional[_models.MachineRunCommand]: + error_map = { + 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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MachineRunCommand]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_command_properties, (IOBase, bytes)): + _content = run_command_properties + else: + _json = self._serialize.body(run_command_properties, "MachineRunCommandUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + run_command_name=run_command_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("MachineRunCommand", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands/{runCommandName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + machine_name: str, + run_command_name: str, + run_command_properties: _models.MachineRunCommandUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MachineRunCommand]: + """The operation to update the run command. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param run_command_name: The name of the run command. Required. + :type run_command_name: str + :param run_command_properties: Parameters supplied to the Create Run Command. Required. + :type run_command_properties: ~azure.mgmt.hybridcompute.models.MachineRunCommandUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MachineRunCommand or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.MachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + machine_name: str, + run_command_name: str, + run_command_properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MachineRunCommand]: + """The operation to update the run command. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param run_command_name: The name of the run command. Required. + :type run_command_name: str + :param run_command_properties: Parameters supplied to the Create Run Command. Required. + :type run_command_properties: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MachineRunCommand or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.MachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + machine_name: str, + run_command_name: str, + run_command_properties: Union[_models.MachineRunCommandUpdate, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.MachineRunCommand]: + """The operation to update the run command. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param run_command_name: The name of the run command. Required. + :type run_command_name: str + :param run_command_properties: Parameters supplied to the Create Run Command. Is either a + MachineRunCommandUpdate type or a IO type. Required. + :type run_command_properties: ~azure.mgmt.hybridcompute.models.MachineRunCommandUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MachineRunCommand or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.MachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MachineRunCommand] = 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, + machine_name=machine_name, + run_command_name=run_command_name, + run_command_properties=run_command_properties, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("MachineRunCommand", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + 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.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands/{runCommandName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, machine_name: str, run_command_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + run_command_name=run_command_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands/{runCommandName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, machine_name: str, run_command_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """The operation to delete a run command. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param run_command_name: The name of the run command. Required. + :type run_command_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + 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, + machine_name=machine_name, + run_command_name=run_command_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands/{runCommandName}" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, machine_name: str, run_command_name: str, **kwargs: Any + ) -> _models.MachineRunCommand: + """The operation to get a run command. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param run_command_name: The name of the run command. Required. + :type run_command_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MachineRunCommand or the result of cls(response) + :rtype: ~azure.mgmt.hybridcompute.models.MachineRunCommand + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.MachineRunCommand] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + run_command_name=run_command_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MachineRunCommand", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands/{runCommandName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, machine_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.MachineRunCommand"]: + """The operation to get all the run commands of a non-Azure machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MachineRunCommand or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridcompute.models.MachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.MachineRunCommandsListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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 = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("MachineRunCommandsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands" + } diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_machines_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_machines_operations.py index 82d87fe31a41..b756421b0e13 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_machines_operations.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_machines_operations.py @@ -6,8 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -21,26 +21,26 @@ ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.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._machines_operations import ( + build_assess_patches_request, build_delete_request, build_get_request, + build_install_patches_request, build_list_by_resource_group_request, build_list_by_subscription_request, ) from .._vendor import HybridComputeManagementClientMixinABC -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +68,7 @@ def __init__(self, *args, **kwargs) -> None: async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, machine_name: str, **kwargs: Any ) -> None: - """The operation to remove a hybrid machine identity in Azure. + """The operation to delete a hybrid machine. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -91,9 +91,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -108,8 +106,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -160,9 +159,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Machine] = kwargs.pop("cls", None) request = build_get_request( @@ -178,8 +175,9 @@ async def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -200,14 +198,380 @@ async def get( "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}" } + async def _assess_patches_initial( + self, resource_group_name: str, name: str, **kwargs: Any + ) -> Optional[_models.MachineAssessPatchesResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.MachineAssessPatchesResult]] = kwargs.pop("cls", None) + + request = build_assess_patches_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._assess_patches_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("MachineAssessPatchesResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _assess_patches_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/assessPatches" + } + + @distributed_trace_async + async def begin_assess_patches( + self, resource_group_name: str, name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.MachineAssessPatchesResult]: + """The operation to assess patches on a hybrid machine identity in Azure. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param name: The name of the hybrid machine. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MachineAssessPatchesResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.MachineAssessPatchesResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.MachineAssessPatchesResult] = 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._assess_patches_initial( + resource_group_name=resource_group_name, + name=name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("MachineAssessPatchesResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_assess_patches.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/assessPatches" + } + + async def _install_patches_initial( + self, + resource_group_name: str, + name: str, + install_patches_input: Union[_models.MachineInstallPatchesParameters, IO], + **kwargs: Any + ) -> Optional[_models.MachineInstallPatchesResult]: + error_map = { + 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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MachineInstallPatchesResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(install_patches_input, (IOBase, bytes)): + _content = install_patches_input + else: + _json = self._serialize.body(install_patches_input, "MachineInstallPatchesParameters") + + request = build_install_patches_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._install_patches_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("MachineInstallPatchesResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _install_patches_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/installPatches" + } + + @overload + async def begin_install_patches( + self, + resource_group_name: str, + name: str, + install_patches_input: _models.MachineInstallPatchesParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MachineInstallPatchesResult]: + """The operation to install patches on a hybrid machine identity in Azure. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param name: The name of the hybrid machine. Required. + :type name: str + :param install_patches_input: Input for InstallPatches as directly received by the API. + Required. + :type install_patches_input: ~azure.mgmt.hybridcompute.models.MachineInstallPatchesParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MachineInstallPatchesResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.MachineInstallPatchesResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_install_patches( + self, + resource_group_name: str, + name: str, + install_patches_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MachineInstallPatchesResult]: + """The operation to install patches on a hybrid machine identity in Azure. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param name: The name of the hybrid machine. Required. + :type name: str + :param install_patches_input: Input for InstallPatches as directly received by the API. + Required. + :type install_patches_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MachineInstallPatchesResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.MachineInstallPatchesResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_install_patches( + self, + resource_group_name: str, + name: str, + install_patches_input: Union[_models.MachineInstallPatchesParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.MachineInstallPatchesResult]: + """The operation to install patches on a hybrid machine identity in Azure. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param name: The name of the hybrid machine. Required. + :type name: str + :param install_patches_input: Input for InstallPatches as directly received by the API. Is + either a MachineInstallPatchesParameters type or a IO type. Required. + :type install_patches_input: ~azure.mgmt.hybridcompute.models.MachineInstallPatchesParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MachineInstallPatchesResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.MachineInstallPatchesResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MachineInstallPatchesResult] = 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._install_patches_initial( + resource_group_name=resource_group_name, + name=name, + install_patches_input=install_patches_input, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("MachineInstallPatchesResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_install_patches.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/installPatches" + } + @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Machine"]: + def list_by_resource_group( + self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Machine"]: """Lists all the hybrid machines in the specified resource group. Use the nextLink property in the response to get the next page of hybrid machines. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str + :param expand: Expands referenced resources. Default value is None. + :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Machine or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridcompute.models.Machine] @@ -216,9 +580,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MachineListResult] = kwargs.pop("cls", None) error_map = { @@ -235,6 +597,7 @@ def prepare_request(next_link=None): request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, template_url=self.list_by_resource_group.metadata["url"], headers=_headers, @@ -271,8 +634,9 @@ async def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -302,9 +666,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Machine" _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MachineListResult] = kwargs.pop("cls", None) error_map = { @@ -356,8 +718,9 @@ async def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_network_profile_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_network_profile_operations.py new file mode 100644 index 000000000000..b0cfb9ec8869 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_network_profile_operations.py @@ -0,0 +1,115 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._network_profile_operations import build_get_request +from .._vendor import HybridComputeManagementClientMixinABC + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class NetworkProfileOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridcompute.aio.HybridComputeManagementClient`'s + :attr:`network_profile` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, resource_group_name: str, machine_name: str, **kwargs: Any) -> _models.NetworkProfile: + """The operation to get network information of hybrid machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NetworkProfile or the result of cls(response) + :rtype: ~azure.mgmt.hybridcompute.models.NetworkProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NetworkProfile] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NetworkProfile", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/networkProfile" + } diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_operations.py index 9f5348b29c3e..eeb92142bae1 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_operations.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -31,10 +30,6 @@ from ...operations._operations import build_list_request from .._vendor import HybridComputeManagementClientMixinABC -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,9 +66,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationValue"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { @@ -124,8 +117,9 @@ async def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_private_endpoint_connections_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_private_endpoint_connections_operations.py index 060a70c71e0b..6522e3ab687e 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_private_endpoint_connections_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -39,10 +39,6 @@ ) from .._vendor import HybridComputeManagementClientMixinABC -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -95,9 +91,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) request = build_get_request( @@ -113,8 +107,9 @@ async def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -154,16 +149,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "PrivateEndpointConnection") @@ -184,8 +177,9 @@ async def _create_or_update_initial( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -306,7 +300,7 @@ async def begin_create_or_update( :type scope_name: str :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :param parameters: Is either a model type or a IO type. Required. + :param parameters: Is either a PrivateEndpointConnection type or a IO type. Required. :type parameters: ~azure.mgmt.hybridcompute.models.PrivateEndpointConnection or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -328,9 +322,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -390,9 +382,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -408,8 +398,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -419,8 +410,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) 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")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, response_headers) _delete_initial.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" @@ -454,9 +453,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) 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) @@ -518,9 +515,7 @@ def list_by_private_link_scope( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) error_map = { @@ -574,8 +569,9 @@ async def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_private_link_resources_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_private_link_resources_operations.py index 631aff65c461..9225f541bdae 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_private_link_resources_operations.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_private_link_resources_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -32,10 +31,6 @@ from ...operations._private_link_resources_operations import build_get_request, build_list_by_private_link_scope_request from .._vendor import HybridComputeManagementClientMixinABC -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,9 +74,7 @@ def list_by_private_link_scope( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) error_map = { @@ -135,8 +128,9 @@ async def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -182,9 +176,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) request = build_get_request( @@ -200,8 +192,9 @@ async def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_private_link_scopes_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_private_link_scopes_operations.py index c5d98c4beb86..3e546d00b9ce 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_private_link_scopes_operations.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/aio/operations/_private_link_scopes_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -43,10 +43,6 @@ ) from .._vendor import HybridComputeManagementClientMixinABC -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -84,9 +80,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.HybridComputePrivateLink _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.HybridComputePrivateLinkScopeListResult] = kwargs.pop("cls", None) error_map = { @@ -138,8 +132,9 @@ async def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -173,9 +168,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.HybridComputePrivateLinkScopeListResult] = kwargs.pop("cls", None) error_map = { @@ -228,8 +221,9 @@ async def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -260,9 +254,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -277,8 +269,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -288,8 +281,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) 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")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, response_headers) _delete_initial.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/privateLinkScopes/{scopeName}" @@ -319,9 +320,7 @@ async def begin_delete(self, resource_group_name: str, scope_name: str, **kwargs _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) 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) @@ -388,9 +387,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.HybridComputePrivateLinkScope] = kwargs.pop("cls", None) request = build_get_request( @@ -405,8 +402,9 @@ async def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -504,7 +502,8 @@ async def create_or_update( :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. :type scope_name: str :param parameters: Properties that need to be specified to create or update a Azure Arc for - Servers and Clusters PrivateLinkScope. Is either a model type or a IO type. Required. + Servers and Clusters PrivateLinkScope. Is either a HybridComputePrivateLinkScope type or a IO + type. Required. :type parameters: ~azure.mgmt.hybridcompute.models.HybridComputePrivateLinkScope or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -525,16 +524,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.HybridComputePrivateLinkScope] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "HybridComputePrivateLinkScope") @@ -554,8 +551,9 @@ async def create_or_update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -657,7 +655,7 @@ async def update_tags( :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. :type scope_name: str :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope - instance. Is either a model type or a IO type. Required. + instance. Is either a TagsResource type or a IO type. Required. :type private_link_scope_tags: ~azure.mgmt.hybridcompute.models.TagsResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -678,16 +676,14 @@ async def update_tags( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.HybridComputePrivateLinkScope] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_link_scope_tags, (IO, bytes)): + if isinstance(private_link_scope_tags, (IOBase, bytes)): _content = private_link_scope_tags else: _json = self._serialize.body(private_link_scope_tags, "TagsResource") @@ -707,8 +703,9 @@ async def update_tags( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -756,9 +753,7 @@ async def get_validation_details( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkScopeValidationDetails] = kwargs.pop("cls", None) request = build_get_validation_details_request( @@ -773,8 +768,9 @@ async def get_validation_details( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -823,9 +819,7 @@ async def get_validation_details_for_machine( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkScopeValidationDetails] = kwargs.pop("cls", None) request = build_get_validation_details_for_machine_request( @@ -840,8 +834,9 @@ async def get_validation_details_for_machine( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/models/__init__.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/models/__init__.py index 2dfe40d65d6c..4d2dfb9151ab 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/models/__init__.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/models/__init__.py @@ -7,31 +7,64 @@ # -------------------------------------------------------------------------- from ._models_py3 import AgentConfiguration +from ._models_py3 import AgentUpgrade +from ._models_py3 import AgentVersion +from ._models_py3 import AgentVersionsList +from ._models_py3 import AvailablePatchCountByClassification from ._models_py3 import CloudMetadata from ._models_py3 import ConfigurationExtension from ._models_py3 import ConnectionDetail from ._models_py3 import ErrorAdditionalInfo from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorDetailAutoGenerated from ._models_py3 import ErrorResponse +from ._models_py3 import ErrorResponseAutoGenerated +from ._models_py3 import EsuKey from ._models_py3 import ExtensionTargetProperties +from ._models_py3 import ExtensionValue +from ._models_py3 import ExtensionValueListResult +from ._models_py3 import ExtensionsResourceStatus from ._models_py3 import HybridComputePrivateLinkScope from ._models_py3 import HybridComputePrivateLinkScopeListResult from ._models_py3 import HybridComputePrivateLinkScopeProperties +from ._models_py3 import HybridIdentityMetadata +from ._models_py3 import HybridIdentityMetadataList from ._models_py3 import Identity +from ._models_py3 import IpAddress +from ._models_py3 import License +from ._models_py3 import LicenseDetails +from ._models_py3 import LicenseProfile +from ._models_py3 import LicenseProfileArmEsuProperties +from ._models_py3 import LicenseProfileArmEsuPropertiesWithoutAssignedLicense +from ._models_py3 import LicenseProfileMachineInstanceView +from ._models_py3 import LicenseProfileMachineInstanceViewEsuProperties +from ._models_py3 import LicenseProfileStorageModelEsuProperties +from ._models_py3 import LicenseProfileUpdate +from ._models_py3 import LicenseProfilesListResult +from ._models_py3 import LicenseUpdate +from ._models_py3 import LicensesListResult +from ._models_py3 import LinuxParameters from ._models_py3 import LocationData from ._models_py3 import Machine +from ._models_py3 import MachineAssessPatchesResult from ._models_py3 import MachineExtension from ._models_py3 import MachineExtensionInstanceView from ._models_py3 import MachineExtensionInstanceViewStatus from ._models_py3 import MachineExtensionProperties from ._models_py3 import MachineExtensionUpdate -from ._models_py3 import MachineExtensionUpdateProperties from ._models_py3 import MachineExtensionUpgrade from ._models_py3 import MachineExtensionsListResult +from ._models_py3 import MachineInstallPatchesParameters +from ._models_py3 import MachineInstallPatchesResult from ._models_py3 import MachineListResult -from ._models_py3 import MachineProperties +from ._models_py3 import MachineRunCommand +from ._models_py3 import MachineRunCommandInstanceView +from ._models_py3 import MachineRunCommandScriptSource +from ._models_py3 import MachineRunCommandUpdate +from ._models_py3 import MachineRunCommandsListResult from ._models_py3 import MachineUpdate -from ._models_py3 import MachineUpdateProperties +from ._models_py3 import NetworkInterface +from ._models_py3 import NetworkProfile from ._models_py3 import OSProfile from ._models_py3 import OSProfileLinuxConfiguration from ._models_py3 import OSProfileWindowsConfiguration @@ -49,53 +82,119 @@ from ._models_py3 import PrivateLinkScopeValidationDetails from ._models_py3 import PrivateLinkScopesResource from ._models_py3 import PrivateLinkServiceConnectionStateProperty +from ._models_py3 import ProductFeature +from ._models_py3 import ProductFeatureUpdate from ._models_py3 import ProxyResource from ._models_py3 import Resource from ._models_py3 import ResourceUpdate +from ._models_py3 import RunCommandInputParameter +from ._models_py3 import RunCommandManagedIdentity from ._models_py3 import ServiceStatus from ._models_py3 import ServiceStatuses +from ._models_py3 import Subnet from ._models_py3 import SystemData from ._models_py3 import TagsResource from ._models_py3 import TrackedResource +from ._models_py3 import WindowsParameters +from ._hybrid_compute_management_client_enums import AgentConfigurationMode +from ._hybrid_compute_management_client_enums import ArcKindEnum from ._hybrid_compute_management_client_enums import AssessmentModeTypes from ._hybrid_compute_management_client_enums import CreatedByType +from ._hybrid_compute_management_client_enums import EsuEligibility +from ._hybrid_compute_management_client_enums import EsuKeyState +from ._hybrid_compute_management_client_enums import EsuServerType +from ._hybrid_compute_management_client_enums import ExecutionState +from ._hybrid_compute_management_client_enums import ExtensionsStatusLevelTypes from ._hybrid_compute_management_client_enums import InstanceViewTypes +from ._hybrid_compute_management_client_enums import LastAttemptStatusEnum +from ._hybrid_compute_management_client_enums import LicenseAssignmentState +from ._hybrid_compute_management_client_enums import LicenseCoreType +from ._hybrid_compute_management_client_enums import LicenseEdition +from ._hybrid_compute_management_client_enums import LicenseProfileProductType +from ._hybrid_compute_management_client_enums import LicenseProfileSubscriptionStatus +from ._hybrid_compute_management_client_enums import LicenseProfileSubscriptionStatusUpdate +from ._hybrid_compute_management_client_enums import LicenseState +from ._hybrid_compute_management_client_enums import LicenseStatus +from ._hybrid_compute_management_client_enums import LicenseTarget +from ._hybrid_compute_management_client_enums import LicenseType +from ._hybrid_compute_management_client_enums import OsType from ._hybrid_compute_management_client_enums import PatchModeTypes +from ._hybrid_compute_management_client_enums import PatchOperationStartedBy +from ._hybrid_compute_management_client_enums import PatchOperationStatus +from ._hybrid_compute_management_client_enums import PatchServiceUsed +from ._hybrid_compute_management_client_enums import ProvisioningState from ._hybrid_compute_management_client_enums import PublicNetworkAccessType from ._hybrid_compute_management_client_enums import StatusLevelTypes from ._hybrid_compute_management_client_enums import StatusTypes +from ._hybrid_compute_management_client_enums import VMGuestPatchClassificationLinux +from ._hybrid_compute_management_client_enums import VMGuestPatchClassificationWindows +from ._hybrid_compute_management_client_enums import VMGuestPatchRebootSetting +from ._hybrid_compute_management_client_enums import VMGuestPatchRebootStatus from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ "AgentConfiguration", + "AgentUpgrade", + "AgentVersion", + "AgentVersionsList", + "AvailablePatchCountByClassification", "CloudMetadata", "ConfigurationExtension", "ConnectionDetail", "ErrorAdditionalInfo", "ErrorDetail", + "ErrorDetailAutoGenerated", "ErrorResponse", + "ErrorResponseAutoGenerated", + "EsuKey", "ExtensionTargetProperties", + "ExtensionValue", + "ExtensionValueListResult", + "ExtensionsResourceStatus", "HybridComputePrivateLinkScope", "HybridComputePrivateLinkScopeListResult", "HybridComputePrivateLinkScopeProperties", + "HybridIdentityMetadata", + "HybridIdentityMetadataList", "Identity", + "IpAddress", + "License", + "LicenseDetails", + "LicenseProfile", + "LicenseProfileArmEsuProperties", + "LicenseProfileArmEsuPropertiesWithoutAssignedLicense", + "LicenseProfileMachineInstanceView", + "LicenseProfileMachineInstanceViewEsuProperties", + "LicenseProfileStorageModelEsuProperties", + "LicenseProfileUpdate", + "LicenseProfilesListResult", + "LicenseUpdate", + "LicensesListResult", + "LinuxParameters", "LocationData", "Machine", + "MachineAssessPatchesResult", "MachineExtension", "MachineExtensionInstanceView", "MachineExtensionInstanceViewStatus", "MachineExtensionProperties", "MachineExtensionUpdate", - "MachineExtensionUpdateProperties", "MachineExtensionUpgrade", "MachineExtensionsListResult", + "MachineInstallPatchesParameters", + "MachineInstallPatchesResult", "MachineListResult", - "MachineProperties", + "MachineRunCommand", + "MachineRunCommandInstanceView", + "MachineRunCommandScriptSource", + "MachineRunCommandUpdate", + "MachineRunCommandsListResult", "MachineUpdate", - "MachineUpdateProperties", + "NetworkInterface", + "NetworkProfile", "OSProfile", "OSProfileLinuxConfiguration", "OSProfileWindowsConfiguration", @@ -113,21 +212,54 @@ "PrivateLinkScopeValidationDetails", "PrivateLinkScopesResource", "PrivateLinkServiceConnectionStateProperty", + "ProductFeature", + "ProductFeatureUpdate", "ProxyResource", "Resource", "ResourceUpdate", + "RunCommandInputParameter", + "RunCommandManagedIdentity", "ServiceStatus", "ServiceStatuses", + "Subnet", "SystemData", "TagsResource", "TrackedResource", + "WindowsParameters", + "AgentConfigurationMode", + "ArcKindEnum", "AssessmentModeTypes", "CreatedByType", + "EsuEligibility", + "EsuKeyState", + "EsuServerType", + "ExecutionState", + "ExtensionsStatusLevelTypes", "InstanceViewTypes", + "LastAttemptStatusEnum", + "LicenseAssignmentState", + "LicenseCoreType", + "LicenseEdition", + "LicenseProfileProductType", + "LicenseProfileSubscriptionStatus", + "LicenseProfileSubscriptionStatusUpdate", + "LicenseState", + "LicenseStatus", + "LicenseTarget", + "LicenseType", + "OsType", "PatchModeTypes", + "PatchOperationStartedBy", + "PatchOperationStatus", + "PatchServiceUsed", + "ProvisioningState", "PublicNetworkAccessType", "StatusLevelTypes", "StatusTypes", + "VMGuestPatchClassificationLinux", + "VMGuestPatchClassificationWindows", + "VMGuestPatchRebootSetting", + "VMGuestPatchRebootStatus", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/models/_hybrid_compute_management_client_enums.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/models/_hybrid_compute_management_client_enums.py index cf1430cbeb8a..81cc6f4f2788 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/models/_hybrid_compute_management_client_enums.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/models/_hybrid_compute_management_client_enums.py @@ -10,6 +10,27 @@ from azure.core import CaseInsensitiveEnumMeta +class AgentConfigurationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Name of configuration mode to use. Modes are pre-defined configurations of security controls, + extension allowlists and guest configuration, maintained by Microsoft. + """ + + FULL = "full" + MONITOR = "monitor" + + +class ArcKindEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates which kind of Arc machine placement on-premises, such as HCI, SCVMM or VMware etc.""" + + AVS = "AVS" + HCI = "HCI" + SCVMM = "SCVMM" + V_MWARE = "VMware" + EPS = "EPS" + GCP = "GCP" + AWS = "AWS" + + class AssessmentModeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the assessment mode.""" @@ -26,12 +47,144 @@ class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): KEY = "Key" +class EsuEligibility(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The ESU eligibility.""" + + ELIGIBLE = "Eligible" + INELIGIBLE = "Ineligible" + UNKNOWN = "Unknown" + + +class EsuKeyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The ESU key state.""" + + INACTIVE = "Inactive" + ACTIVE = "Active" + + +class EsuServerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The server types for Esu.""" + + STANDARD = "Standard" + DATACENTER = "Datacenter" + + +class ExecutionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Script execution status.""" + + UNKNOWN = "Unknown" + PENDING = "Pending" + RUNNING = "Running" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + TIMED_OUT = "TimedOut" + CANCELED = "Canceled" + + +class ExtensionsStatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The level code.""" + + INFO = "Info" + WARNING = "Warning" + ERROR = "Error" + + class InstanceViewTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """InstanceViewTypes.""" INSTANCE_VIEW = "instanceView" +class LastAttemptStatusEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the status of Agent Upgrade.""" + + SUCCESS = "Success" + FAILED = "Failed" + + +class LicenseAssignmentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Describes the license assignment state (Assigned or NotAssigned).""" + + ASSIGNED = "Assigned" + NOT_ASSIGNED = "NotAssigned" + + +class LicenseCoreType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Describes the license core type (pCore or vCore).""" + + P_CORE = "pCore" + V_CORE = "vCore" + + +class LicenseEdition(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Describes the edition of the license. The values are either Standard or Datacenter.""" + + STANDARD = "Standard" + DATACENTER = "Datacenter" + + +class LicenseProfileProductType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The product type of the license.""" + + WINDOWS_SERVER = "WindowsServer" + WINDOWS_IO_T_ENTERPRISE = "WindowsIoTEnterprise" + + +class LicenseProfileSubscriptionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Subscription status of the OS or Product feature.""" + + UNKNOWN = "Unknown" + ENABLING = "Enabling" + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class LicenseProfileSubscriptionStatusUpdate(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates the new subscription status of the OS or Product Features.""" + + ENABLE = "Enable" + DISABLE = "Disable" + + +class LicenseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Describes the state of the license.""" + + ACTIVATED = "Activated" + DEACTIVATED = "Deactivated" + + +class LicenseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The license status.""" + + UNLICENSED = "Unlicensed" + LICENSED = "Licensed" + OOB_GRACE = "OOBGrace" + OOT_GRACE = "OOTGrace" + NON_GENUINE_GRACE = "NonGenuineGrace" + NOTIFICATION = "Notification" + EXTENDED_GRACE = "ExtendedGrace" + + +class LicenseTarget(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Describes the license target server.""" + + WINDOWS_SERVER2012 = "Windows Server 2012" + WINDOWS_SERVER2012_R2 = "Windows Server 2012 R2" + + +class LicenseType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the license resource.""" + + ESU = "ESU" + + +class OsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operating system type of the machine.""" + + WINDOWS = "Windows" + LINUX = "Linux" + + class PatchModeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the patch mode.""" @@ -41,6 +194,50 @@ class PatchModeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): MANUAL = "Manual" +class PatchOperationStartedBy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates if operation was triggered by user or by platform.""" + + USER = "User" + PLATFORM = "Platform" + + +class PatchOperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The overall success or failure status of the operation. It remains "InProgress" until the + operation completes. At that point it will become "Unknown", "Failed", "Succeeded", or + "CompletedWithWarnings.". + """ + + UNKNOWN = "Unknown" + IN_PROGRESS = "InProgress" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + COMPLETED_WITH_WARNINGS = "CompletedWithWarnings" + + +class PatchServiceUsed(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the patch service used for the operation.""" + + UNKNOWN = "Unknown" + WU = "WU" + WU_WSUS = "WU_WSUS" + YUM = "YUM" + APT = "APT" + ZYPPER = "Zypper" + + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state, which only appears in the response.""" + + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + ACCEPTED = "Accepted" + CANCELED = "Canceled" + DELETED = "Deleted" + + class PublicNetworkAccessType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The network access policy to determine if Azure Arc agents can use public Azure Arc service endpoints. Defaults to disabled (access to Azure Arc services only via private link). @@ -68,3 +265,43 @@ class StatusTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): CONNECTED = "Connected" DISCONNECTED = "Disconnected" ERROR = "Error" + + +class VMGuestPatchClassificationLinux(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """VMGuestPatchClassificationLinux.""" + + CRITICAL = "Critical" + SECURITY = "Security" + OTHER = "Other" + + +class VMGuestPatchClassificationWindows(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """VMGuestPatchClassificationWindows.""" + + CRITICAL = "Critical" + SECURITY = "Security" + UPDATE_ROLL_UP = "UpdateRollUp" + FEATURE_PACK = "FeaturePack" + SERVICE_PACK = "ServicePack" + DEFINITION = "Definition" + TOOLS = "Tools" + UPDATES = "Updates" + + +class VMGuestPatchRebootSetting(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines when it is acceptable to reboot a VM during a software update operation.""" + + IF_REQUIRED = "IfRequired" + NEVER = "Never" + ALWAYS = "Always" + + +class VMGuestPatchRebootStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reboot state of the VM following completion of the operation.""" + + UNKNOWN = "Unknown" + NOT_NEEDED = "NotNeeded" + REQUIRED = "Required" + STARTED = "Started" + FAILED = "Failed" + COMPLETED = "Completed" diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/models/_models_py3.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/models/_models_py3.py index 1a98ef511fa2..e69a4850e25c 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/models/_models_py3.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/models/_models_py3.py @@ -13,10 +13,6 @@ from .. import _serialization -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports if sys.version_info >= (3, 8): from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports else: @@ -25,7 +21,6 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object class AgentConfiguration(_serialization.Model): @@ -51,6 +46,10 @@ class AgentConfiguration(_serialization.Model): :ivar guest_configuration_enabled: Specified whether the guest configuration service is enabled or disabled. :vartype guest_configuration_enabled: str + :ivar config_mode: Name of configuration mode to use. Modes are pre-defined configurations of + security controls, extension allowlists and guest configuration, maintained by Microsoft. Known + values are: "full" and "monitor". + :vartype config_mode: str or ~azure.mgmt.hybridcompute.models.AgentConfigurationMode """ _validation = { @@ -61,6 +60,7 @@ class AgentConfiguration(_serialization.Model): "proxy_bypass": {"readonly": True}, "extensions_enabled": {"readonly": True}, "guest_configuration_enabled": {"readonly": True}, + "config_mode": {"readonly": True}, } _attribute_map = { @@ -71,6 +71,7 @@ class AgentConfiguration(_serialization.Model): "proxy_bypass": {"key": "proxyBypass", "type": "[str]"}, "extensions_enabled": {"key": "extensionsEnabled", "type": "str"}, "guest_configuration_enabled": {"key": "guestConfigurationEnabled", "type": "str"}, + "config_mode": {"key": "configMode", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: @@ -83,6 +84,202 @@ def __init__(self, **kwargs: Any) -> None: self.proxy_bypass = None self.extensions_enabled = None self.guest_configuration_enabled = None + self.config_mode = None + + +class AgentUpgrade(_serialization.Model): + """The info w.r.t Agent Upgrade. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar desired_version: Specifies the version info w.r.t AgentUpgrade for the machine. + :vartype desired_version: str + :ivar correlation_id: The correlation ID passed in from RSM per upgrade. + :vartype correlation_id: str + :ivar enable_automatic_upgrade: Specifies if RSM should try to upgrade this machine. + :vartype enable_automatic_upgrade: bool + :ivar last_attempt_desired_version: Specifies the version of the last attempt. + :vartype last_attempt_desired_version: str + :ivar last_attempt_timestamp: Timestamp of last upgrade attempt. + :vartype last_attempt_timestamp: str + :ivar last_attempt_status: Specifies the status of Agent Upgrade. Known values are: "Success" + and "Failed". + :vartype last_attempt_status: str or ~azure.mgmt.hybridcompute.models.LastAttemptStatusEnum + :ivar last_attempt_message: Failure message of last upgrade attempt if any. + :vartype last_attempt_message: str + """ + + _validation = { + "last_attempt_desired_version": {"readonly": True}, + "last_attempt_timestamp": {"readonly": True}, + "last_attempt_status": {"readonly": True}, + "last_attempt_message": {"readonly": True}, + } + + _attribute_map = { + "desired_version": {"key": "desiredVersion", "type": "str"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "enable_automatic_upgrade": {"key": "enableAutomaticUpgrade", "type": "bool"}, + "last_attempt_desired_version": {"key": "lastAttemptDesiredVersion", "type": "str"}, + "last_attempt_timestamp": {"key": "lastAttemptTimestamp", "type": "str"}, + "last_attempt_status": {"key": "lastAttemptStatus", "type": "str"}, + "last_attempt_message": {"key": "lastAttemptMessage", "type": "str"}, + } + + def __init__( + self, + *, + desired_version: Optional[str] = None, + correlation_id: Optional[str] = None, + enable_automatic_upgrade: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword desired_version: Specifies the version info w.r.t AgentUpgrade for the machine. + :paramtype desired_version: str + :keyword correlation_id: The correlation ID passed in from RSM per upgrade. + :paramtype correlation_id: str + :keyword enable_automatic_upgrade: Specifies if RSM should try to upgrade this machine. + :paramtype enable_automatic_upgrade: bool + """ + super().__init__(**kwargs) + self.desired_version = desired_version + self.correlation_id = correlation_id + self.enable_automatic_upgrade = enable_automatic_upgrade + self.last_attempt_desired_version = None + self.last_attempt_timestamp = None + self.last_attempt_status = None + self.last_attempt_message = None + + +class AgentVersion(_serialization.Model): + """Describes properties of Agent Version. + + :ivar agent_version: Represents the agent version. + :vartype agent_version: str + :ivar download_link: Represents the download link of specific agent version. + :vartype download_link: str + :ivar os_type: Defines the os type. + :vartype os_type: str + """ + + _attribute_map = { + "agent_version": {"key": "agentVersion", "type": "str"}, + "download_link": {"key": "downloadLink", "type": "str"}, + "os_type": {"key": "osType", "type": "str"}, + } + + def __init__( + self, + *, + agent_version: Optional[str] = None, + download_link: Optional[str] = None, + os_type: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword agent_version: Represents the agent version. + :paramtype agent_version: str + :keyword download_link: Represents the download link of specific agent version. + :paramtype download_link: str + :keyword os_type: Defines the os type. + :paramtype os_type: str + """ + super().__init__(**kwargs) + self.agent_version = agent_version + self.download_link = download_link + self.os_type = os_type + + +class AgentVersionsList(_serialization.Model): + """Describes AgentVersions List. + + :ivar value: The list of available Agent Versions. + :vartype value: list[~azure.mgmt.hybridcompute.models.AgentVersion] + :ivar next_link: The URI to fetch the next 10 available Agent Versions. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[AgentVersion]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.AgentVersion"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The list of available Agent Versions. + :paramtype value: list[~azure.mgmt.hybridcompute.models.AgentVersion] + :keyword next_link: The URI to fetch the next 10 available Agent Versions. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AvailablePatchCountByClassification(_serialization.Model): + """Summarization of patches available for installation on the machine by classification. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar security: Number of security patches available for installation. + :vartype security: int + :ivar critical: Number of critical patches available for installation. + :vartype critical: int + :ivar definition: Number of definition patches available for installation. + :vartype definition: int + :ivar update_rollup: Number of update Rollup patches available for installation. + :vartype update_rollup: int + :ivar feature_pack: Number of feature pack patches available for installation. + :vartype feature_pack: int + :ivar service_pack: Number of service pack patches available for installation. + :vartype service_pack: int + :ivar tools: Number of tools patches available for installation. + :vartype tools: int + :ivar updates: Number of updates category patches available for installation. + :vartype updates: int + :ivar other: Number of other patches available for installation. + :vartype other: int + """ + + _validation = { + "security": {"readonly": True}, + "critical": {"readonly": True}, + "definition": {"readonly": True}, + "update_rollup": {"readonly": True}, + "feature_pack": {"readonly": True}, + "service_pack": {"readonly": True}, + "tools": {"readonly": True}, + "updates": {"readonly": True}, + "other": {"readonly": True}, + } + + _attribute_map = { + "security": {"key": "security", "type": "int"}, + "critical": {"key": "critical", "type": "int"}, + "definition": {"key": "definition", "type": "int"}, + "update_rollup": {"key": "updateRollup", "type": "int"}, + "feature_pack": {"key": "featurePack", "type": "int"}, + "service_pack": {"key": "servicePack", "type": "int"}, + "tools": {"key": "tools", "type": "int"}, + "updates": {"key": "updates", "type": "int"}, + "other": {"key": "other", "type": "int"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.security = None + self.critical = None + self.definition = None + self.update_rollup = None + self.feature_pack = None + self.service_pack = None + self.tools = None + self.updates = None + self.other = None class CloudMetadata(_serialization.Model): @@ -250,6 +447,49 @@ def __init__(self, **kwargs: Any) -> None: self.additional_info = None +class ErrorDetailAutoGenerated(_serialization.Model): + """The error detail. + + 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.hybridcompute.models.ErrorDetailAutoGenerated] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.hybridcompute.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetailAutoGenerated]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). @@ -271,6 +511,106 @@ def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: A self.error = error +class ErrorResponseAutoGenerated(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.hybridcompute.models.ErrorDetailAutoGenerated + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetailAutoGenerated"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetailAutoGenerated"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.hybridcompute.models.ErrorDetailAutoGenerated + """ + super().__init__(**kwargs) + self.error = error + + +class EsuKey(_serialization.Model): + """ESU key. + + :ivar sku: SKU number. + :vartype sku: str + :ivar license_status: The current status of the license profile key. + :vartype license_status: str + """ + + _attribute_map = { + "sku": {"key": "sku", "type": "str"}, + "license_status": {"key": "licenseStatus", "type": "str"}, + } + + def __init__(self, *, sku: Optional[str] = None, license_status: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword sku: SKU number. + :paramtype sku: str + :keyword license_status: The current status of the license profile key. + :paramtype license_status: str + """ + super().__init__(**kwargs) + self.sku = sku + self.license_status = license_status + + +class ExtensionsResourceStatus(_serialization.Model): + """Instance view status. + + :ivar code: The status code. + :vartype code: str + :ivar level: The level code. Known values are: "Info", "Warning", and "Error". + :vartype level: str or ~azure.mgmt.hybridcompute.models.ExtensionsStatusLevelTypes + :ivar display_status: The short localizable label for the status. + :vartype display_status: str + :ivar message: The detailed status message, including for alerts and error messages. + :vartype message: str + :ivar time: The time of the status. + :vartype time: ~datetime.datetime + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "level": {"key": "level", "type": "str"}, + "display_status": {"key": "displayStatus", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "time": {"key": "time", "type": "iso-8601"}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + level: Optional[Union[str, "_models.ExtensionsStatusLevelTypes"]] = None, + display_status: Optional[str] = None, + message: Optional[str] = None, + time: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword code: The status code. + :paramtype code: str + :keyword level: The level code. Known values are: "Info", "Warning", and "Error". + :paramtype level: str or ~azure.mgmt.hybridcompute.models.ExtensionsStatusLevelTypes + :keyword display_status: The short localizable label for the status. + :paramtype display_status: str + :keyword message: The detailed status message, including for alerts and error messages. + :paramtype message: str + :keyword time: The time of the status. + :paramtype time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.code = code + self.level = level + self.display_status = display_status + self.message = message + self.time = time + + class ExtensionTargetProperties(_serialization.Model): """Describes the Machine Extension Target Version Properties. @@ -291,73 +631,227 @@ def __init__(self, *, target_version: Optional[str] = None, **kwargs: Any) -> No self.target_version = target_version -class PrivateLinkScopesResource(_serialization.Model): - """An azure resource object. +class Resource(_serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. 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 Azure. - - :ivar id: Azure resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Azure resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Azure resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, - "location": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) self.id = None self.name = None self.type = None - self.location = location - self.tags = tags + self.system_data = None -class HybridComputePrivateLinkScope(PrivateLinkScopesResource): - """An Azure Arc PrivateLinkScope definition. +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Azure resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Azure resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar properties: Properties that define a Azure Arc PrivateLinkScope resource. + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + + +class ExtensionValue(ProxyResource): + """Describes a Extension Metadata. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData + :ivar version: The version of the Extension being received. + :vartype version: str + :ivar extension_type: The type of the Extension being received. + :vartype extension_type: str + :ivar publisher: The publisher of the Extension being received. + :vartype publisher: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "version": {"readonly": True}, + "extension_type": {"readonly": True}, + "publisher": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "version": {"key": "properties.version", "type": "str"}, + "extension_type": {"key": "properties.extensionType", "type": "str"}, + "publisher": {"key": "properties.publisher", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.version = None + self.extension_type = None + self.publisher = None + + +class ExtensionValueListResult(_serialization.Model): + """The List Extension Metadata response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of extension metadata. + :vartype value: list[~azure.mgmt.hybridcompute.models.ExtensionValue] + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ExtensionValue]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + + +class PrivateLinkScopesResource(_serialization.Model): + """An azure resource object. + + 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 Azure. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class HybridComputePrivateLinkScope(PrivateLinkScopesResource): + """An Azure Arc PrivateLinkScope definition. + + 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 Azure. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar properties: Properties that define a Azure Arc PrivateLinkScope resource. :vartype properties: ~azure.mgmt.hybridcompute.models.HybridComputePrivateLinkScopeProperties :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData @@ -490,6 +984,95 @@ def __init__( self.private_endpoint_connections = None +class HybridIdentityMetadata(ProxyResource): + """Defines the HybridIdentityMetadata. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData + :ivar vm_id: The unique identifier for the resource. + :vartype vm_id: str + :ivar public_key: The Public Key. + :vartype public_key: str + :ivar identity: Identity for the resource. + :vartype identity: ~azure.mgmt.hybridcompute.models.Identity + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "identity": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "vm_id": {"key": "properties.vmId", "type": "str"}, + "public_key": {"key": "properties.publicKey", "type": "str"}, + "identity": {"key": "properties.identity", "type": "Identity"}, + } + + def __init__(self, *, vm_id: Optional[str] = None, public_key: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword vm_id: The unique identifier for the resource. + :paramtype vm_id: str + :keyword public_key: The Public Key. + :paramtype public_key: str + """ + super().__init__(**kwargs) + self.vm_id = vm_id + self.public_key = public_key + self.identity = None + + +class HybridIdentityMetadataList(_serialization.Model): + """List of HybridIdentityMetadata. + + All required parameters must be populated in order to send to Azure. + + :ivar next_link: Url to follow for getting next page of HybridIdentityMetadata. + :vartype next_link: str + :ivar value: Array of HybridIdentityMetadata. Required. + :vartype value: list[~azure.mgmt.hybridcompute.models.HybridIdentityMetadata] + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[HybridIdentityMetadata]"}, + } + + def __init__( + self, *, value: List["_models.HybridIdentityMetadata"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword next_link: Url to follow for getting next page of HybridIdentityMetadata. + :paramtype next_link: str + :keyword value: Array of HybridIdentityMetadata. Required. + :paramtype value: list[~azure.mgmt.hybridcompute.models.HybridIdentityMetadata] + """ + super().__init__(**kwargs) + self.next_link = next_link + self.value = value + + class Identity(_serialization.Model): """Identity for the resource. @@ -525,63 +1108,52 @@ def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs self.type = type -class LocationData(_serialization.Model): - """Metadata pertaining to the geographic location of the resource. +class IpAddress(_serialization.Model): + """Describes properties of the IP address. - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: A canonical name for the geographic or physical location. Required. - :vartype name: str - :ivar city: The city or locality where the resource is located. - :vartype city: str - :ivar district: The district, state, or province where the resource is located. - :vartype district: str - :ivar country_or_region: The country or region where the resource is located. - :vartype country_or_region: str + :ivar address: Represents the IP Address. + :vartype address: str + :ivar ip_address_version: Represents the Ip Address Version. + :vartype ip_address_version: str + :ivar subnet: The subnet to which this IP address belongs. + :vartype subnet: ~azure.mgmt.hybridcompute.models.Subnet """ _validation = { - "name": {"required": True, "max_length": 256}, + "subnet": {"readonly": True}, } _attribute_map = { - "name": {"key": "name", "type": "str"}, - "city": {"key": "city", "type": "str"}, - "district": {"key": "district", "type": "str"}, - "country_or_region": {"key": "countryOrRegion", "type": "str"}, + "address": {"key": "address", "type": "str"}, + "ip_address_version": {"key": "ipAddressVersion", "type": "str"}, + "subnet": {"key": "subnet", "type": "Subnet"}, } def __init__( - self, - *, - name: str, - city: Optional[str] = None, - district: Optional[str] = None, - country_or_region: Optional[str] = None, - **kwargs: Any + self, *, address: Optional[str] = None, ip_address_version: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword name: A canonical name for the geographic or physical location. Required. - :paramtype name: str - :keyword city: The city or locality where the resource is located. - :paramtype city: str - :keyword district: The district, state, or province where the resource is located. - :paramtype district: str - :keyword country_or_region: The country or region where the resource is located. - :paramtype country_or_region: str + :keyword address: Represents the IP Address. + :paramtype address: str + :keyword ip_address_version: Represents the Ip Address Version. + :paramtype ip_address_version: str """ super().__init__(**kwargs) - self.name = name - self.city = city - self.district = district - self.country_or_region = country_or_region + self.address = address + self.ip_address_version = ip_address_version + self.subnet = None -class Resource(_serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which + has 'tags' and a 'location'. 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 Azure. + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str @@ -590,31 +1162,46 @@ class Resource(_serialization.Model): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - } + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + """ super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None + self.tags = tags + self.location = location -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which - has 'tags' and a 'location'. +class License(TrackedResource): + """Describes a license in a hybrid machine. Variables are only populated by the server, and will be ignored when sending a request. @@ -628,112 +1215,154 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. :vartype location: str + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Accepted", "Canceled", + and "Deleted". + :vartype provisioning_state: str or ~azure.mgmt.hybridcompute.models.ProvisioningState + :ivar tenant_id: Describes the tenant id. + :vartype tenant_id: str + :ivar license_type: The type of the license resource. "ESU" + :vartype license_type: str or ~azure.mgmt.hybridcompute.models.LicenseType + :ivar license_details: Describes the properties of a License. + :vartype license_details: ~azure.mgmt.hybridcompute.models.LicenseDetails """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, "location": {"key": "location", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "tenant_id": {"key": "properties.tenantId", "type": "str"}, + "license_type": {"key": "properties.licenseType", "type": "str"}, + "license_details": {"key": "properties.licenseDetails", "type": "LicenseDetails"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + tenant_id: Optional[str] = None, + license_type: Optional[Union[str, "_models.LicenseType"]] = None, + license_details: Optional["_models.LicenseDetails"] = None, + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword location: The geo-location where the resource lives. Required. :paramtype location: str + :keyword tenant_id: Describes the tenant id. + :paramtype tenant_id: str + :keyword license_type: The type of the license resource. "ESU" + :paramtype license_type: str or ~azure.mgmt.hybridcompute.models.LicenseType + :keyword license_details: Describes the properties of a License. + :paramtype license_details: ~azure.mgmt.hybridcompute.models.LicenseDetails """ - super().__init__(**kwargs) - self.tags = tags - self.location = location + super().__init__(tags=tags, location=location, **kwargs) + self.provisioning_state = None + self.tenant_id = tenant_id + self.license_type = license_type + self.license_details = license_details -class Machine(TrackedResource): - """Describes a hybrid machine. +class LicenseDetails(_serialization.Model): + """Describes the properties of a License. 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 Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar properties: Hybrid Compute Machine properties. - :vartype properties: ~azure.mgmt.hybridcompute.models.MachineProperties - :ivar identity: Identity for the resource. - :vartype identity: ~azure.mgmt.hybridcompute.models.Identity - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData + :ivar state: Describes the state of the license. Known values are: "Activated" and + "Deactivated". + :vartype state: str or ~azure.mgmt.hybridcompute.models.LicenseState + :ivar target: Describes the license target server. Known values are: "Windows Server 2012" and + "Windows Server 2012 R2". + :vartype target: str or ~azure.mgmt.hybridcompute.models.LicenseTarget + :ivar edition: Describes the edition of the license. The values are either Standard or + Datacenter. Known values are: "Standard" and "Datacenter". + :vartype edition: str or ~azure.mgmt.hybridcompute.models.LicenseEdition + :ivar type: Describes the license core type (pCore or vCore). Known values are: "pCore" and + "vCore". + :vartype type: str or ~azure.mgmt.hybridcompute.models.LicenseCoreType + :ivar processors: Describes the number of processors. + :vartype processors: int + :ivar assigned_licenses: Describes the number of assigned licenses. + :vartype assigned_licenses: int + :ivar immutable_id: Describes the immutable id. + :vartype immutable_id: str """ _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "system_data": {"readonly": True}, + "assigned_licenses": {"readonly": True}, + "immutable_id": {"readonly": True}, } _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "edition": {"key": "edition", "type": "str"}, "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - "properties": {"key": "properties", "type": "MachineProperties"}, - "identity": {"key": "identity", "type": "Identity"}, - "system_data": {"key": "systemData", "type": "SystemData"}, + "processors": {"key": "processors", "type": "int"}, + "assigned_licenses": {"key": "assignedLicenses", "type": "int"}, + "immutable_id": {"key": "immutableId", "type": "str"}, } def __init__( self, *, - location: str, - tags: Optional[Dict[str, str]] = None, - properties: Optional["_models.MachineProperties"] = None, - identity: Optional["_models.Identity"] = None, + state: Optional[Union[str, "_models.LicenseState"]] = None, + target: Optional[Union[str, "_models.LicenseTarget"]] = None, + edition: Optional[Union[str, "_models.LicenseEdition"]] = None, + type: Optional[Union[str, "_models.LicenseCoreType"]] = None, + processors: Optional[int] = None, **kwargs: Any ) -> None: """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword properties: Hybrid Compute Machine properties. - :paramtype properties: ~azure.mgmt.hybridcompute.models.MachineProperties - :keyword identity: Identity for the resource. - :paramtype identity: ~azure.mgmt.hybridcompute.models.Identity + :keyword state: Describes the state of the license. Known values are: "Activated" and + "Deactivated". + :paramtype state: str or ~azure.mgmt.hybridcompute.models.LicenseState + :keyword target: Describes the license target server. Known values are: "Windows Server 2012" + and "Windows Server 2012 R2". + :paramtype target: str or ~azure.mgmt.hybridcompute.models.LicenseTarget + :keyword edition: Describes the edition of the license. The values are either Standard or + Datacenter. Known values are: "Standard" and "Datacenter". + :paramtype edition: str or ~azure.mgmt.hybridcompute.models.LicenseEdition + :keyword type: Describes the license core type (pCore or vCore). Known values are: "pCore" and + "vCore". + :paramtype type: str or ~azure.mgmt.hybridcompute.models.LicenseCoreType + :keyword processors: Describes the number of processors. + :paramtype processors: int """ - super().__init__(tags=tags, location=location, **kwargs) - self.properties = properties - self.identity = identity - self.system_data = None + super().__init__(**kwargs) + self.state = state + self.target = target + self.edition = edition + self.type = type + self.processors = processors + self.assigned_licenses = None + self.immutable_id = None -class MachineExtension(TrackedResource): - """Describes a Machine Extension. +class LicenseProfile(TrackedResource): # pylint: disable=too-many-instance-attributes + """Describes a license profile in a hybrid machine. Variables are only populated by the server, and will be ignored when sending a request. @@ -747,32 +1376,92 @@ class MachineExtension(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. :vartype location: str - :ivar properties: Describes Machine Extension Properties. - :vartype properties: ~azure.mgmt.hybridcompute.models.MachineExtensionProperties - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Accepted", "Canceled", + and "Deleted". + :vartype provisioning_state: str or ~azure.mgmt.hybridcompute.models.ProvisioningState + :ivar subscription_status: Indicates the subscription status of the product. Known values are: + "Unknown", "Enabling", "Enabled", and "Disabled". + :vartype subscription_status: str or + ~azure.mgmt.hybridcompute.models.LicenseProfileSubscriptionStatus + :ivar product_type: Indicates the product type of the license. Known values are: + "WindowsServer" and "WindowsIoTEnterprise". + :vartype product_type: str or ~azure.mgmt.hybridcompute.models.LicenseProfileProductType + :ivar billing_start_date: The timestamp in UTC when the billing starts. + :vartype billing_start_date: ~datetime.datetime + :ivar enrollment_date: The timestamp in UTC when the user enrolls the feature. + :vartype enrollment_date: ~datetime.datetime + :ivar disenrollment_date: The timestamp in UTC when the user disenrolled the feature. + :vartype disenrollment_date: ~datetime.datetime + :ivar product_features: The list of product features. + :vartype product_features: list[~azure.mgmt.hybridcompute.models.ProductFeature] + :ivar assigned_license_immutable_id: The guid id of the license. + :vartype assigned_license_immutable_id: str + :ivar esu_keys: The list of ESU keys. + :vartype esu_keys: list[~azure.mgmt.hybridcompute.models.EsuKey] + :ivar server_type: The type of the Esu servers. Known values are: "Standard" and "Datacenter". + :vartype server_type: str or ~azure.mgmt.hybridcompute.models.EsuServerType + :ivar esu_eligibility: Indicates the eligibility state of Esu. Known values are: "Eligible", + "Ineligible", and "Unknown". + :vartype esu_eligibility: str or ~azure.mgmt.hybridcompute.models.EsuEligibility + :ivar esu_key_state: Indicates whether there is an ESU Key currently active for the machine. + Known values are: "Inactive" and "Active". + :vartype esu_key_state: str or ~azure.mgmt.hybridcompute.models.EsuKeyState + :ivar assigned_license: The resource id of the license. + :vartype assigned_license: str + :ivar software_assurance_customer: Specifies if this machine is licensed as part of a Software + Assurance agreement. + :vartype software_assurance_customer: bool """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, - "location": {"required": True}, "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "billing_start_date": {"readonly": True}, + "enrollment_date": {"readonly": True}, + "disenrollment_date": {"readonly": True}, + "assigned_license_immutable_id": {"readonly": True}, + "esu_keys": {"readonly": True}, + "server_type": {"readonly": True}, + "esu_eligibility": {"readonly": True}, + "esu_key_state": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, "location": {"key": "location", "type": "str"}, - "properties": {"key": "properties", "type": "MachineExtensionProperties"}, - "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "subscription_status": {"key": "properties.productProfile.subscriptionStatus", "type": "str"}, + "product_type": {"key": "properties.productProfile.productType", "type": "str"}, + "billing_start_date": {"key": "properties.productProfile.billingStartDate", "type": "iso-8601"}, + "enrollment_date": {"key": "properties.productProfile.enrollmentDate", "type": "iso-8601"}, + "disenrollment_date": {"key": "properties.productProfile.disenrollmentDate", "type": "iso-8601"}, + "product_features": {"key": "properties.productProfile.productFeatures", "type": "[ProductFeature]"}, + "assigned_license_immutable_id": {"key": "properties.esuProfile.assignedLicenseImmutableId", "type": "str"}, + "esu_keys": {"key": "properties.esuProfile.esuKeys", "type": "[EsuKey]"}, + "server_type": {"key": "properties.esuProfile.serverType", "type": "str"}, + "esu_eligibility": {"key": "properties.esuProfile.esuEligibility", "type": "str"}, + "esu_key_state": {"key": "properties.esuProfile.esuKeyState", "type": "str"}, + "assigned_license": {"key": "properties.esuProfile.assignedLicense", "type": "str"}, + "software_assurance_customer": { + "key": "properties.softwareAssurance.softwareAssuranceCustomer", + "type": "bool", + }, } def __init__( @@ -780,7 +1469,11 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - properties: Optional["_models.MachineExtensionProperties"] = None, + subscription_status: Optional[Union[str, "_models.LicenseProfileSubscriptionStatus"]] = None, + product_type: Optional[Union[str, "_models.LicenseProfileProductType"]] = None, + product_features: Optional[List["_models.ProductFeature"]] = None, + assigned_license: Optional[str] = None, + software_assurance_customer: Optional[bool] = None, **kwargs: Any ) -> None: """ @@ -788,241 +1481,342 @@ def __init__( :paramtype tags: dict[str, str] :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword properties: Describes Machine Extension Properties. - :paramtype properties: ~azure.mgmt.hybridcompute.models.MachineExtensionProperties + :keyword subscription_status: Indicates the subscription status of the product. Known values + are: "Unknown", "Enabling", "Enabled", and "Disabled". + :paramtype subscription_status: str or + ~azure.mgmt.hybridcompute.models.LicenseProfileSubscriptionStatus + :keyword product_type: Indicates the product type of the license. Known values are: + "WindowsServer" and "WindowsIoTEnterprise". + :paramtype product_type: str or ~azure.mgmt.hybridcompute.models.LicenseProfileProductType + :keyword product_features: The list of product features. + :paramtype product_features: list[~azure.mgmt.hybridcompute.models.ProductFeature] + :keyword assigned_license: The resource id of the license. + :paramtype assigned_license: str + :keyword software_assurance_customer: Specifies if this machine is licensed as part of a + Software Assurance agreement. + :paramtype software_assurance_customer: bool """ super().__init__(tags=tags, location=location, **kwargs) - self.properties = properties - self.system_data = None + self.provisioning_state = None + self.subscription_status = subscription_status + self.product_type = product_type + self.billing_start_date = None + self.enrollment_date = None + self.disenrollment_date = None + self.product_features = product_features + self.assigned_license_immutable_id = None + self.esu_keys = None + self.server_type = None + self.esu_eligibility = None + self.esu_key_state = None + self.assigned_license = assigned_license + self.software_assurance_customer = software_assurance_customer + + +class LicenseProfileStorageModelEsuProperties(_serialization.Model): + """License profile storage model for ESU properties. + Variables are only populated by the server, and will be ignored when sending a request. -class MachineExtensionInstanceView(_serialization.Model): - """Describes the Machine Extension Instance View. + :ivar assigned_license_immutable_id: The guid id of the license. + :vartype assigned_license_immutable_id: str + :ivar esu_keys: The list of ESU keys. + :vartype esu_keys: list[~azure.mgmt.hybridcompute.models.EsuKey] + """ - :ivar name: The machine extension name. - :vartype name: str - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar status: Instance view status. - :vartype status: ~azure.mgmt.hybridcompute.models.MachineExtensionInstanceViewStatus + _validation = { + "assigned_license_immutable_id": {"readonly": True}, + "esu_keys": {"readonly": True}, + } + + _attribute_map = { + "assigned_license_immutable_id": {"key": "assignedLicenseImmutableId", "type": "str"}, + "esu_keys": {"key": "esuKeys", "type": "[EsuKey]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.assigned_license_immutable_id = None + self.esu_keys = None + + +class LicenseProfileArmEsuPropertiesWithoutAssignedLicense(LicenseProfileStorageModelEsuProperties): + """Describes the properties of a License Profile ARM model. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar assigned_license_immutable_id: The guid id of the license. + :vartype assigned_license_immutable_id: str + :ivar esu_keys: The list of ESU keys. + :vartype esu_keys: list[~azure.mgmt.hybridcompute.models.EsuKey] + :ivar server_type: The type of the Esu servers. Known values are: "Standard" and "Datacenter". + :vartype server_type: str or ~azure.mgmt.hybridcompute.models.EsuServerType + :ivar esu_eligibility: Indicates the eligibility state of Esu. Known values are: "Eligible", + "Ineligible", and "Unknown". + :vartype esu_eligibility: str or ~azure.mgmt.hybridcompute.models.EsuEligibility + :ivar esu_key_state: Indicates whether there is an ESU Key currently active for the machine. + Known values are: "Inactive" and "Active". + :vartype esu_key_state: str or ~azure.mgmt.hybridcompute.models.EsuKeyState """ + _validation = { + "assigned_license_immutable_id": {"readonly": True}, + "esu_keys": {"readonly": True}, + "server_type": {"readonly": True}, + "esu_eligibility": {"readonly": True}, + "esu_key_state": {"readonly": True}, + } + _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, - "status": {"key": "status", "type": "MachineExtensionInstanceViewStatus"}, + "assigned_license_immutable_id": {"key": "assignedLicenseImmutableId", "type": "str"}, + "esu_keys": {"key": "esuKeys", "type": "[EsuKey]"}, + "server_type": {"key": "serverType", "type": "str"}, + "esu_eligibility": {"key": "esuEligibility", "type": "str"}, + "esu_key_state": {"key": "esuKeyState", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - status: Optional["_models.MachineExtensionInstanceViewStatus"] = None, - **kwargs: Any - ) -> None: + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.server_type = None + self.esu_eligibility = None + self.esu_key_state = None + + +class LicenseProfileArmEsuProperties(LicenseProfileArmEsuPropertiesWithoutAssignedLicense): + """Describes the properties of a License Profile ARM model. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar assigned_license_immutable_id: The guid id of the license. + :vartype assigned_license_immutable_id: str + :ivar esu_keys: The list of ESU keys. + :vartype esu_keys: list[~azure.mgmt.hybridcompute.models.EsuKey] + :ivar server_type: The type of the Esu servers. Known values are: "Standard" and "Datacenter". + :vartype server_type: str or ~azure.mgmt.hybridcompute.models.EsuServerType + :ivar esu_eligibility: Indicates the eligibility state of Esu. Known values are: "Eligible", + "Ineligible", and "Unknown". + :vartype esu_eligibility: str or ~azure.mgmt.hybridcompute.models.EsuEligibility + :ivar esu_key_state: Indicates whether there is an ESU Key currently active for the machine. + Known values are: "Inactive" and "Active". + :vartype esu_key_state: str or ~azure.mgmt.hybridcompute.models.EsuKeyState + :ivar assigned_license: The resource id of the license. + :vartype assigned_license: str + """ + + _validation = { + "assigned_license_immutable_id": {"readonly": True}, + "esu_keys": {"readonly": True}, + "server_type": {"readonly": True}, + "esu_eligibility": {"readonly": True}, + "esu_key_state": {"readonly": True}, + } + + _attribute_map = { + "assigned_license_immutable_id": {"key": "assignedLicenseImmutableId", "type": "str"}, + "esu_keys": {"key": "esuKeys", "type": "[EsuKey]"}, + "server_type": {"key": "serverType", "type": "str"}, + "esu_eligibility": {"key": "esuEligibility", "type": "str"}, + "esu_key_state": {"key": "esuKeyState", "type": "str"}, + "assigned_license": {"key": "assignedLicense", "type": "str"}, + } + + def __init__(self, *, assigned_license: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword name: The machine extension name. - :paramtype name: str - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword status: Instance view status. - :paramtype status: ~azure.mgmt.hybridcompute.models.MachineExtensionInstanceViewStatus + :keyword assigned_license: The resource id of the license. + :paramtype assigned_license: str """ super().__init__(**kwargs) - self.name = name - self.type = type - self.type_handler_version = type_handler_version - self.status = status + self.assigned_license = assigned_license -class MachineExtensionInstanceViewStatus(_serialization.Model): - """Instance view status. +class LicenseProfileMachineInstanceView(_serialization.Model): + """License Profile Instance View in Machine Properties. - :ivar code: The status code. - :vartype code: str - :ivar level: The level code. Known values are: "Info", "Warning", and "Error". - :vartype level: str or ~azure.mgmt.hybridcompute.models.StatusLevelTypes - :ivar display_status: The short localizable label for the status. - :vartype display_status: str - :ivar message: The detailed status message, including for alerts and error messages. - :vartype message: str - :ivar time: The time of the status. - :vartype time: ~datetime.datetime + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar license_status: Indicates the license status of the OS. Known values are: "Unlicensed", + "Licensed", "OOBGrace", "OOTGrace", "NonGenuineGrace", "Notification", and "ExtendedGrace". + :vartype license_status: str or ~azure.mgmt.hybridcompute.models.LicenseStatus + :ivar license_channel: Indicates the license channel. + :vartype license_channel: str + :ivar esu_profile: Properties for the Machine ESU profile. + :vartype esu_profile: + ~azure.mgmt.hybridcompute.models.LicenseProfileMachineInstanceViewEsuProperties + :ivar subscription_status: Indicates the subscription status of the product. Known values are: + "Unknown", "Enabling", "Enabled", and "Disabled". + :vartype subscription_status: str or + ~azure.mgmt.hybridcompute.models.LicenseProfileSubscriptionStatus + :ivar product_type: Indicates the product type of the license. Known values are: + "WindowsServer" and "WindowsIoTEnterprise". + :vartype product_type: str or ~azure.mgmt.hybridcompute.models.LicenseProfileProductType + :ivar billing_start_date: The timestamp in UTC when the billing starts. + :vartype billing_start_date: ~datetime.datetime + :ivar enrollment_date: The timestamp in UTC when the user enrolls the feature. + :vartype enrollment_date: ~datetime.datetime + :ivar disenrollment_date: The timestamp in UTC when the user disenrolled the feature. + :vartype disenrollment_date: ~datetime.datetime + :ivar product_features: The list of product features. + :vartype product_features: list[~azure.mgmt.hybridcompute.models.ProductFeature] + :ivar software_assurance_customer: Specifies if this machine is licensed as part of a Software + Assurance agreement. + :vartype software_assurance_customer: bool """ + _validation = { + "license_status": {"readonly": True}, + "license_channel": {"readonly": True}, + "billing_start_date": {"readonly": True}, + "enrollment_date": {"readonly": True}, + "disenrollment_date": {"readonly": True}, + } + _attribute_map = { - "code": {"key": "code", "type": "str"}, - "level": {"key": "level", "type": "str"}, - "display_status": {"key": "displayStatus", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "time": {"key": "time", "type": "iso-8601"}, + "license_status": {"key": "licenseStatus", "type": "str"}, + "license_channel": {"key": "licenseChannel", "type": "str"}, + "esu_profile": {"key": "esuProfile", "type": "LicenseProfileMachineInstanceViewEsuProperties"}, + "subscription_status": {"key": "productProfile.subscriptionStatus", "type": "str"}, + "product_type": {"key": "productProfile.productType", "type": "str"}, + "billing_start_date": {"key": "productProfile.billingStartDate", "type": "iso-8601"}, + "enrollment_date": {"key": "productProfile.enrollmentDate", "type": "iso-8601"}, + "disenrollment_date": {"key": "productProfile.disenrollmentDate", "type": "iso-8601"}, + "product_features": {"key": "productProfile.productFeatures", "type": "[ProductFeature]"}, + "software_assurance_customer": {"key": "softwareAssurance.softwareAssuranceCustomer", "type": "bool"}, } def __init__( self, *, - code: Optional[str] = None, - level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, - display_status: Optional[str] = None, - message: Optional[str] = None, - time: Optional[datetime.datetime] = None, + esu_profile: Optional["_models.LicenseProfileMachineInstanceViewEsuProperties"] = None, + subscription_status: Optional[Union[str, "_models.LicenseProfileSubscriptionStatus"]] = None, + product_type: Optional[Union[str, "_models.LicenseProfileProductType"]] = None, + product_features: Optional[List["_models.ProductFeature"]] = None, + software_assurance_customer: Optional[bool] = None, **kwargs: Any ) -> None: """ - :keyword code: The status code. - :paramtype code: str - :keyword level: The level code. Known values are: "Info", "Warning", and "Error". - :paramtype level: str or ~azure.mgmt.hybridcompute.models.StatusLevelTypes - :keyword display_status: The short localizable label for the status. - :paramtype display_status: str - :keyword message: The detailed status message, including for alerts and error messages. - :paramtype message: str - :keyword time: The time of the status. - :paramtype time: ~datetime.datetime + :keyword esu_profile: Properties for the Machine ESU profile. + :paramtype esu_profile: + ~azure.mgmt.hybridcompute.models.LicenseProfileMachineInstanceViewEsuProperties + :keyword subscription_status: Indicates the subscription status of the product. Known values + are: "Unknown", "Enabling", "Enabled", and "Disabled". + :paramtype subscription_status: str or + ~azure.mgmt.hybridcompute.models.LicenseProfileSubscriptionStatus + :keyword product_type: Indicates the product type of the license. Known values are: + "WindowsServer" and "WindowsIoTEnterprise". + :paramtype product_type: str or ~azure.mgmt.hybridcompute.models.LicenseProfileProductType + :keyword product_features: The list of product features. + :paramtype product_features: list[~azure.mgmt.hybridcompute.models.ProductFeature] + :keyword software_assurance_customer: Specifies if this machine is licensed as part of a + Software Assurance agreement. + :paramtype software_assurance_customer: bool """ super().__init__(**kwargs) - self.code = code - self.level = level - self.display_status = display_status - self.message = message - self.time = time + self.license_status = None + self.license_channel = None + self.esu_profile = esu_profile + self.subscription_status = subscription_status + self.product_type = product_type + self.billing_start_date = None + self.enrollment_date = None + self.disenrollment_date = None + self.product_features = product_features + self.software_assurance_customer = software_assurance_customer -class MachineExtensionProperties(_serialization.Model): - """Describes the properties of a Machine Extension. +class LicenseProfileMachineInstanceViewEsuProperties(LicenseProfileArmEsuPropertiesWithoutAssignedLicense): + """Properties for the Machine ESU profile. Variables are only populated by the server, and will be ignored when sending a request. - :ivar force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar enable_automatic_upgrade: Indicates whether the extension should be automatically - upgraded by the platform if there is a newer version available. - :vartype enable_automatic_upgrade: bool - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The machine extension instance view. - :vartype instance_view: ~azure.mgmt.hybridcompute.models.MachineExtensionInstanceView + :ivar assigned_license_immutable_id: The guid id of the license. + :vartype assigned_license_immutable_id: str + :ivar esu_keys: The list of ESU keys. + :vartype esu_keys: list[~azure.mgmt.hybridcompute.models.EsuKey] + :ivar server_type: The type of the Esu servers. Known values are: "Standard" and "Datacenter". + :vartype server_type: str or ~azure.mgmt.hybridcompute.models.EsuServerType + :ivar esu_eligibility: Indicates the eligibility state of Esu. Known values are: "Eligible", + "Ineligible", and "Unknown". + :vartype esu_eligibility: str or ~azure.mgmt.hybridcompute.models.EsuEligibility + :ivar esu_key_state: Indicates whether there is an ESU Key currently active for the machine. + Known values are: "Inactive" and "Active". + :vartype esu_key_state: str or ~azure.mgmt.hybridcompute.models.EsuKeyState + :ivar assigned_license: The assigned license resource. + :vartype assigned_license: ~azure.mgmt.hybridcompute.models.License + :ivar license_assignment_state: Describes the license assignment state (Assigned or + NotAssigned). Known values are: "Assigned" and "NotAssigned". + :vartype license_assignment_state: str or + ~azure.mgmt.hybridcompute.models.LicenseAssignmentState """ _validation = { - "provisioning_state": {"readonly": True}, + "assigned_license_immutable_id": {"readonly": True}, + "esu_keys": {"readonly": True}, + "server_type": {"readonly": True}, + "esu_eligibility": {"readonly": True}, + "esu_key_state": {"readonly": True}, } _attribute_map = { - "force_update_tag": {"key": "forceUpdateTag", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, - "enable_automatic_upgrade": {"key": "enableAutomaticUpgrade", "type": "bool"}, - "auto_upgrade_minor_version": {"key": "autoUpgradeMinorVersion", "type": "bool"}, - "settings": {"key": "settings", "type": "object"}, - "protected_settings": {"key": "protectedSettings", "type": "object"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "instance_view": {"key": "instanceView", "type": "MachineExtensionInstanceView"}, + "assigned_license_immutable_id": {"key": "assignedLicenseImmutableId", "type": "str"}, + "esu_keys": {"key": "esuKeys", "type": "[EsuKey]"}, + "server_type": {"key": "serverType", "type": "str"}, + "esu_eligibility": {"key": "esuEligibility", "type": "str"}, + "esu_key_state": {"key": "esuKeyState", "type": "str"}, + "assigned_license": {"key": "assignedLicense", "type": "License"}, + "license_assignment_state": {"key": "licenseAssignmentState", "type": "str"}, } def __init__( self, *, - force_update_tag: Optional[str] = None, - publisher: Optional[str] = None, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - enable_automatic_upgrade: Optional[bool] = None, - auto_upgrade_minor_version: Optional[bool] = None, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, - instance_view: Optional["_models.MachineExtensionInstanceView"] = None, + assigned_license: Optional["_models.License"] = None, + license_assignment_state: Optional[Union[str, "_models.LicenseAssignmentState"]] = None, **kwargs: Any ) -> None: """ - :keyword force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :paramtype force_update_tag: str - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword enable_automatic_upgrade: Indicates whether the extension should be automatically - upgraded by the platform if there is a newer version available. - :paramtype enable_automatic_upgrade: bool - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - :keyword instance_view: The machine extension instance view. - :paramtype instance_view: ~azure.mgmt.hybridcompute.models.MachineExtensionInstanceView + :keyword assigned_license: The assigned license resource. + :paramtype assigned_license: ~azure.mgmt.hybridcompute.models.License + :keyword license_assignment_state: Describes the license assignment state (Assigned or + NotAssigned). Known values are: "Assigned" and "NotAssigned". + :paramtype license_assignment_state: str or + ~azure.mgmt.hybridcompute.models.LicenseAssignmentState """ super().__init__(**kwargs) - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type = type - self.type_handler_version = type_handler_version - self.enable_automatic_upgrade = enable_automatic_upgrade - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.settings = settings - self.protected_settings = protected_settings - self.provisioning_state = None - self.instance_view = instance_view + self.assigned_license = assigned_license + self.license_assignment_state = license_assignment_state -class MachineExtensionsListResult(_serialization.Model): - """Describes the Machine Extensions List Result. +class LicenseProfilesListResult(_serialization.Model): + """The List hybrid machine license profile operation response. - :ivar value: The list of extensions. - :vartype value: list[~azure.mgmt.hybridcompute.models.MachineExtension] - :ivar next_link: The uri to fetch the next page of machine extensions. Call ListNext() with - this to fetch the next page of extensions. + All required parameters must be populated in order to send to Azure. + + :ivar value: The list of license profiles. Required. + :vartype value: list[~azure.mgmt.hybridcompute.models.LicenseProfile] + :ivar next_link: The URI to fetch the next page of Machines. Call ListNext() with this URI to + fetch the next page of license profile. :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { - "value": {"key": "value", "type": "[MachineExtension]"}, + "value": {"key": "value", "type": "[LicenseProfile]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.MachineExtension"]] = None, - next_link: Optional[str] = None, - **kwargs: Any + self, *, value: List["_models.LicenseProfile"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: The list of extensions. - :paramtype value: list[~azure.mgmt.hybridcompute.models.MachineExtension] - :keyword next_link: The uri to fetch the next page of machine extensions. Call ListNext() with - this to fetch the next page of extensions. + :keyword value: The list of license profiles. Required. + :paramtype value: list[~azure.mgmt.hybridcompute.models.LicenseProfile] + :keyword next_link: The URI to fetch the next page of Machines. Call ListNext() with this URI + to fetch the next page of license profile. :paramtype next_link: str """ super().__init__(**kwargs) @@ -1050,175 +1844,312 @@ def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> N self.tags = tags -class MachineExtensionUpdate(ResourceUpdate): - """Describes a Machine Extension Update. +class LicenseProfileUpdate(ResourceUpdate): + """Describes a License Profile Update. :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar properties: Describes Machine Extension Update Properties. - :vartype properties: ~azure.mgmt.hybridcompute.models.MachineExtensionUpdateProperties + :ivar subscription_status: Indicates the subscription status of the product. Known values are: + "Enable" and "Disable". + :vartype subscription_status: str or + ~azure.mgmt.hybridcompute.models.LicenseProfileSubscriptionStatusUpdate + :ivar product_type: Indicates the product type of the license. Known values are: + "WindowsServer" and "WindowsIoTEnterprise". + :vartype product_type: str or ~azure.mgmt.hybridcompute.models.LicenseProfileProductType + :ivar product_features: The list of product feature updates. + :vartype product_features: list[~azure.mgmt.hybridcompute.models.ProductFeatureUpdate] + :ivar assigned_license: The resource id of the license. + :vartype assigned_license: str + :ivar software_assurance_customer: Specifies if this machine is licensed as part of a Software + Assurance agreement. + :vartype software_assurance_customer: bool """ _attribute_map = { "tags": {"key": "tags", "type": "{str}"}, - "properties": {"key": "properties", "type": "MachineExtensionUpdateProperties"}, + "subscription_status": {"key": "properties.productProfile.subscriptionStatus", "type": "str"}, + "product_type": {"key": "properties.productProfile.productType", "type": "str"}, + "product_features": {"key": "properties.productProfile.productFeatures", "type": "[ProductFeatureUpdate]"}, + "assigned_license": {"key": "properties.esuProfile.assignedLicense", "type": "str"}, + "software_assurance_customer": { + "key": "properties.softwareAssurance.softwareAssuranceCustomer", + "type": "bool", + }, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - properties: Optional["_models.MachineExtensionUpdateProperties"] = None, + subscription_status: Optional[Union[str, "_models.LicenseProfileSubscriptionStatusUpdate"]] = None, + product_type: Optional[Union[str, "_models.LicenseProfileProductType"]] = None, + product_features: Optional[List["_models.ProductFeatureUpdate"]] = None, + assigned_license: Optional[str] = None, + software_assurance_customer: Optional[bool] = None, **kwargs: Any ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword properties: Describes Machine Extension Update Properties. - :paramtype properties: ~azure.mgmt.hybridcompute.models.MachineExtensionUpdateProperties + :keyword subscription_status: Indicates the subscription status of the product. Known values + are: "Enable" and "Disable". + :paramtype subscription_status: str or + ~azure.mgmt.hybridcompute.models.LicenseProfileSubscriptionStatusUpdate + :keyword product_type: Indicates the product type of the license. Known values are: + "WindowsServer" and "WindowsIoTEnterprise". + :paramtype product_type: str or ~azure.mgmt.hybridcompute.models.LicenseProfileProductType + :keyword product_features: The list of product feature updates. + :paramtype product_features: list[~azure.mgmt.hybridcompute.models.ProductFeatureUpdate] + :keyword assigned_license: The resource id of the license. + :paramtype assigned_license: str + :keyword software_assurance_customer: Specifies if this machine is licensed as part of a + Software Assurance agreement. + :paramtype software_assurance_customer: bool """ super().__init__(tags=tags, **kwargs) - self.properties = properties + self.subscription_status = subscription_status + self.product_type = product_type + self.product_features = product_features + self.assigned_license = assigned_license + self.software_assurance_customer = software_assurance_customer -class MachineExtensionUpdateProperties(_serialization.Model): - """Describes the properties of a Machine Extension. +class LicensesListResult(_serialization.Model): + """The List license operation response. - :ivar force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON + All required parameters must be populated in order to send to Azure. + + :ivar value: The list of licenses. Required. + :vartype value: list[~azure.mgmt.hybridcompute.models.License] + :ivar next_link: The URI to fetch the next page of Machines. Call ListNext() with this URI to + fetch the next page of license profile. + :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { - "force_update_tag": {"key": "forceUpdateTag", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "autoUpgradeMinorVersion", "type": "bool"}, - "settings": {"key": "settings", "type": "object"}, - "protected_settings": {"key": "protectedSettings", "type": "object"}, + "value": {"key": "value", "type": "[License]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.License"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: The list of licenses. Required. + :paramtype value: list[~azure.mgmt.hybridcompute.models.License] + :keyword next_link: The URI to fetch the next page of Machines. Call ListNext() with this URI + to fetch the next page of license profile. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class LicenseUpdate(ResourceUpdate): + """Describes a License Update. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar license_type: The type of the license resource. "ESU" + :vartype license_type: str or ~azure.mgmt.hybridcompute.models.LicenseType + :ivar state: Describes the state of the license. Known values are: "Activated" and + "Deactivated". + :vartype state: str or ~azure.mgmt.hybridcompute.models.LicenseState + :ivar target: Describes the license target server. Known values are: "Windows Server 2012" and + "Windows Server 2012 R2". + :vartype target: str or ~azure.mgmt.hybridcompute.models.LicenseTarget + :ivar edition: Describes the edition of the license. The values are either Standard or + Datacenter. Known values are: "Standard" and "Datacenter". + :vartype edition: str or ~azure.mgmt.hybridcompute.models.LicenseEdition + :ivar type: Describes the license core type (pCore or vCore). Known values are: "pCore" and + "vCore". + :vartype type: str or ~azure.mgmt.hybridcompute.models.LicenseCoreType + :ivar processors: Describes the number of processors. + :vartype processors: int + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "license_type": {"key": "properties.licenseType", "type": "str"}, + "state": {"key": "properties.licenseDetails.state", "type": "str"}, + "target": {"key": "properties.licenseDetails.target", "type": "str"}, + "edition": {"key": "properties.licenseDetails.edition", "type": "str"}, + "type": {"key": "properties.licenseDetails.type", "type": "str"}, + "processors": {"key": "properties.licenseDetails.processors", "type": "int"}, } def __init__( self, *, - force_update_tag: Optional[str] = None, - publisher: Optional[str] = None, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - auto_upgrade_minor_version: Optional[bool] = None, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, + tags: Optional[Dict[str, str]] = None, + license_type: Optional[Union[str, "_models.LicenseType"]] = None, + state: Optional[Union[str, "_models.LicenseState"]] = None, + target: Optional[Union[str, "_models.LicenseTarget"]] = None, + edition: Optional[Union[str, "_models.LicenseEdition"]] = None, + type: Optional[Union[str, "_models.LicenseCoreType"]] = None, + processors: Optional[int] = None, **kwargs: Any ) -> None: """ - :keyword force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :paramtype force_update_tag: str - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword license_type: The type of the license resource. "ESU" + :paramtype license_type: str or ~azure.mgmt.hybridcompute.models.LicenseType + :keyword state: Describes the state of the license. Known values are: "Activated" and + "Deactivated". + :paramtype state: str or ~azure.mgmt.hybridcompute.models.LicenseState + :keyword target: Describes the license target server. Known values are: "Windows Server 2012" + and "Windows Server 2012 R2". + :paramtype target: str or ~azure.mgmt.hybridcompute.models.LicenseTarget + :keyword edition: Describes the edition of the license. The values are either Standard or + Datacenter. Known values are: "Standard" and "Datacenter". + :paramtype edition: str or ~azure.mgmt.hybridcompute.models.LicenseEdition + :keyword type: Describes the license core type (pCore or vCore). Known values are: "pCore" and + "vCore". + :paramtype type: str or ~azure.mgmt.hybridcompute.models.LicenseCoreType + :keyword processors: Describes the number of processors. + :paramtype processors: int """ - super().__init__(**kwargs) - self.force_update_tag = force_update_tag - self.publisher = publisher + super().__init__(tags=tags, **kwargs) + self.license_type = license_type + self.state = state + self.target = target + self.edition = edition self.type = type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.settings = settings - self.protected_settings = protected_settings - - -class MachineExtensionUpgrade(_serialization.Model): - """Describes the Machine Extension Upgrade Properties. - - :ivar extension_targets: Describes the Extension Target Properties. - :vartype extension_targets: dict[str, - ~azure.mgmt.hybridcompute.models.ExtensionTargetProperties] + self.processors = processors + + +class LinuxParameters(_serialization.Model): + """Input for InstallPatches on a Linux VM, as directly received by the API. + + :ivar classifications_to_include: The update classifications to select when installing patches + for Linux. + :vartype classifications_to_include: list[str or + ~azure.mgmt.hybridcompute.models.VMGuestPatchClassificationLinux] + :ivar package_name_masks_to_include: packages to include in the patch operation. Format: + packageName_packageVersion. + :vartype package_name_masks_to_include: list[str] + :ivar package_name_masks_to_exclude: packages to exclude in the patch operation. Format: + packageName_packageVersion. + :vartype package_name_masks_to_exclude: list[str] """ _attribute_map = { - "extension_targets": {"key": "extensionTargets", "type": "{ExtensionTargetProperties}"}, + "classifications_to_include": {"key": "classificationsToInclude", "type": "[str]"}, + "package_name_masks_to_include": {"key": "packageNameMasksToInclude", "type": "[str]"}, + "package_name_masks_to_exclude": {"key": "packageNameMasksToExclude", "type": "[str]"}, } def __init__( - self, *, extension_targets: Optional[Dict[str, "_models.ExtensionTargetProperties"]] = None, **kwargs: Any + self, + *, + classifications_to_include: Optional[List[Union[str, "_models.VMGuestPatchClassificationLinux"]]] = None, + package_name_masks_to_include: Optional[List[str]] = None, + package_name_masks_to_exclude: Optional[List[str]] = None, + **kwargs: Any ) -> None: """ - :keyword extension_targets: Describes the Extension Target Properties. - :paramtype extension_targets: dict[str, - ~azure.mgmt.hybridcompute.models.ExtensionTargetProperties] + :keyword classifications_to_include: The update classifications to select when installing + patches for Linux. + :paramtype classifications_to_include: list[str or + ~azure.mgmt.hybridcompute.models.VMGuestPatchClassificationLinux] + :keyword package_name_masks_to_include: packages to include in the patch operation. Format: + packageName_packageVersion. + :paramtype package_name_masks_to_include: list[str] + :keyword package_name_masks_to_exclude: packages to exclude in the patch operation. Format: + packageName_packageVersion. + :paramtype package_name_masks_to_exclude: list[str] """ super().__init__(**kwargs) - self.extension_targets = extension_targets + self.classifications_to_include = classifications_to_include + self.package_name_masks_to_include = package_name_masks_to_include + self.package_name_masks_to_exclude = package_name_masks_to_exclude -class MachineListResult(_serialization.Model): - """The List hybrid machine operation response. +class LocationData(_serialization.Model): + """Metadata pertaining to the geographic location of the resource. All required parameters must be populated in order to send to Azure. - :ivar value: The list of hybrid machines. Required. - :vartype value: list[~azure.mgmt.hybridcompute.models.Machine] - :ivar next_link: The URI to fetch the next page of Machines. Call ListNext() with this URI to - fetch the next page of hybrid machines. - :vartype next_link: str + :ivar name: A canonical name for the geographic or physical location. Required. + :vartype name: str + :ivar city: The city or locality where the resource is located. + :vartype city: str + :ivar district: The district, state, or province where the resource is located. + :vartype district: str + :ivar country_or_region: The country or region where the resource is located. + :vartype country_or_region: str """ _validation = { - "value": {"required": True}, + "name": {"required": True, "max_length": 256}, } _attribute_map = { - "value": {"key": "value", "type": "[Machine]"}, - "next_link": {"key": "nextLink", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "city": {"key": "city", "type": "str"}, + "district": {"key": "district", "type": "str"}, + "country_or_region": {"key": "countryOrRegion", "type": "str"}, } - def __init__(self, *, value: List["_models.Machine"], next_link: Optional[str] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + name: str, + city: Optional[str] = None, + district: Optional[str] = None, + country_or_region: Optional[str] = None, + **kwargs: Any + ) -> None: """ - :keyword value: The list of hybrid machines. Required. - :paramtype value: list[~azure.mgmt.hybridcompute.models.Machine] - :keyword next_link: The URI to fetch the next page of Machines. Call ListNext() with this URI - to fetch the next page of hybrid machines. - :paramtype next_link: str + :keyword name: A canonical name for the geographic or physical location. Required. + :paramtype name: str + :keyword city: The city or locality where the resource is located. + :paramtype city: str + :keyword district: The district, state, or province where the resource is located. + :paramtype district: str + :keyword country_or_region: The country or region where the resource is located. + :paramtype country_or_region: str """ super().__init__(**kwargs) - self.value = value - self.next_link = next_link + self.name = name + self.city = city + self.district = district + self.country_or_region = country_or_region -class MachineProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Describes the properties of a hybrid machine. +class Machine(TrackedResource): # pylint: disable=too-many-instance-attributes + """Describes a hybrid machine. 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 Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar resources: The list of extensions affiliated to the machine. + :vartype resources: list[~azure.mgmt.hybridcompute.models.MachineExtension] + :ivar identity: Identity for the resource. + :vartype identity: ~azure.mgmt.hybridcompute.models.Identity + :ivar kind: Indicates which kind of Arc machine placement on-premises, such as HCI, SCVMM or + VMware etc. Known values are: "AVS", "HCI", "SCVMM", "VMware", "EPS", "GCP", and "AWS". + :vartype kind: str or ~azure.mgmt.hybridcompute.models.ArcKindEnum :ivar location_data: Metadata pertaining to the geographic location of the resource. :vartype location_data: ~azure.mgmt.hybridcompute.models.LocationData :ivar agent_configuration: Configurable properties that the user can set locally via the @@ -1228,8 +2159,12 @@ class MachineProperties(_serialization.Model): # pylint: disable=too-many-insta :vartype service_statuses: ~azure.mgmt.hybridcompute.models.ServiceStatuses :ivar cloud_metadata: The metadata of the cloud environment (Azure/GCP/AWS/OCI...). :vartype cloud_metadata: ~azure.mgmt.hybridcompute.models.CloudMetadata + :ivar agent_upgrade: The info of the machine w.r.t Agent Upgrade. + :vartype agent_upgrade: ~azure.mgmt.hybridcompute.models.AgentUpgrade :ivar os_profile: Specifies the operating system settings for the hybrid machine. :vartype os_profile: ~azure.mgmt.hybridcompute.models.OSProfile + :ivar license_profile: Specifies the License related properties for a machine. + :vartype license_profile: ~azure.mgmt.hybridcompute.models.LicenseProfileMachineInstanceView :ivar provisioning_state: The provisioning state, which only appears in the response. :vartype provisioning_state: str :ivar status: The status of the hybrid machine agent. Known values are: "Connected", @@ -1258,10 +2193,12 @@ class MachineProperties(_serialization.Model): # pylint: disable=too-many-insta :vartype os_type: str :ivar vm_uuid: Specifies the Arc Machine's unique SMBIOS ID. :vartype vm_uuid: str - :ivar extensions: Machine Extensions information. + :ivar extensions: Machine Extensions information (deprecated field). :vartype extensions: list[~azure.mgmt.hybridcompute.models.MachineExtensionInstanceView] :ivar os_sku: Specifies the Operating System product SKU. :vartype os_sku: str + :ivar os_edition: The edition of the Operating System. + :vartype os_edition: str :ivar domain_name: Specifies the Windows domain name. :vartype domain_name: str :ivar ad_fqdn: Specifies the AD fully qualified display name. @@ -1278,9 +2215,17 @@ class MachineProperties(_serialization.Model): # pylint: disable=too-many-insta :vartype mssql_discovered: str :ivar detected_properties: Detected properties from the machine. :vartype detected_properties: dict[str, str] + :ivar network_profile: Information about the network the machine is on. + :vartype network_profile: ~azure.mgmt.hybridcompute.models.NetworkProfile """ _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "resources": {"readonly": True}, "agent_configuration": {"readonly": True}, "provisioning_state": {"readonly": True}, "status": {"readonly": True}, @@ -1293,49 +2238,70 @@ class MachineProperties(_serialization.Model): # pylint: disable=too-many-insta "os_version": {"readonly": True}, "vm_uuid": {"readonly": True}, "os_sku": {"readonly": True}, + "os_edition": {"readonly": True}, "domain_name": {"readonly": True}, "ad_fqdn": {"readonly": True}, "dns_fqdn": {"readonly": True}, "detected_properties": {"readonly": True}, + "network_profile": {"readonly": True}, } _attribute_map = { - "location_data": {"key": "locationData", "type": "LocationData"}, - "agent_configuration": {"key": "agentConfiguration", "type": "AgentConfiguration"}, - "service_statuses": {"key": "serviceStatuses", "type": "ServiceStatuses"}, - "cloud_metadata": {"key": "cloudMetadata", "type": "CloudMetadata"}, - "os_profile": {"key": "osProfile", "type": "OSProfile"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "last_status_change": {"key": "lastStatusChange", "type": "iso-8601"}, - "error_details": {"key": "errorDetails", "type": "[ErrorDetail]"}, - "agent_version": {"key": "agentVersion", "type": "str"}, - "vm_id": {"key": "vmId", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "machine_fqdn": {"key": "machineFqdn", "type": "str"}, - "client_public_key": {"key": "clientPublicKey", "type": "str"}, - "os_name": {"key": "osName", "type": "str"}, - "os_version": {"key": "osVersion", "type": "str"}, - "os_type": {"key": "osType", "type": "str"}, - "vm_uuid": {"key": "vmUuid", "type": "str"}, - "extensions": {"key": "extensions", "type": "[MachineExtensionInstanceView]"}, - "os_sku": {"key": "osSku", "type": "str"}, - "domain_name": {"key": "domainName", "type": "str"}, - "ad_fqdn": {"key": "adFqdn", "type": "str"}, - "dns_fqdn": {"key": "dnsFqdn", "type": "str"}, - "private_link_scope_resource_id": {"key": "privateLinkScopeResourceId", "type": "str"}, - "parent_cluster_resource_id": {"key": "parentClusterResourceId", "type": "str"}, - "mssql_discovered": {"key": "mssqlDiscovered", "type": "str"}, - "detected_properties": {"key": "detectedProperties", "type": "{str}"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "resources": {"key": "resources", "type": "[MachineExtension]"}, + "identity": {"key": "identity", "type": "Identity"}, + "kind": {"key": "kind", "type": "str"}, + "location_data": {"key": "properties.locationData", "type": "LocationData"}, + "agent_configuration": {"key": "properties.agentConfiguration", "type": "AgentConfiguration"}, + "service_statuses": {"key": "properties.serviceStatuses", "type": "ServiceStatuses"}, + "cloud_metadata": {"key": "properties.cloudMetadata", "type": "CloudMetadata"}, + "agent_upgrade": {"key": "properties.agentUpgrade", "type": "AgentUpgrade"}, + "os_profile": {"key": "properties.osProfile", "type": "OSProfile"}, + "license_profile": {"key": "properties.licenseProfile", "type": "LicenseProfileMachineInstanceView"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "last_status_change": {"key": "properties.lastStatusChange", "type": "iso-8601"}, + "error_details": {"key": "properties.errorDetails", "type": "[ErrorDetail]"}, + "agent_version": {"key": "properties.agentVersion", "type": "str"}, + "vm_id": {"key": "properties.vmId", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "machine_fqdn": {"key": "properties.machineFqdn", "type": "str"}, + "client_public_key": {"key": "properties.clientPublicKey", "type": "str"}, + "os_name": {"key": "properties.osName", "type": "str"}, + "os_version": {"key": "properties.osVersion", "type": "str"}, + "os_type": {"key": "properties.osType", "type": "str"}, + "vm_uuid": {"key": "properties.vmUuid", "type": "str"}, + "extensions": {"key": "properties.extensions", "type": "[MachineExtensionInstanceView]"}, + "os_sku": {"key": "properties.osSku", "type": "str"}, + "os_edition": {"key": "properties.osEdition", "type": "str"}, + "domain_name": {"key": "properties.domainName", "type": "str"}, + "ad_fqdn": {"key": "properties.adFqdn", "type": "str"}, + "dns_fqdn": {"key": "properties.dnsFqdn", "type": "str"}, + "private_link_scope_resource_id": {"key": "properties.privateLinkScopeResourceId", "type": "str"}, + "parent_cluster_resource_id": {"key": "properties.parentClusterResourceId", "type": "str"}, + "mssql_discovered": {"key": "properties.mssqlDiscovered", "type": "str"}, + "detected_properties": {"key": "properties.detectedProperties", "type": "{str}"}, + "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, } def __init__( # pylint: disable=too-many-locals self, *, + location: str, + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.Identity"] = None, + kind: Optional[Union[str, "_models.ArcKindEnum"]] = None, location_data: Optional["_models.LocationData"] = None, service_statuses: Optional["_models.ServiceStatuses"] = None, cloud_metadata: Optional["_models.CloudMetadata"] = None, + agent_upgrade: Optional["_models.AgentUpgrade"] = None, os_profile: Optional["_models.OSProfile"] = None, + license_profile: Optional["_models.LicenseProfileMachineInstanceView"] = None, vm_id: Optional[str] = None, client_public_key: Optional[str] = None, os_type: Optional[str] = None, @@ -1346,14 +2312,27 @@ def __init__( # pylint: disable=too-many-locals **kwargs: Any ) -> None: """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword identity: Identity for the resource. + :paramtype identity: ~azure.mgmt.hybridcompute.models.Identity + :keyword kind: Indicates which kind of Arc machine placement on-premises, such as HCI, SCVMM or + VMware etc. Known values are: "AVS", "HCI", "SCVMM", "VMware", "EPS", "GCP", and "AWS". + :paramtype kind: str or ~azure.mgmt.hybridcompute.models.ArcKindEnum :keyword location_data: Metadata pertaining to the geographic location of the resource. :paramtype location_data: ~azure.mgmt.hybridcompute.models.LocationData :keyword service_statuses: Statuses of dependent services that are reported back to ARM. :paramtype service_statuses: ~azure.mgmt.hybridcompute.models.ServiceStatuses :keyword cloud_metadata: The metadata of the cloud environment (Azure/GCP/AWS/OCI...). :paramtype cloud_metadata: ~azure.mgmt.hybridcompute.models.CloudMetadata + :keyword agent_upgrade: The info of the machine w.r.t Agent Upgrade. + :paramtype agent_upgrade: ~azure.mgmt.hybridcompute.models.AgentUpgrade :keyword os_profile: Specifies the operating system settings for the hybrid machine. :paramtype os_profile: ~azure.mgmt.hybridcompute.models.OSProfile + :keyword license_profile: Specifies the License related properties for a machine. + :paramtype license_profile: ~azure.mgmt.hybridcompute.models.LicenseProfileMachineInstanceView :keyword vm_id: Specifies the hybrid machine unique ID. :paramtype vm_id: str :keyword client_public_key: Public Key that the client provides to be used during initial @@ -1361,7 +2340,7 @@ def __init__( # pylint: disable=too-many-locals :paramtype client_public_key: str :keyword os_type: The type of Operating System (windows/linux). :paramtype os_type: str - :keyword extensions: Machine Extensions information. + :keyword extensions: Machine Extensions information (deprecated field). :paramtype extensions: list[~azure.mgmt.hybridcompute.models.MachineExtensionInstanceView] :keyword private_link_scope_resource_id: The resource id of the private link scope this machine is assigned to, if any. @@ -1372,83 +2351,1142 @@ def __init__( # pylint: disable=too-many-locals :keyword mssql_discovered: Specifies whether any MS SQL instance is discovered on the machine. :paramtype mssql_discovered: str """ + super().__init__(tags=tags, location=location, **kwargs) + self.resources = None + self.identity = identity + self.kind = kind + self.location_data = location_data + self.agent_configuration = None + self.service_statuses = service_statuses + self.cloud_metadata = cloud_metadata + self.agent_upgrade = agent_upgrade + self.os_profile = os_profile + self.license_profile = license_profile + self.provisioning_state = None + self.status = None + self.last_status_change = None + self.error_details = None + self.agent_version = None + self.vm_id = vm_id + self.display_name = None + self.machine_fqdn = None + self.client_public_key = client_public_key + self.os_name = None + self.os_version = None + self.os_type = os_type + self.vm_uuid = None + self.extensions = extensions + self.os_sku = None + self.os_edition = None + self.domain_name = None + self.ad_fqdn = None + self.dns_fqdn = None + self.private_link_scope_resource_id = private_link_scope_resource_id + self.parent_cluster_resource_id = parent_cluster_resource_id + self.mssql_discovered = mssql_discovered + self.detected_properties = None + self.network_profile = None + + +class MachineAssessPatchesResult(_serialization.Model): + """Describes the properties of an AssessPatches result. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: The overall success or failure status of the operation. It remains "InProgress" + until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", + or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + and "CompletedWithWarnings". + :vartype status: str or ~azure.mgmt.hybridcompute.models.PatchOperationStatus + :ivar assessment_activity_id: The activity ID of the operation that produced this result. + :vartype assessment_activity_id: str + :ivar reboot_pending: The overall reboot status of the VM. It will be true when partially + installed patches require a reboot to complete installation but the reboot has not yet + occurred. + :vartype reboot_pending: bool + :ivar available_patch_count_by_classification: Summarization of patches available for + installation on the machine by classification. + :vartype available_patch_count_by_classification: + ~azure.mgmt.hybridcompute.models.AvailablePatchCountByClassification + :ivar start_date_time: The UTC timestamp when the operation began. + :vartype start_date_time: ~datetime.datetime + :ivar last_modified_date_time: The UTC timestamp when the operation finished. + :vartype last_modified_date_time: ~datetime.datetime + :ivar started_by: Indicates if operation was triggered by user or by platform. Known values + are: "User" and "Platform". + :vartype started_by: str or ~azure.mgmt.hybridcompute.models.PatchOperationStartedBy + :ivar patch_service_used: Specifies the patch service used for the operation. Known values are: + "Unknown", "WU", "WU_WSUS", "YUM", "APT", and "Zypper". + :vartype patch_service_used: str or ~azure.mgmt.hybridcompute.models.PatchServiceUsed + :ivar os_type: The operating system type of the machine. Known values are: "Windows" and + "Linux". + :vartype os_type: str or ~azure.mgmt.hybridcompute.models.OsType + :ivar error_details: The errors that were encountered during execution of the operation. The + details array contains the list of them. + :vartype error_details: ~azure.mgmt.hybridcompute.models.ErrorDetail + """ + + _validation = { + "status": {"readonly": True}, + "assessment_activity_id": {"readonly": True}, + "reboot_pending": {"readonly": True}, + "start_date_time": {"readonly": True}, + "last_modified_date_time": {"readonly": True}, + "started_by": {"readonly": True}, + "patch_service_used": {"readonly": True}, + "os_type": {"readonly": True}, + "error_details": {"readonly": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "assessment_activity_id": {"key": "assessmentActivityId", "type": "str"}, + "reboot_pending": {"key": "rebootPending", "type": "bool"}, + "available_patch_count_by_classification": { + "key": "availablePatchCountByClassification", + "type": "AvailablePatchCountByClassification", + }, + "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, + "last_modified_date_time": {"key": "lastModifiedDateTime", "type": "iso-8601"}, + "started_by": {"key": "startedBy", "type": "str"}, + "patch_service_used": {"key": "patchServiceUsed", "type": "str"}, + "os_type": {"key": "osType", "type": "str"}, + "error_details": {"key": "errorDetails", "type": "ErrorDetail"}, + } + + def __init__( + self, + *, + available_patch_count_by_classification: Optional["_models.AvailablePatchCountByClassification"] = None, + **kwargs: Any + ) -> None: + """ + :keyword available_patch_count_by_classification: Summarization of patches available for + installation on the machine by classification. + :paramtype available_patch_count_by_classification: + ~azure.mgmt.hybridcompute.models.AvailablePatchCountByClassification + """ + super().__init__(**kwargs) + self.status = None + self.assessment_activity_id = None + self.reboot_pending = None + self.available_patch_count_by_classification = available_patch_count_by_classification + self.start_date_time = None + self.last_modified_date_time = None + self.started_by = None + self.patch_service_used = None + self.os_type = None + self.error_details = None + + +class MachineExtension(TrackedResource): + """Describes a Machine Extension. + + 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 Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Describes Machine Extension Properties. + :vartype properties: ~azure.mgmt.hybridcompute.models.MachineExtensionProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "MachineExtensionProperties"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.MachineExtensionProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword properties: Describes Machine Extension Properties. + :paramtype properties: ~azure.mgmt.hybridcompute.models.MachineExtensionProperties + """ + super().__init__(tags=tags, location=location, **kwargs) + self.properties = properties + + +class MachineExtensionInstanceView(_serialization.Model): + """Describes the Machine Extension Instance View. + + :ivar name: The machine extension name. + :vartype name: str + :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". + :vartype type: str + :ivar type_handler_version: Specifies the version of the script handler. + :vartype type_handler_version: str + :ivar status: Instance view status. + :vartype status: ~azure.mgmt.hybridcompute.models.MachineExtensionInstanceViewStatus + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, + "status": {"key": "status", "type": "MachineExtensionInstanceViewStatus"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + type: Optional[str] = None, + type_handler_version: Optional[str] = None, + status: Optional["_models.MachineExtensionInstanceViewStatus"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The machine extension name. + :paramtype name: str + :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". + :paramtype type: str + :keyword type_handler_version: Specifies the version of the script handler. + :paramtype type_handler_version: str + :keyword status: Instance view status. + :paramtype status: ~azure.mgmt.hybridcompute.models.MachineExtensionInstanceViewStatus + """ + super().__init__(**kwargs) + self.name = name + self.type = type + self.type_handler_version = type_handler_version + self.status = status + + +class MachineExtensionInstanceViewStatus(_serialization.Model): + """Instance view status. + + :ivar code: The status code. + :vartype code: str + :ivar level: The level code. Known values are: "Info", "Warning", and "Error". + :vartype level: str or ~azure.mgmt.hybridcompute.models.StatusLevelTypes + :ivar display_status: The short localizable label for the status. + :vartype display_status: str + :ivar message: The detailed status message, including for alerts and error messages. + :vartype message: str + :ivar time: The time of the status. + :vartype time: ~datetime.datetime + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "level": {"key": "level", "type": "str"}, + "display_status": {"key": "displayStatus", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "time": {"key": "time", "type": "iso-8601"}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, + display_status: Optional[str] = None, + message: Optional[str] = None, + time: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword code: The status code. + :paramtype code: str + :keyword level: The level code. Known values are: "Info", "Warning", and "Error". + :paramtype level: str or ~azure.mgmt.hybridcompute.models.StatusLevelTypes + :keyword display_status: The short localizable label for the status. + :paramtype display_status: str + :keyword message: The detailed status message, including for alerts and error messages. + :paramtype message: str + :keyword time: The time of the status. + :paramtype time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.code = code + self.level = level + self.display_status = display_status + self.message = message + self.time = time + + +class MachineExtensionProperties(_serialization.Model): + """Describes the properties of a Machine Extension. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar force_update_tag: How the extension handler should be forced to update even if the + extension configuration has not changed. + :vartype force_update_tag: str + :ivar publisher: The name of the extension handler publisher. + :vartype publisher: str + :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". + :vartype type: str + :ivar type_handler_version: Specifies the version of the script handler. + :vartype type_handler_version: str + :ivar enable_automatic_upgrade: Indicates whether the extension should be automatically + upgraded by the platform if there is a newer version available. + :vartype enable_automatic_upgrade: bool + :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor + version if one is available at deployment time. Once deployed, however, the extension will not + upgrade minor versions unless redeployed, even with this property set to true. + :vartype auto_upgrade_minor_version: bool + :ivar settings: Json formatted public settings for the extension. + :vartype settings: dict[str, any] + :ivar protected_settings: The extension can contain either protectedSettings or + protectedSettingsFromKeyVault or no protected settings at all. + :vartype protected_settings: dict[str, any] + :ivar provisioning_state: The provisioning state, which only appears in the response. + :vartype provisioning_state: str + :ivar instance_view: The machine extension instance view. + :vartype instance_view: ~azure.mgmt.hybridcompute.models.MachineExtensionInstanceView + """ + + _validation = { + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "force_update_tag": {"key": "forceUpdateTag", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, + "enable_automatic_upgrade": {"key": "enableAutomaticUpgrade", "type": "bool"}, + "auto_upgrade_minor_version": {"key": "autoUpgradeMinorVersion", "type": "bool"}, + "settings": {"key": "settings", "type": "{object}"}, + "protected_settings": {"key": "protectedSettings", "type": "{object}"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "instance_view": {"key": "instanceView", "type": "MachineExtensionInstanceView"}, + } + + def __init__( + self, + *, + force_update_tag: Optional[str] = None, + publisher: Optional[str] = None, + type: Optional[str] = None, + type_handler_version: Optional[str] = None, + enable_automatic_upgrade: Optional[bool] = None, + auto_upgrade_minor_version: Optional[bool] = None, + settings: Optional[Dict[str, Any]] = None, + protected_settings: Optional[Dict[str, Any]] = None, + instance_view: Optional["_models.MachineExtensionInstanceView"] = None, + **kwargs: Any + ) -> None: + """ + :keyword force_update_tag: How the extension handler should be forced to update even if the + extension configuration has not changed. + :paramtype force_update_tag: str + :keyword publisher: The name of the extension handler publisher. + :paramtype publisher: str + :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". + :paramtype type: str + :keyword type_handler_version: Specifies the version of the script handler. + :paramtype type_handler_version: str + :keyword enable_automatic_upgrade: Indicates whether the extension should be automatically + upgraded by the platform if there is a newer version available. + :paramtype enable_automatic_upgrade: bool + :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor + version if one is available at deployment time. Once deployed, however, the extension will not + upgrade minor versions unless redeployed, even with this property set to true. + :paramtype auto_upgrade_minor_version: bool + :keyword settings: Json formatted public settings for the extension. + :paramtype settings: dict[str, any] + :keyword protected_settings: The extension can contain either protectedSettings or + protectedSettingsFromKeyVault or no protected settings at all. + :paramtype protected_settings: dict[str, any] + :keyword instance_view: The machine extension instance view. + :paramtype instance_view: ~azure.mgmt.hybridcompute.models.MachineExtensionInstanceView + """ + super().__init__(**kwargs) + self.force_update_tag = force_update_tag + self.publisher = publisher + self.type = type + self.type_handler_version = type_handler_version + self.enable_automatic_upgrade = enable_automatic_upgrade + self.auto_upgrade_minor_version = auto_upgrade_minor_version + self.settings = settings + self.protected_settings = protected_settings + self.provisioning_state = None + self.instance_view = instance_view + + +class MachineExtensionsListResult(_serialization.Model): + """Describes the Machine Extensions List Result. + + :ivar value: The list of extensions. + :vartype value: list[~azure.mgmt.hybridcompute.models.MachineExtension] + :ivar next_link: The uri to fetch the next page of machine extensions. Call ListNext() with + this to fetch the next page of extensions. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[MachineExtension]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.MachineExtension"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: The list of extensions. + :paramtype value: list[~azure.mgmt.hybridcompute.models.MachineExtension] + :keyword next_link: The uri to fetch the next page of machine extensions. Call ListNext() with + this to fetch the next page of extensions. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class MachineExtensionUpdate(ResourceUpdate): + """Describes a Machine Extension Update. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar force_update_tag: How the extension handler should be forced to update even if the + extension configuration has not changed. + :vartype force_update_tag: str + :ivar publisher: The name of the extension handler publisher. + :vartype publisher: str + :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". + :vartype type: str + :ivar type_handler_version: Specifies the version of the script handler. + :vartype type_handler_version: str + :ivar enable_automatic_upgrade: Indicates whether the extension should be automatically + upgraded by the platform if there is a newer version available. + :vartype enable_automatic_upgrade: bool + :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor + version if one is available at deployment time. Once deployed, however, the extension will not + upgrade minor versions unless redeployed, even with this property set to true. + :vartype auto_upgrade_minor_version: bool + :ivar settings: Json formatted public settings for the extension. + :vartype settings: dict[str, any] + :ivar protected_settings: The extension can contain either protectedSettings or + protectedSettingsFromKeyVault or no protected settings at all. + :vartype protected_settings: dict[str, any] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, + "publisher": {"key": "properties.publisher", "type": "str"}, + "type": {"key": "properties.type", "type": "str"}, + "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, + "enable_automatic_upgrade": {"key": "properties.enableAutomaticUpgrade", "type": "bool"}, + "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, + "settings": {"key": "properties.settings", "type": "{object}"}, + "protected_settings": {"key": "properties.protectedSettings", "type": "{object}"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + force_update_tag: Optional[str] = None, + publisher: Optional[str] = None, + type: Optional[str] = None, + type_handler_version: Optional[str] = None, + enable_automatic_upgrade: Optional[bool] = None, + auto_upgrade_minor_version: Optional[bool] = None, + settings: Optional[Dict[str, Any]] = None, + protected_settings: Optional[Dict[str, Any]] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword force_update_tag: How the extension handler should be forced to update even if the + extension configuration has not changed. + :paramtype force_update_tag: str + :keyword publisher: The name of the extension handler publisher. + :paramtype publisher: str + :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". + :paramtype type: str + :keyword type_handler_version: Specifies the version of the script handler. + :paramtype type_handler_version: str + :keyword enable_automatic_upgrade: Indicates whether the extension should be automatically + upgraded by the platform if there is a newer version available. + :paramtype enable_automatic_upgrade: bool + :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor + version if one is available at deployment time. Once deployed, however, the extension will not + upgrade minor versions unless redeployed, even with this property set to true. + :paramtype auto_upgrade_minor_version: bool + :keyword settings: Json formatted public settings for the extension. + :paramtype settings: dict[str, any] + :keyword protected_settings: The extension can contain either protectedSettings or + protectedSettingsFromKeyVault or no protected settings at all. + :paramtype protected_settings: dict[str, any] + """ + super().__init__(tags=tags, **kwargs) + self.force_update_tag = force_update_tag + self.publisher = publisher + self.type = type + self.type_handler_version = type_handler_version + self.enable_automatic_upgrade = enable_automatic_upgrade + self.auto_upgrade_minor_version = auto_upgrade_minor_version + self.settings = settings + self.protected_settings = protected_settings + + +class MachineExtensionUpgrade(_serialization.Model): + """Describes the Machine Extension Upgrade Properties. + + :ivar extension_targets: Describes the Extension Target Properties. + :vartype extension_targets: dict[str, + ~azure.mgmt.hybridcompute.models.ExtensionTargetProperties] + """ + + _attribute_map = { + "extension_targets": {"key": "extensionTargets", "type": "{ExtensionTargetProperties}"}, + } + + def __init__( + self, *, extension_targets: Optional[Dict[str, "_models.ExtensionTargetProperties"]] = None, **kwargs: Any + ) -> None: + """ + :keyword extension_targets: Describes the Extension Target Properties. + :paramtype extension_targets: dict[str, + ~azure.mgmt.hybridcompute.models.ExtensionTargetProperties] + """ + super().__init__(**kwargs) + self.extension_targets = extension_targets + + +class MachineInstallPatchesParameters(_serialization.Model): + """Input for InstallPatches as directly received by the API. + + All required parameters must be populated in order to send to Azure. + + :ivar maximum_duration: Specifies the maximum amount of time that the operation will run. It + must be an ISO 8601-compliant duration string such as PT4H (4 hours). Required. + :vartype maximum_duration: str + :ivar reboot_setting: Defines when it is acceptable to reboot a VM during a software update + operation. Required. Known values are: "IfRequired", "Never", and "Always". + :vartype reboot_setting: str or ~azure.mgmt.hybridcompute.models.VMGuestPatchRebootSetting + :ivar windows_parameters: Input for InstallPatches on a Windows VM, as directly received by the + API. + :vartype windows_parameters: ~azure.mgmt.hybridcompute.models.WindowsParameters + :ivar linux_parameters: Input for InstallPatches on a Linux VM, as directly received by the + API. + :vartype linux_parameters: ~azure.mgmt.hybridcompute.models.LinuxParameters + """ + + _validation = { + "maximum_duration": {"required": True}, + "reboot_setting": {"required": True}, + } + + _attribute_map = { + "maximum_duration": {"key": "maximumDuration", "type": "str"}, + "reboot_setting": {"key": "rebootSetting", "type": "str"}, + "windows_parameters": {"key": "windowsParameters", "type": "WindowsParameters"}, + "linux_parameters": {"key": "linuxParameters", "type": "LinuxParameters"}, + } + + def __init__( + self, + *, + maximum_duration: str, + reboot_setting: Union[str, "_models.VMGuestPatchRebootSetting"], + windows_parameters: Optional["_models.WindowsParameters"] = None, + linux_parameters: Optional["_models.LinuxParameters"] = None, + **kwargs: Any + ) -> None: + """ + :keyword maximum_duration: Specifies the maximum amount of time that the operation will run. It + must be an ISO 8601-compliant duration string such as PT4H (4 hours). Required. + :paramtype maximum_duration: str + :keyword reboot_setting: Defines when it is acceptable to reboot a VM during a software update + operation. Required. Known values are: "IfRequired", "Never", and "Always". + :paramtype reboot_setting: str or ~azure.mgmt.hybridcompute.models.VMGuestPatchRebootSetting + :keyword windows_parameters: Input for InstallPatches on a Windows VM, as directly received by + the API. + :paramtype windows_parameters: ~azure.mgmt.hybridcompute.models.WindowsParameters + :keyword linux_parameters: Input for InstallPatches on a Linux VM, as directly received by the + API. + :paramtype linux_parameters: ~azure.mgmt.hybridcompute.models.LinuxParameters + """ + super().__init__(**kwargs) + self.maximum_duration = maximum_duration + self.reboot_setting = reboot_setting + self.windows_parameters = windows_parameters + self.linux_parameters = linux_parameters + + +class MachineInstallPatchesResult(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The result summary of an installation operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: The overall success or failure status of the operation. It remains "InProgress" + until the operation completes. At that point it will become "Failed", "Succeeded", "Unknown" or + "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", and + "CompletedWithWarnings". + :vartype status: str or ~azure.mgmt.hybridcompute.models.PatchOperationStatus + :ivar installation_activity_id: The activity ID of the operation that produced this result. + :vartype installation_activity_id: str + :ivar reboot_status: The reboot state of the VM following completion of the operation. Known + values are: "Unknown", "NotNeeded", "Required", "Started", "Failed", and "Completed". + :vartype reboot_status: str or ~azure.mgmt.hybridcompute.models.VMGuestPatchRebootStatus + :ivar maintenance_window_exceeded: Whether the operation ran out of time before it completed + all its intended actions. + :vartype maintenance_window_exceeded: bool + :ivar excluded_patch_count: The number of patches that were not installed due to the user + blocking their installation. + :vartype excluded_patch_count: int + :ivar not_selected_patch_count: The number of patches that were detected as available for + install, but did not meet the operation's criteria. + :vartype not_selected_patch_count: int + :ivar pending_patch_count: The number of patches that were identified as meeting the + installation criteria, but were not able to be installed. Typically this happens when + maintenanceWindowExceeded == true. + :vartype pending_patch_count: int + :ivar installed_patch_count: The number of patches successfully installed. + :vartype installed_patch_count: int + :ivar failed_patch_count: The number of patches that could not be installed due to some issue. + See errors for details. + :vartype failed_patch_count: int + :ivar start_date_time: The UTC timestamp when the operation began. + :vartype start_date_time: ~datetime.datetime + :ivar last_modified_date_time: The UTC timestamp when the operation finished. + :vartype last_modified_date_time: ~datetime.datetime + :ivar started_by: Indicates if operation was triggered by user or by platform. Known values + are: "User" and "Platform". + :vartype started_by: str or ~azure.mgmt.hybridcompute.models.PatchOperationStartedBy + :ivar patch_service_used: Specifies the patch service used for the operation. Known values are: + "Unknown", "WU", "WU_WSUS", "YUM", "APT", and "Zypper". + :vartype patch_service_used: str or ~azure.mgmt.hybridcompute.models.PatchServiceUsed + :ivar os_type: The operating system type of the machine. Known values are: "Windows" and + "Linux". + :vartype os_type: str or ~azure.mgmt.hybridcompute.models.OsType + :ivar error_details: The errors that were encountered during execution of the operation. The + details array contains the list of them. + :vartype error_details: ~azure.mgmt.hybridcompute.models.ErrorDetail + """ + + _validation = { + "status": {"readonly": True}, + "installation_activity_id": {"readonly": True}, + "reboot_status": {"readonly": True}, + "maintenance_window_exceeded": {"readonly": True}, + "excluded_patch_count": {"readonly": True}, + "not_selected_patch_count": {"readonly": True}, + "pending_patch_count": {"readonly": True}, + "installed_patch_count": {"readonly": True}, + "failed_patch_count": {"readonly": True}, + "start_date_time": {"readonly": True}, + "last_modified_date_time": {"readonly": True}, + "started_by": {"readonly": True}, + "patch_service_used": {"readonly": True}, + "os_type": {"readonly": True}, + "error_details": {"readonly": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "installation_activity_id": {"key": "installationActivityId", "type": "str"}, + "reboot_status": {"key": "rebootStatus", "type": "str"}, + "maintenance_window_exceeded": {"key": "maintenanceWindowExceeded", "type": "bool"}, + "excluded_patch_count": {"key": "excludedPatchCount", "type": "int"}, + "not_selected_patch_count": {"key": "notSelectedPatchCount", "type": "int"}, + "pending_patch_count": {"key": "pendingPatchCount", "type": "int"}, + "installed_patch_count": {"key": "installedPatchCount", "type": "int"}, + "failed_patch_count": {"key": "failedPatchCount", "type": "int"}, + "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, + "last_modified_date_time": {"key": "lastModifiedDateTime", "type": "iso-8601"}, + "started_by": {"key": "startedBy", "type": "str"}, + "patch_service_used": {"key": "patchServiceUsed", "type": "str"}, + "os_type": {"key": "osType", "type": "str"}, + "error_details": {"key": "errorDetails", "type": "ErrorDetail"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.status = None + self.installation_activity_id = None + self.reboot_status = None + self.maintenance_window_exceeded = None + self.excluded_patch_count = None + self.not_selected_patch_count = None + self.pending_patch_count = None + self.installed_patch_count = None + self.failed_patch_count = None + self.start_date_time = None + self.last_modified_date_time = None + self.started_by = None + self.patch_service_used = None + self.os_type = None + self.error_details = None + + +class MachineListResult(_serialization.Model): + """The List hybrid machine operation response. + + All required parameters must be populated in order to send to Azure. + + :ivar value: The list of hybrid machines. Required. + :vartype value: list[~azure.mgmt.hybridcompute.models.Machine] + :ivar next_link: The URI to fetch the next page of Machines. Call ListNext() with this URI to + fetch the next page of hybrid machines. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Machine]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.Machine"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: The list of hybrid machines. Required. + :paramtype value: list[~azure.mgmt.hybridcompute.models.Machine] + :keyword next_link: The URI to fetch the next page of Machines. Call ListNext() with this URI + to fetch the next page of hybrid machines. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class MachineRunCommand(TrackedResource): # pylint: disable=too-many-instance-attributes + """Describes a Run Command. + + 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 Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar source: The source of the run command script. + :vartype source: ~azure.mgmt.hybridcompute.models.MachineRunCommandScriptSource + :ivar parameters: The parameters used by the script. + :vartype parameters: list[~azure.mgmt.hybridcompute.models.RunCommandInputParameter] + :ivar protected_parameters: The parameters used by the script. + :vartype protected_parameters: list[~azure.mgmt.hybridcompute.models.RunCommandInputParameter] + :ivar async_execution: Optional. If set to true, provisioning will complete as soon as script + starts and will not wait for script to complete. + :vartype async_execution: bool + :ivar run_as_user: Specifies the user account on the machine when executing the run command. + :vartype run_as_user: str + :ivar run_as_password: Specifies the user account password on the machine when executing the + run command. + :vartype run_as_password: str + :ivar timeout_in_seconds: The timeout in seconds to execute the run command. + :vartype timeout_in_seconds: int + :ivar output_blob_uri: Specifies the Azure storage blob where script output stream will be + uploaded. Use a SAS URI with read, append, create, write access OR use managed identity to + provide the VM access to the blob. Refer outputBlobManagedIdentity parameter. + :vartype output_blob_uri: str + :ivar error_blob_uri: Specifies the Azure storage blob where script error stream will be + uploaded. Use a SAS URI with read, append, create, write access OR use managed identity to + provide the VM access to the blob. Refer errorBlobManagedIdentity parameter. + :vartype error_blob_uri: str + :ivar output_blob_managed_identity: User-assigned managed identity that has access to + outputBlobUri storage blob. Use an empty object in case of system-assigned identity. Make sure + managed identity has been given access to blob's container with 'Storage Blob Data Contributor' + role assignment. In case of user-assigned identity, make sure you add it under VM's identity. + For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and + https://aka.ms/RunCommandManaged. + :vartype output_blob_managed_identity: + ~azure.mgmt.hybridcompute.models.RunCommandManagedIdentity + :ivar error_blob_managed_identity: User-assigned managed identity that has access to + errorBlobUri storage blob. Use an empty object in case of system-assigned identity. Make sure + managed identity has been given access to blob's container with 'Storage Blob Data Contributor' + role assignment. In case of user-assigned identity, make sure you add it under VM's identity. + For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and + https://aka.ms/RunCommandManaged. + :vartype error_blob_managed_identity: + ~azure.mgmt.hybridcompute.models.RunCommandManagedIdentity + :ivar provisioning_state: The provisioning state, which only appears in the response. + :vartype provisioning_state: str + :ivar instance_view: The machine run command instance view. + :vartype instance_view: ~azure.mgmt.hybridcompute.models.MachineRunCommandInstanceView + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "instance_view": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "source": {"key": "properties.source", "type": "MachineRunCommandScriptSource"}, + "parameters": {"key": "properties.parameters", "type": "[RunCommandInputParameter]"}, + "protected_parameters": {"key": "properties.protectedParameters", "type": "[RunCommandInputParameter]"}, + "async_execution": {"key": "properties.asyncExecution", "type": "bool"}, + "run_as_user": {"key": "properties.runAsUser", "type": "str"}, + "run_as_password": {"key": "properties.runAsPassword", "type": "str"}, + "timeout_in_seconds": {"key": "properties.timeoutInSeconds", "type": "int"}, + "output_blob_uri": {"key": "properties.outputBlobUri", "type": "str"}, + "error_blob_uri": {"key": "properties.errorBlobUri", "type": "str"}, + "output_blob_managed_identity": { + "key": "properties.outputBlobManagedIdentity", + "type": "RunCommandManagedIdentity", + }, + "error_blob_managed_identity": { + "key": "properties.errorBlobManagedIdentity", + "type": "RunCommandManagedIdentity", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "instance_view": {"key": "properties.instanceView", "type": "MachineRunCommandInstanceView"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + source: Optional["_models.MachineRunCommandScriptSource"] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, + protected_parameters: Optional[List["_models.RunCommandInputParameter"]] = None, + async_execution: bool = False, + run_as_user: Optional[str] = None, + run_as_password: Optional[str] = None, + timeout_in_seconds: Optional[int] = None, + output_blob_uri: Optional[str] = None, + error_blob_uri: Optional[str] = None, + output_blob_managed_identity: Optional["_models.RunCommandManagedIdentity"] = None, + error_blob_managed_identity: Optional["_models.RunCommandManagedIdentity"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword source: The source of the run command script. + :paramtype source: ~azure.mgmt.hybridcompute.models.MachineRunCommandScriptSource + :keyword parameters: The parameters used by the script. + :paramtype parameters: list[~azure.mgmt.hybridcompute.models.RunCommandInputParameter] + :keyword protected_parameters: The parameters used by the script. + :paramtype protected_parameters: + list[~azure.mgmt.hybridcompute.models.RunCommandInputParameter] + :keyword async_execution: Optional. If set to true, provisioning will complete as soon as + script starts and will not wait for script to complete. + :paramtype async_execution: bool + :keyword run_as_user: Specifies the user account on the machine when executing the run command. + :paramtype run_as_user: str + :keyword run_as_password: Specifies the user account password on the machine when executing the + run command. + :paramtype run_as_password: str + :keyword timeout_in_seconds: The timeout in seconds to execute the run command. + :paramtype timeout_in_seconds: int + :keyword output_blob_uri: Specifies the Azure storage blob where script output stream will be + uploaded. Use a SAS URI with read, append, create, write access OR use managed identity to + provide the VM access to the blob. Refer outputBlobManagedIdentity parameter. + :paramtype output_blob_uri: str + :keyword error_blob_uri: Specifies the Azure storage blob where script error stream will be + uploaded. Use a SAS URI with read, append, create, write access OR use managed identity to + provide the VM access to the blob. Refer errorBlobManagedIdentity parameter. + :paramtype error_blob_uri: str + :keyword output_blob_managed_identity: User-assigned managed identity that has access to + outputBlobUri storage blob. Use an empty object in case of system-assigned identity. Make sure + managed identity has been given access to blob's container with 'Storage Blob Data Contributor' + role assignment. In case of user-assigned identity, make sure you add it under VM's identity. + For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and + https://aka.ms/RunCommandManaged. + :paramtype output_blob_managed_identity: + ~azure.mgmt.hybridcompute.models.RunCommandManagedIdentity + :keyword error_blob_managed_identity: User-assigned managed identity that has access to + errorBlobUri storage blob. Use an empty object in case of system-assigned identity. Make sure + managed identity has been given access to blob's container with 'Storage Blob Data Contributor' + role assignment. In case of user-assigned identity, make sure you add it under VM's identity. + For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and + https://aka.ms/RunCommandManaged. + :paramtype error_blob_managed_identity: + ~azure.mgmt.hybridcompute.models.RunCommandManagedIdentity + """ + super().__init__(tags=tags, location=location, **kwargs) + self.source = source + self.parameters = parameters + self.protected_parameters = protected_parameters + self.async_execution = async_execution + self.run_as_user = run_as_user + self.run_as_password = run_as_password + self.timeout_in_seconds = timeout_in_seconds + self.output_blob_uri = output_blob_uri + self.error_blob_uri = error_blob_uri + self.output_blob_managed_identity = output_blob_managed_identity + self.error_blob_managed_identity = error_blob_managed_identity + self.provisioning_state = None + self.instance_view = None + + +class MachineRunCommandInstanceView(_serialization.Model): + """The instance view of a machine run command. + + :ivar execution_state: Script execution status. Known values are: "Unknown", "Pending", + "Running", "Failed", "Succeeded", "TimedOut", and "Canceled". + :vartype execution_state: str or ~azure.mgmt.hybridcompute.models.ExecutionState + :ivar execution_message: Communicate script configuration errors or execution messages. + :vartype execution_message: str + :ivar exit_code: Exit code returned from script execution. + :vartype exit_code: int + :ivar output: Script output stream. + :vartype output: str + :ivar error: Script error stream. + :vartype error: str + :ivar start_time: Script start time. + :vartype start_time: ~datetime.datetime + :ivar end_time: Script end time. + :vartype end_time: ~datetime.datetime + :ivar statuses: The status information. + :vartype statuses: list[~azure.mgmt.hybridcompute.models.ExtensionsResourceStatus] + """ + + _attribute_map = { + "execution_state": {"key": "executionState", "type": "str"}, + "execution_message": {"key": "executionMessage", "type": "str"}, + "exit_code": {"key": "exitCode", "type": "int"}, + "output": {"key": "output", "type": "str"}, + "error": {"key": "error", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "statuses": {"key": "statuses", "type": "[ExtensionsResourceStatus]"}, + } + + def __init__( + self, + *, + execution_state: Optional[Union[str, "_models.ExecutionState"]] = None, + execution_message: Optional[str] = None, + exit_code: Optional[int] = None, + output: Optional[str] = None, + error: Optional[str] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + statuses: Optional[List["_models.ExtensionsResourceStatus"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword execution_state: Script execution status. Known values are: "Unknown", "Pending", + "Running", "Failed", "Succeeded", "TimedOut", and "Canceled". + :paramtype execution_state: str or ~azure.mgmt.hybridcompute.models.ExecutionState + :keyword execution_message: Communicate script configuration errors or execution messages. + :paramtype execution_message: str + :keyword exit_code: Exit code returned from script execution. + :paramtype exit_code: int + :keyword output: Script output stream. + :paramtype output: str + :keyword error: Script error stream. + :paramtype error: str + :keyword start_time: Script start time. + :paramtype start_time: ~datetime.datetime + :keyword end_time: Script end time. + :paramtype end_time: ~datetime.datetime + :keyword statuses: The status information. + :paramtype statuses: list[~azure.mgmt.hybridcompute.models.ExtensionsResourceStatus] + """ + super().__init__(**kwargs) + self.execution_state = execution_state + self.execution_message = execution_message + self.exit_code = exit_code + self.output = output + self.error = error + self.start_time = start_time + self.end_time = end_time + self.statuses = statuses + + +class MachineRunCommandScriptSource(_serialization.Model): + """Describes the script sources for run command. Use only one of script, scriptUri, commandId. + + :ivar script: Specifies the script content to be executed on the machine. + :vartype script: str + :ivar script_uri: Specifies the script download location. It can be either SAS URI of an Azure + storage blob with read access or public URI. + :vartype script_uri: str + :ivar command_id: Specifies the commandId of predefined built-in script. + :vartype command_id: str + :ivar script_uri_managed_identity: User-assigned managed identity that has access to scriptUri + in case of Azure storage blob. Use an empty object in case of system-assigned identity. Make + sure the Azure storage blob exists, and managed identity has been given access to blob's + container with 'Storage Blob Data Reader' role assignment. In case of user-assigned identity, + make sure you add it under VM's identity. For more info on managed identity and Run Command, + refer https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged. + :vartype script_uri_managed_identity: + ~azure.mgmt.hybridcompute.models.RunCommandManagedIdentity + """ + + _attribute_map = { + "script": {"key": "script", "type": "str"}, + "script_uri": {"key": "scriptUri", "type": "str"}, + "command_id": {"key": "commandId", "type": "str"}, + "script_uri_managed_identity": {"key": "scriptUriManagedIdentity", "type": "RunCommandManagedIdentity"}, + } + + def __init__( + self, + *, + script: Optional[str] = None, + script_uri: Optional[str] = None, + command_id: Optional[str] = None, + script_uri_managed_identity: Optional["_models.RunCommandManagedIdentity"] = None, + **kwargs: Any + ) -> None: + """ + :keyword script: Specifies the script content to be executed on the machine. + :paramtype script: str + :keyword script_uri: Specifies the script download location. It can be either SAS URI of an + Azure storage blob with read access or public URI. + :paramtype script_uri: str + :keyword command_id: Specifies the commandId of predefined built-in script. + :paramtype command_id: str + :keyword script_uri_managed_identity: User-assigned managed identity that has access to + scriptUri in case of Azure storage blob. Use an empty object in case of system-assigned + identity. Make sure the Azure storage blob exists, and managed identity has been given access + to blob's container with 'Storage Blob Data Reader' role assignment. In case of user-assigned + identity, make sure you add it under VM's identity. For more info on managed identity and Run + Command, refer https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged. + :paramtype script_uri_managed_identity: + ~azure.mgmt.hybridcompute.models.RunCommandManagedIdentity + """ super().__init__(**kwargs) - self.location_data = location_data - self.agent_configuration = None - self.service_statuses = service_statuses - self.cloud_metadata = cloud_metadata - self.os_profile = os_profile - self.provisioning_state = None - self.status = None - self.last_status_change = None - self.error_details = None - self.agent_version = None - self.vm_id = vm_id - self.display_name = None - self.machine_fqdn = None - self.client_public_key = client_public_key - self.os_name = None - self.os_version = None - self.os_type = os_type - self.vm_uuid = None - self.extensions = extensions - self.os_sku = None - self.domain_name = None - self.ad_fqdn = None - self.dns_fqdn = None - self.private_link_scope_resource_id = private_link_scope_resource_id - self.parent_cluster_resource_id = parent_cluster_resource_id - self.mssql_discovered = mssql_discovered - self.detected_properties = None + self.script = script + self.script_uri = script_uri + self.command_id = command_id + self.script_uri_managed_identity = script_uri_managed_identity -class MachineUpdate(ResourceUpdate): - """Describes a hybrid machine Update. +class MachineRunCommandsListResult(_serialization.Model): + """Describes the Run Commands List Result. - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar identity: Identity for the resource. - :vartype identity: ~azure.mgmt.hybridcompute.models.Identity - :ivar properties: Hybrid Compute Machine properties. - :vartype properties: ~azure.mgmt.hybridcompute.models.MachineUpdateProperties + :ivar value: The list of run commands. + :vartype value: list[~azure.mgmt.hybridcompute.models.MachineRunCommand] + :ivar next_link: The uri to fetch the next page of run commands. Call ListNext() with this to + fetch the next page of run commands. + :vartype next_link: str """ _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "identity": {"key": "identity", "type": "Identity"}, - "properties": {"key": "properties", "type": "MachineUpdateProperties"}, + "value": {"key": "value", "type": "[MachineRunCommand]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - tags: Optional[Dict[str, str]] = None, - identity: Optional["_models.Identity"] = None, - properties: Optional["_models.MachineUpdateProperties"] = None, + value: Optional[List["_models.MachineRunCommand"]] = None, + next_link: Optional[str] = None, **kwargs: Any ) -> None: + """ + :keyword value: The list of run commands. + :paramtype value: list[~azure.mgmt.hybridcompute.models.MachineRunCommand] + :keyword next_link: The uri to fetch the next page of run commands. Call ListNext() with this + to fetch the next page of run commands. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class MachineRunCommandUpdate(ResourceUpdate): + """Describes a Machine Extension Update. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword identity: Identity for the resource. - :paramtype identity: ~azure.mgmt.hybridcompute.models.Identity - :keyword properties: Hybrid Compute Machine properties. - :paramtype properties: ~azure.mgmt.hybridcompute.models.MachineUpdateProperties """ super().__init__(tags=tags, **kwargs) - self.identity = identity - self.properties = properties -class MachineUpdateProperties(_serialization.Model): - """Describes the ARM updatable properties of a hybrid machine. +class MachineUpdate(ResourceUpdate): + """Describes a hybrid machine Update. + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar identity: Identity for the resource. + :vartype identity: ~azure.mgmt.hybridcompute.models.Identity + :ivar kind: Indicates which kind of Arc machine placement on-premises, such as HCI, SCVMM or + VMware etc. Known values are: "AVS", "HCI", "SCVMM", "VMware", "EPS", "GCP", and "AWS". + :vartype kind: str or ~azure.mgmt.hybridcompute.models.ArcKindEnum :ivar location_data: Metadata pertaining to the geographic location of the resource. :vartype location_data: ~azure.mgmt.hybridcompute.models.LocationData :ivar os_profile: Specifies the operating system settings for the hybrid machine. :vartype os_profile: ~azure.mgmt.hybridcompute.models.OSProfile :ivar cloud_metadata: The metadata of the cloud environment (Azure/GCP/AWS/OCI...). :vartype cloud_metadata: ~azure.mgmt.hybridcompute.models.CloudMetadata + :ivar agent_upgrade: The info of the machine w.r.t Agent Upgrade. + :vartype agent_upgrade: ~azure.mgmt.hybridcompute.models.AgentUpgrade :ivar parent_cluster_resource_id: The resource id of the parent cluster (Azure HCI) this machine is assigned to, if any. :vartype parent_cluster_resource_id: str @@ -1458,30 +3496,47 @@ class MachineUpdateProperties(_serialization.Model): """ _attribute_map = { - "location_data": {"key": "locationData", "type": "LocationData"}, - "os_profile": {"key": "osProfile", "type": "OSProfile"}, - "cloud_metadata": {"key": "cloudMetadata", "type": "CloudMetadata"}, - "parent_cluster_resource_id": {"key": "parentClusterResourceId", "type": "str"}, - "private_link_scope_resource_id": {"key": "privateLinkScopeResourceId", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "kind": {"key": "kind", "type": "str"}, + "location_data": {"key": "properties.locationData", "type": "LocationData"}, + "os_profile": {"key": "properties.osProfile", "type": "OSProfile"}, + "cloud_metadata": {"key": "properties.cloudMetadata", "type": "CloudMetadata"}, + "agent_upgrade": {"key": "properties.agentUpgrade", "type": "AgentUpgrade"}, + "parent_cluster_resource_id": {"key": "properties.parentClusterResourceId", "type": "str"}, + "private_link_scope_resource_id": {"key": "properties.privateLinkScopeResourceId", "type": "str"}, } def __init__( self, *, + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.Identity"] = None, + kind: Optional[Union[str, "_models.ArcKindEnum"]] = None, location_data: Optional["_models.LocationData"] = None, os_profile: Optional["_models.OSProfile"] = None, cloud_metadata: Optional["_models.CloudMetadata"] = None, + agent_upgrade: Optional["_models.AgentUpgrade"] = None, parent_cluster_resource_id: Optional[str] = None, private_link_scope_resource_id: Optional[str] = None, **kwargs: Any ) -> None: """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword identity: Identity for the resource. + :paramtype identity: ~azure.mgmt.hybridcompute.models.Identity + :keyword kind: Indicates which kind of Arc machine placement on-premises, such as HCI, SCVMM or + VMware etc. Known values are: "AVS", "HCI", "SCVMM", "VMware", "EPS", "GCP", and "AWS". + :paramtype kind: str or ~azure.mgmt.hybridcompute.models.ArcKindEnum :keyword location_data: Metadata pertaining to the geographic location of the resource. :paramtype location_data: ~azure.mgmt.hybridcompute.models.LocationData :keyword os_profile: Specifies the operating system settings for the hybrid machine. :paramtype os_profile: ~azure.mgmt.hybridcompute.models.OSProfile :keyword cloud_metadata: The metadata of the cloud environment (Azure/GCP/AWS/OCI...). :paramtype cloud_metadata: ~azure.mgmt.hybridcompute.models.CloudMetadata + :keyword agent_upgrade: The info of the machine w.r.t Agent Upgrade. + :paramtype agent_upgrade: ~azure.mgmt.hybridcompute.models.AgentUpgrade :keyword parent_cluster_resource_id: The resource id of the parent cluster (Azure HCI) this machine is assigned to, if any. :paramtype parent_cluster_resource_id: str @@ -1489,14 +3544,57 @@ def __init__( is assigned to, if any. :paramtype private_link_scope_resource_id: str """ - super().__init__(**kwargs) + super().__init__(tags=tags, **kwargs) + self.identity = identity + self.kind = kind self.location_data = location_data self.os_profile = os_profile self.cloud_metadata = cloud_metadata + self.agent_upgrade = agent_upgrade self.parent_cluster_resource_id = parent_cluster_resource_id self.private_link_scope_resource_id = private_link_scope_resource_id +class NetworkInterface(_serialization.Model): + """Describes a network interface. + + :ivar ip_addresses: The list of IP addresses in this interface. + :vartype ip_addresses: list[~azure.mgmt.hybridcompute.models.IpAddress] + """ + + _attribute_map = { + "ip_addresses": {"key": "ipAddresses", "type": "[IpAddress]"}, + } + + def __init__(self, *, ip_addresses: Optional[List["_models.IpAddress"]] = None, **kwargs: Any) -> None: + """ + :keyword ip_addresses: The list of IP addresses in this interface. + :paramtype ip_addresses: list[~azure.mgmt.hybridcompute.models.IpAddress] + """ + super().__init__(**kwargs) + self.ip_addresses = ip_addresses + + +class NetworkProfile(_serialization.Model): + """Describes the network information on this machine. + + :ivar network_interfaces: The list of network interfaces. + :vartype network_interfaces: list[~azure.mgmt.hybridcompute.models.NetworkInterface] + """ + + _attribute_map = { + "network_interfaces": {"key": "networkInterfaces", "type": "[NetworkInterface]"}, + } + + def __init__(self, *, network_interfaces: Optional[List["_models.NetworkInterface"]] = None, **kwargs: Any) -> None: + """ + :keyword network_interfaces: The list of network interfaces. + :paramtype network_interfaces: list[~azure.mgmt.hybridcompute.models.NetworkInterface] + """ + super().__init__(**kwargs) + self.network_interfaces = network_interfaces + + class OperationListResult(_serialization.Model): """The List Compute Operation operation response. @@ -1713,39 +3811,6 @@ def __init__( self.patch_mode = patch_mode -class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have - tags and a location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - class PrivateEndpointConnection(ProxyResource): """A private endpoint connection. @@ -1759,10 +3824,11 @@ class PrivateEndpointConnection(ProxyResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData :ivar properties: Resource properties. :vartype properties: ~azure.mgmt.hybridcompute.models.PrivateEndpointConnectionProperties - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData """ _validation = { @@ -1776,8 +3842,8 @@ class PrivateEndpointConnection(ProxyResource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "PrivateEndpointConnectionProperties"}, "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "PrivateEndpointConnectionProperties"}, } def __init__( @@ -1789,7 +3855,6 @@ def __init__( """ super().__init__(**kwargs) self.properties = properties - self.system_data = None class PrivateEndpointConnectionDataModel(_serialization.Model): @@ -1949,10 +4014,11 @@ class PrivateLinkResource(ProxyResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData :ivar properties: Resource properties. :vartype properties: ~azure.mgmt.hybridcompute.models.PrivateLinkResourceProperties - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData """ _validation = { @@ -1966,8 +4032,8 @@ class PrivateLinkResource(ProxyResource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "PrivateLinkResourceProperties"}, "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "PrivateLinkResourceProperties"}, } def __init__(self, *, properties: Optional["_models.PrivateLinkResourceProperties"] = None, **kwargs: Any) -> None: @@ -1977,7 +4043,6 @@ def __init__(self, *, properties: Optional["_models.PrivateLinkResourcePropertie """ super().__init__(**kwargs) self.properties = properties - self.system_data = None class PrivateLinkResourceListResult(_serialization.Model): @@ -2127,6 +4192,168 @@ def __init__(self, *, status: str, description: str, **kwargs: Any) -> None: self.actions_required = None +class ProductFeature(_serialization.Model): + """Product Feature. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Product feature name. + :vartype name: str + :ivar subscription_status: Indicates the current status of the product features. Known values + are: "Unknown", "Enabling", "Enabled", and "Disabled". + :vartype subscription_status: str or + ~azure.mgmt.hybridcompute.models.LicenseProfileSubscriptionStatus + :ivar billing_start_date: The timestamp in UTC when the billing starts. + :vartype billing_start_date: ~datetime.datetime + :ivar enrollment_date: The timestamp in UTC when the user enrolls the feature. + :vartype enrollment_date: ~datetime.datetime + :ivar disenrollment_date: The timestamp in UTC when the user disenrolled the feature. + :vartype disenrollment_date: ~datetime.datetime + """ + + _validation = { + "billing_start_date": {"readonly": True}, + "enrollment_date": {"readonly": True}, + "disenrollment_date": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "subscription_status": {"key": "subscriptionStatus", "type": "str"}, + "billing_start_date": {"key": "billingStartDate", "type": "iso-8601"}, + "enrollment_date": {"key": "enrollmentDate", "type": "iso-8601"}, + "disenrollment_date": {"key": "disenrollmentDate", "type": "iso-8601"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + subscription_status: Optional[Union[str, "_models.LicenseProfileSubscriptionStatus"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Product feature name. + :paramtype name: str + :keyword subscription_status: Indicates the current status of the product features. Known + values are: "Unknown", "Enabling", "Enabled", and "Disabled". + :paramtype subscription_status: str or + ~azure.mgmt.hybridcompute.models.LicenseProfileSubscriptionStatus + """ + super().__init__(**kwargs) + self.name = name + self.subscription_status = subscription_status + self.billing_start_date = None + self.enrollment_date = None + self.disenrollment_date = None + + +class ProductFeatureUpdate(_serialization.Model): + """Product Feature. + + :ivar name: Product feature name. + :vartype name: str + :ivar subscription_status: Indicates the new status of the product feature. Known values are: + "Enable" and "Disable". + :vartype subscription_status: str or + ~azure.mgmt.hybridcompute.models.LicenseProfileSubscriptionStatusUpdate + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "subscription_status": {"key": "subscriptionStatus", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + subscription_status: Optional[Union[str, "_models.LicenseProfileSubscriptionStatusUpdate"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Product feature name. + :paramtype name: str + :keyword subscription_status: Indicates the new status of the product feature. Known values + are: "Enable" and "Disable". + :paramtype subscription_status: str or + ~azure.mgmt.hybridcompute.models.LicenseProfileSubscriptionStatusUpdate + """ + super().__init__(**kwargs) + self.name = name + self.subscription_status = subscription_status + + +class RunCommandInputParameter(_serialization.Model): + """Describes the properties of a run command parameter. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The run command parameter name. Required. + :vartype name: str + :ivar value: The run command parameter value. Required. + :vartype value: str + """ + + _validation = { + "name": {"required": True}, + "value": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, *, name: str, value: str, **kwargs: Any) -> None: + """ + :keyword name: The run command parameter name. Required. + :paramtype name: str + :keyword value: The run command parameter value. Required. + :paramtype value: str + """ + super().__init__(**kwargs) + self.name = name + self.value = value + + +class RunCommandManagedIdentity(_serialization.Model): + """Contains clientId or objectId (use only one, not both) of a user-assigned managed identity that + has access to storage blob used in Run Command. Use an empty RunCommandManagedIdentity object + in case of system-assigned identity. Make sure the Azure storage blob exists in case of + scriptUri, and managed identity has been given access to blob's container with 'Storage Blob + Data Reader' role assignment with scriptUri blob and 'Storage Blob Data Contributor' for Append + blobs(outputBlobUri, errorBlobUri). In case of user assigned identity, make sure you add it + under VM's identity. For more info on managed identity and Run Command, refer + https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged. + + :ivar client_id: Client Id (GUID value) of the user-assigned managed identity. ObjectId should + not be used if this is provided. + :vartype client_id: str + :ivar object_id: Object Id (GUID value) of the user-assigned managed identity. ClientId should + not be used if this is provided. + :vartype object_id: str + """ + + _attribute_map = { + "client_id": {"key": "clientId", "type": "str"}, + "object_id": {"key": "objectId", "type": "str"}, + } + + def __init__(self, *, client_id: Optional[str] = None, object_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword client_id: Client Id (GUID value) of the user-assigned managed identity. ObjectId + should not be used if this is provided. + :paramtype client_id: str + :keyword object_id: Object Id (GUID value) of the user-assigned managed identity. ClientId + should not be used if this is provided. + :paramtype object_id: str + """ + super().__init__(**kwargs) + self.client_id = client_id + self.object_id = object_id + + class ServiceStatus(_serialization.Model): """Describes the status and behavior of a service. @@ -2187,6 +4414,26 @@ def __init__( self.guest_configuration_service = guest_configuration_service +class Subnet(_serialization.Model): + """Describes the subnet. + + :ivar address_prefix: Represents address prefix. + :vartype address_prefix: str + """ + + _attribute_map = { + "address_prefix": {"key": "addressPrefix", "type": "str"}, + } + + def __init__(self, *, address_prefix: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword address_prefix: Represents address prefix. + :paramtype address_prefix: str + """ + super().__init__(**kwargs) + self.address_prefix = address_prefix + + class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. @@ -2270,3 +4517,64 @@ def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> N """ super().__init__(**kwargs) self.tags = tags + + +class WindowsParameters(_serialization.Model): + """Input for InstallPatches on a Windows VM, as directly received by the API. + + :ivar classifications_to_include: The update classifications to select when installing patches + for Windows. + :vartype classifications_to_include: list[str or + ~azure.mgmt.hybridcompute.models.VMGuestPatchClassificationWindows] + :ivar kb_numbers_to_include: Kbs to include in the patch operation. + :vartype kb_numbers_to_include: list[str] + :ivar kb_numbers_to_exclude: Kbs to exclude in the patch operation. + :vartype kb_numbers_to_exclude: list[str] + :ivar exclude_kbs_requiring_reboot: Filters out Kbs that don't have an + InstallationRebootBehavior of 'NeverReboots' when this is set to true. + :vartype exclude_kbs_requiring_reboot: bool + :ivar max_patch_publish_date: This is used to install patches that were published on or before + this given max published date. + :vartype max_patch_publish_date: ~datetime.datetime + """ + + _attribute_map = { + "classifications_to_include": {"key": "classificationsToInclude", "type": "[str]"}, + "kb_numbers_to_include": {"key": "kbNumbersToInclude", "type": "[str]"}, + "kb_numbers_to_exclude": {"key": "kbNumbersToExclude", "type": "[str]"}, + "exclude_kbs_requiring_reboot": {"key": "excludeKbsRequiringReboot", "type": "bool"}, + "max_patch_publish_date": {"key": "maxPatchPublishDate", "type": "iso-8601"}, + } + + def __init__( + self, + *, + classifications_to_include: Optional[List[Union[str, "_models.VMGuestPatchClassificationWindows"]]] = None, + kb_numbers_to_include: Optional[List[str]] = None, + kb_numbers_to_exclude: Optional[List[str]] = None, + exclude_kbs_requiring_reboot: Optional[bool] = None, + max_patch_publish_date: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword classifications_to_include: The update classifications to select when installing + patches for Windows. + :paramtype classifications_to_include: list[str or + ~azure.mgmt.hybridcompute.models.VMGuestPatchClassificationWindows] + :keyword kb_numbers_to_include: Kbs to include in the patch operation. + :paramtype kb_numbers_to_include: list[str] + :keyword kb_numbers_to_exclude: Kbs to exclude in the patch operation. + :paramtype kb_numbers_to_exclude: list[str] + :keyword exclude_kbs_requiring_reboot: Filters out Kbs that don't have an + InstallationRebootBehavior of 'NeverReboots' when this is set to true. + :paramtype exclude_kbs_requiring_reboot: bool + :keyword max_patch_publish_date: This is used to install patches that were published on or + before this given max published date. + :paramtype max_patch_publish_date: ~datetime.datetime + """ + super().__init__(**kwargs) + self.classifications_to_include = classifications_to_include + self.kb_numbers_to_include = kb_numbers_to_include + self.kb_numbers_to_exclude = kb_numbers_to_exclude + self.exclude_kbs_requiring_reboot = exclude_kbs_requiring_reboot + self.max_patch_publish_date = max_patch_publish_date diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/__init__.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/__init__.py index 4709c0d6c162..0a1d56088a0d 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/__init__.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/__init__.py @@ -6,10 +6,17 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from ._licenses_operations import LicensesOperations from ._machines_operations import MachinesOperations +from ._license_profiles_operations import LicenseProfilesOperations from ._machine_extensions_operations import MachineExtensionsOperations from ._hybrid_compute_management_client_operations import HybridComputeManagementClientOperationsMixin +from ._extension_metadata_operations import ExtensionMetadataOperations from ._operations import Operations +from ._network_profile_operations import NetworkProfileOperations +from ._hybrid_identity_metadata_operations import HybridIdentityMetadataOperations +from ._agent_version_operations import AgentVersionOperations +from ._machine_run_commands_operations import MachineRunCommandsOperations from ._private_link_scopes_operations import PrivateLinkScopesOperations from ._private_link_resources_operations import PrivateLinkResourcesOperations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations @@ -19,10 +26,17 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ + "LicensesOperations", "MachinesOperations", + "LicenseProfilesOperations", "MachineExtensionsOperations", "HybridComputeManagementClientOperationsMixin", + "ExtensionMetadataOperations", "Operations", + "NetworkProfileOperations", + "HybridIdentityMetadataOperations", + "AgentVersionOperations", + "MachineRunCommandsOperations", "PrivateLinkScopesOperations", "PrivateLinkResourcesOperations", "PrivateEndpointConnectionsOperations", diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_agent_version_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_agent_version_operations.py new file mode 100644 index 000000000000..de52b12e4526 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_agent_version_operations.py @@ -0,0 +1,219 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import HybridComputeManagementClientMixinABC, _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(os_type: 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-10-03-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.HybridCompute/osType/{osType}/agentVersions") + path_format_arguments = { + "osType": _SERIALIZER.url("os_type", os_type, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(os_type: str, version: 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-10-03-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.HybridCompute/osType/{osType}/agentVersions/{version}") + path_format_arguments = { + "osType": _SERIALIZER.url("os_type", os_type, "str"), + "version": _SERIALIZER.url("version", version, "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) + + +class AgentVersionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridcompute.HybridComputeManagementClient`'s + :attr:`agent_version` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, os_type: str, **kwargs: Any) -> _models.AgentVersionsList: + """Gets all Agent Versions along with the download link currently present. + + :param os_type: Defines the os type. Required. + :type os_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AgentVersionsList or the result of cls(response) + :rtype: ~azure.mgmt.hybridcompute.models.AgentVersionsList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AgentVersionsList] = kwargs.pop("cls", None) + + request = build_list_request( + os_type=os_type, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AgentVersionsList", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {"url": "/providers/Microsoft.HybridCompute/osType/{osType}/agentVersions"} + + @distributed_trace + def get(self, os_type: str, version: str, **kwargs: Any) -> _models.AgentVersion: + """Gets an Agent Version along with the download link currently present. + + :param os_type: Defines the os type. Required. + :type os_type: str + :param version: Defines the agent version. To get latest, use latest or else a specific agent + version. Required. + :type version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AgentVersion or the result of cls(response) + :rtype: ~azure.mgmt.hybridcompute.models.AgentVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AgentVersion] = kwargs.pop("cls", None) + + request = build_get_request( + os_type=os_type, + version=version, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AgentVersion", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/providers/Microsoft.HybridCompute/osType/{osType}/agentVersions/{version}"} diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_extension_metadata_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_extension_metadata_operations.py new file mode 100644 index 000000000000..3bdafcd22671 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_extension_metadata_operations.py @@ -0,0 +1,285 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import HybridComputeManagementClientMixinABC, _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + location: str, publisher: str, extension_type: str, version: 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-10-03-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.HybridCompute/locations/{location}/publishers/{publisher}/extensionTypes/{extensionType}/versions/{version}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), + "publisher": _SERIALIZER.url("publisher", publisher, "str"), + "extensionType": _SERIALIZER.url("extension_type", extension_type, "str"), + "version": _SERIALIZER.url("version", version, "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_list_request( + location: str, publisher: str, extension_type: 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-10-03-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.HybridCompute/locations/{location}/publishers/{publisher}/extensionTypes/{extensionType}/versions", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), + "publisher": _SERIALIZER.url("publisher", publisher, "str"), + "extensionType": _SERIALIZER.url("extension_type", extension_type, "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) + + +class ExtensionMetadataOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridcompute.HybridComputeManagementClient`'s + :attr:`extension_metadata` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, location: str, publisher: str, extension_type: str, version: str, **kwargs: Any + ) -> _models.ExtensionValue: + """Gets an Extension Metadata based on location, publisher, extensionType and version. + + :param location: The location of the Extension being received. Required. + :type location: str + :param publisher: The publisher of the Extension being received. Required. + :type publisher: str + :param extension_type: The extensionType of the Extension being received. Required. + :type extension_type: str + :param version: The version of the Extension being received. Required. + :type version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ExtensionValue or the result of cls(response) + :rtype: ~azure.mgmt.hybridcompute.models.ExtensionValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ExtensionValue] = kwargs.pop("cls", None) + + request = build_get_request( + location=location, + publisher=publisher, + extension_type=extension_type, + version=version, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ExtensionValue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.HybridCompute/locations/{location}/publishers/{publisher}/extensionTypes/{extensionType}/versions/{version}" + } + + @distributed_trace + def list( + self, location: str, publisher: str, extension_type: str, **kwargs: Any + ) -> Iterable["_models.ExtensionValue"]: + """Gets all Extension versions based on location, publisher, extensionType. + + :param location: The location of the Extension being received. Required. + :type location: str + :param publisher: The publisher of the Extension being received. Required. + :type publisher: str + :param extension_type: The extensionType of the Extension being received. Required. + :type extension_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExtensionValue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridcompute.models.ExtensionValue] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ExtensionValueListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + location=location, + publisher=publisher, + extension_type=extension_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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 = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ExtensionValueListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.HybridCompute/locations/{location}/publishers/{publisher}/extensionTypes/{extensionType}/versions" + } diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_hybrid_compute_management_client_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_hybrid_compute_management_client_operations.py index 3bf746ea295b..306393d469da 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_hybrid_compute_management_client_operations.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_hybrid_compute_management_client_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -28,12 +28,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import HybridComputeManagementClientMixinABC, _convert_request, _format_url_section +from .._vendor import HybridComputeManagementClientMixinABC, _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_upgrade_extensions_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -61,10 +57,12 @@ def build_upgrade_extensions_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "machineName": _SERIALIZER.url("machine_name", machine_name, "str"), + "machineName": _SERIALIZER.url( + "machine_name", machine_name, "str", max_length=54, min_length=1, pattern=r"^[a-zA-Z0-9-_\.]{1,54}$" + ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -96,16 +94,14 @@ def _upgrade_extensions_initial( # pylint: disable=inconsistent-return-statemen _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(extension_upgrade_parameters, (IO, bytes)): + if isinstance(extension_upgrade_parameters, (IOBase, bytes)): _content = extension_upgrade_parameters else: _json = self._serialize.body(extension_upgrade_parameters, "MachineExtensionUpgrade") @@ -125,8 +121,9 @@ def _upgrade_extensions_initial( # pylint: disable=inconsistent-return-statemen request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -136,8 +133,16 @@ def _upgrade_extensions_initial( # pylint: disable=inconsistent-return-statemen error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) 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")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, response_headers) _upgrade_extensions_initial.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/upgradeExtensions" @@ -231,7 +236,7 @@ def begin_upgrade_extensions( :param machine_name: The name of the hybrid machine. Required. :type machine_name: str :param extension_upgrade_parameters: Parameters supplied to the Upgrade Extensions operation. - Is either a model type or a IO type. Required. + Is either a MachineExtensionUpgrade type or a IO type. Required. :type extension_upgrade_parameters: ~azure.mgmt.hybridcompute.models.MachineExtensionUpgrade or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -252,9 +257,7 @@ def begin_upgrade_extensions( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_hybrid_identity_metadata_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_hybrid_identity_metadata_operations.py new file mode 100644 index 000000000000..d02becffb769 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_hybrid_identity_metadata_operations.py @@ -0,0 +1,292 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import HybridComputeManagementClientMixinABC, _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, machine_name: str, metadata_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-10-03-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/hybridIdentityMetadata/{metadataName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "machineName": _SERIALIZER.url( + "machine_name", machine_name, "str", max_length=54, min_length=1, pattern=r"^[a-zA-Z0-9-_\.]{1,54}$" + ), + "metadataName": _SERIALIZER.url("metadata_name", metadata_name, "str", pattern=r"^[a-zA-Z0-9-_\.]{1,54}$"), + } + + _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_list_by_machines_request( + resource_group_name: str, machine_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-10-03-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/hybridIdentityMetadata", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "machineName": _SERIALIZER.url( + "machine_name", machine_name, "str", max_length=54, min_length=1, pattern=r"^[a-zA-Z0-9-_\.]{1,54}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class HybridIdentityMetadataOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridcompute.HybridComputeManagementClient`'s + :attr:`hybrid_identity_metadata` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, machine_name: str, metadata_name: str, **kwargs: Any + ) -> _models.HybridIdentityMetadata: + """Gets HybridIdentityMetadata. + + Implements HybridIdentityMetadata GET method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param metadata_name: Name of the HybridIdentityMetadata. Required. + :type metadata_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HybridIdentityMetadata or the result of cls(response) + :rtype: ~azure.mgmt.hybridcompute.models.HybridIdentityMetadata + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.HybridIdentityMetadata] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + metadata_name=metadata_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("HybridIdentityMetadata", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/hybridIdentityMetadata/{metadataName}" + } + + @distributed_trace + def list_by_machines( + self, resource_group_name: str, machine_name: str, **kwargs: Any + ) -> Iterable["_models.HybridIdentityMetadata"]: + """Implements GET HybridIdentityMetadata in a machine. + + Returns the list of HybridIdentityMetadata of the given machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either HybridIdentityMetadata or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridcompute.models.HybridIdentityMetadata] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.HybridIdentityMetadataList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_machines_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_machines.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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 = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("HybridIdentityMetadataList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_machines.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/hybridIdentityMetadata" + } diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_license_profiles_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_license_profiles_operations.py new file mode 100644 index 000000000000..c3c372bf5f74 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_license_profiles_operations.py @@ -0,0 +1,1011 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import HybridComputeManagementClientMixinABC, _convert_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_or_update_request( + resource_group_name: str, machine_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-10-03-preview")) + license_profile_name: Literal["default"] = kwargs.pop("license_profile_name", "default") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/licenseProfiles/{licenseProfileName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "machineName": _SERIALIZER.url("machine_name", machine_name, "str", pattern=r"[a-zA-Z0-9-_\.]+"), + "licenseProfileName": _SERIALIZER.url("license_profile_name", license_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_update_request( + resource_group_name: str, machine_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-10-03-preview")) + license_profile_name: Literal["default"] = kwargs.pop("license_profile_name", "default") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/licenseProfiles/{licenseProfileName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "machineName": _SERIALIZER.url("machine_name", machine_name, "str", pattern=r"[a-zA-Z0-9-_\.]+"), + "licenseProfileName": _SERIALIZER.url("license_profile_name", license_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_get_request(resource_group_name: str, machine_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-10-03-preview")) + license_profile_name: Literal["default"] = kwargs.pop("license_profile_name", "default") + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/licenseProfiles/{licenseProfileName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "machineName": _SERIALIZER.url("machine_name", machine_name, "str", pattern=r"[a-zA-Z0-9-_\.]+"), + "licenseProfileName": _SERIALIZER.url("license_profile_name", license_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_delete_request( + resource_group_name: str, machine_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-10-03-preview")) + license_profile_name: Literal["default"] = kwargs.pop("license_profile_name", "default") + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/licenseProfiles/{licenseProfileName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "machineName": _SERIALIZER.url("machine_name", machine_name, "str", pattern=r"[a-zA-Z0-9-_\.]+"), + "licenseProfileName": _SERIALIZER.url("license_profile_name", license_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_list_request(resource_group_name: str, machine_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-10-03-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/licenseProfiles", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "machineName": _SERIALIZER.url( + "machine_name", machine_name, "str", max_length=54, min_length=1, pattern=r"^[a-zA-Z0-9-_\.]{1,54}$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class LicenseProfilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridcompute.HybridComputeManagementClient`'s + :attr:`license_profiles` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _create_or_update_initial( + self, resource_group_name: str, machine_name: str, parameters: Union[_models.LicenseProfile, IO], **kwargs: Any + ) -> _models.LicenseProfile: + error_map = { + 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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + license_profile_name: Literal["default"] = kwargs.pop("license_profile_name", "default") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LicenseProfile] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LicenseProfile") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + license_profile_name=license_profile_name, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("LicenseProfile", pipeline_response) + + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("LicenseProfile", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/licenseProfiles/{licenseProfileName}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + machine_name: str, + parameters: _models.LicenseProfile, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LicenseProfile]: + """The operation to create or update a license profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param parameters: Parameters supplied to the Create or Update license profile operation. + Required. + :type parameters: ~azure.mgmt.hybridcompute.models.LicenseProfile + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword license_profile_name: The name of the license profile. Default value is "default". + Note that overriding this default value may result in unsupported behavior. + :paramtype license_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LicenseProfile or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.LicenseProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + machine_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LicenseProfile]: + """The operation to create or update a license profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param parameters: Parameters supplied to the Create or Update license profile operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword license_profile_name: The name of the license profile. Default value is "default". + Note that overriding this default value may result in unsupported behavior. + :paramtype license_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LicenseProfile or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.LicenseProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, machine_name: str, parameters: Union[_models.LicenseProfile, IO], **kwargs: Any + ) -> LROPoller[_models.LicenseProfile]: + """The operation to create or update a license profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param parameters: Parameters supplied to the Create or Update license profile operation. Is + either a LicenseProfile type or a IO type. Required. + :type parameters: ~azure.mgmt.hybridcompute.models.LicenseProfile or IO + :keyword license_profile_name: The name of the license profile. Default value is "default". + Note that overriding this default value may result in unsupported behavior. + :paramtype license_profile_name: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LicenseProfile or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.LicenseProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", self._config.api_version)) + license_profile_name: Literal["default"] = kwargs.pop("license_profile_name", "default") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LicenseProfile] = 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_update_initial( + resource_group_name=resource_group_name, + machine_name=machine_name, + parameters=parameters, + api_version=api_version, + license_profile_name=license_profile_name, + 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): + deserialized = self._deserialize("LicenseProfile", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + 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.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/licenseProfiles/{licenseProfileName}" + } + + def _update_initial( + self, + resource_group_name: str, + machine_name: str, + parameters: Union[_models.LicenseProfileUpdate, IO], + **kwargs: Any + ) -> Optional[_models.LicenseProfile]: + error_map = { + 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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + license_profile_name: Literal["default"] = kwargs.pop("license_profile_name", "default") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.LicenseProfile]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LicenseProfileUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + license_profile_name=license_profile_name, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("LicenseProfile", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/licenseProfiles/{licenseProfileName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + machine_name: str, + parameters: _models.LicenseProfileUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LicenseProfile]: + """The operation to update a license profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param parameters: Parameters supplied to the Update license profile operation. Required. + :type parameters: ~azure.mgmt.hybridcompute.models.LicenseProfileUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword license_profile_name: The name of the license profile. Default value is "default". + Note that overriding this default value may result in unsupported behavior. + :paramtype license_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LicenseProfile or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.LicenseProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + machine_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LicenseProfile]: + """The operation to update a license profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param parameters: Parameters supplied to the Update license profile operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword license_profile_name: The name of the license profile. Default value is "default". + Note that overriding this default value may result in unsupported behavior. + :paramtype license_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LicenseProfile or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.LicenseProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + machine_name: str, + parameters: Union[_models.LicenseProfileUpdate, IO], + **kwargs: Any + ) -> LROPoller[_models.LicenseProfile]: + """The operation to update a license profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param parameters: Parameters supplied to the Update license profile operation. Is either a + LicenseProfileUpdate type or a IO type. Required. + :type parameters: ~azure.mgmt.hybridcompute.models.LicenseProfileUpdate or IO + :keyword license_profile_name: The name of the license profile. Default value is "default". + Note that overriding this default value may result in unsupported behavior. + :paramtype license_profile_name: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LicenseProfile or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.LicenseProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", self._config.api_version)) + license_profile_name: Literal["default"] = kwargs.pop("license_profile_name", "default") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LicenseProfile] = 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, + machine_name=machine_name, + parameters=parameters, + api_version=api_version, + license_profile_name=license_profile_name, + 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): + deserialized = self._deserialize("LicenseProfile", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + 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.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/licenseProfiles/{licenseProfileName}" + } + + @distributed_trace + def get(self, resource_group_name: str, machine_name: str, **kwargs: Any) -> _models.LicenseProfile: + """Retrieves information about the view of a license profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :keyword license_profile_name: The name of the license profile. Default value is "default". + Note that overriding this default value may result in unsupported behavior. + :paramtype license_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LicenseProfile or the result of cls(response) + :rtype: ~azure.mgmt.hybridcompute.models.LicenseProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + license_profile_name: Literal["default"] = kwargs.pop("license_profile_name", "default") + cls: ClsType[_models.LicenseProfile] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + license_profile_name=license_profile_name, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LicenseProfile", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/licenseProfiles/{licenseProfileName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, machine_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + license_profile_name: Literal["default"] = kwargs.pop("license_profile_name", "default") + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + license_profile_name=license_profile_name, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/licenseProfiles/{licenseProfileName}" + } + + @distributed_trace + def begin_delete(self, resource_group_name: str, machine_name: str, **kwargs: Any) -> LROPoller[None]: + """The operation to delete a license profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :keyword license_profile_name: The name of the license profile. Default value is "default". + Note that overriding this default value may result in unsupported behavior. + :paramtype license_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + license_profile_name: Literal["default"] = kwargs.pop("license_profile_name", "default") + 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, + machine_name=machine_name, + api_version=api_version, + license_profile_name=license_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, {}) + + 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.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/licenseProfiles/{licenseProfileName}" + } + + @distributed_trace + def list(self, resource_group_name: str, machine_name: str, **kwargs: Any) -> Iterable["_models.LicenseProfile"]: + """The operation to get all license profiles of a non-Azure machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the machine. Required. + :type machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LicenseProfile or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridcompute.models.LicenseProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LicenseProfilesListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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 = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("LicenseProfilesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/licenseProfiles" + } diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_licenses_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_licenses_operations.py new file mode 100644 index 000000000000..02aca2d69f79 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_licenses_operations.py @@ -0,0 +1,1223 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import HybridComputeManagementClientMixinABC, _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_validate_license_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridCompute/validateLicense" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, license_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-10-03-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/licenses/{licenseName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "licenseName": _SERIALIZER.url("license_name", license_name, "str", pattern=r"[a-zA-Z0-9-_\.]+"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + 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_update_request( + resource_group_name: str, license_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-10-03-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/licenses/{licenseName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "licenseName": _SERIALIZER.url("license_name", license_name, "str", pattern=r"[a-zA-Z0-9-_\.]+"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + 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_get_request(resource_group_name: str, license_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-10-03-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/licenses/{licenseName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "licenseName": _SERIALIZER.url("license_name", license_name, "str", pattern=r"[a-zA-Z0-9-_\.]+"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, license_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-10-03-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/licenses/{licenseName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "licenseName": _SERIALIZER.url("license_name", license_name, "str", pattern=r"[a-zA-Z0-9-_\.]+"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(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-10-03-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/licenses", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HybridCompute/licenses") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class LicensesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridcompute.HybridComputeManagementClient`'s + :attr:`licenses` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _validate_license_initial(self, parameters: Union[_models.License, IO], **kwargs: Any) -> _models.License: + error_map = { + 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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.License] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "License") + + request = build_validate_license_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._validate_license_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("License", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _validate_license_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.HybridCompute/validateLicense" + } + + @overload + def begin_validate_license( + self, parameters: _models.License, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.License]: + """The operation to validate a license. + + :param parameters: Parameters supplied to the license validation operation. Required. + :type parameters: ~azure.mgmt.hybridcompute.models.License + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either License or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.License] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate_license( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.License]: + """The operation to validate a license. + + :param parameters: Parameters supplied to the license validation operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either License or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.License] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_license( + self, parameters: Union[_models.License, IO], **kwargs: Any + ) -> LROPoller[_models.License]: + """The operation to validate a license. + + :param parameters: Parameters supplied to the license validation operation. Is either a License + type or a IO type. Required. + :type parameters: ~azure.mgmt.hybridcompute.models.License or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either License or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.License] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.License] = 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._validate_license_initial( + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("License", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + 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.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_validate_license.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.HybridCompute/validateLicense" + } + + def _create_or_update_initial( + self, resource_group_name: str, license_name: str, parameters: Union[_models.License, IO], **kwargs: Any + ) -> _models.License: + error_map = { + 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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.License] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "License") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + license_name=license_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("License", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/licenses/{licenseName}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + license_name: str, + parameters: _models.License, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.License]: + """The operation to create or update a license. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param license_name: The name of the license. Required. + :type license_name: str + :param parameters: Parameters supplied to the Create license operation. Required. + :type parameters: ~azure.mgmt.hybridcompute.models.License + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either License or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.License] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + license_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.License]: + """The operation to create or update a license. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param license_name: The name of the license. Required. + :type license_name: str + :param parameters: Parameters supplied to the Create license operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either License or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.License] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, license_name: str, parameters: Union[_models.License, IO], **kwargs: Any + ) -> LROPoller[_models.License]: + """The operation to create or update a license. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param license_name: The name of the license. Required. + :type license_name: str + :param parameters: Parameters supplied to the Create license operation. Is either a License + type or a IO type. Required. + :type parameters: ~azure.mgmt.hybridcompute.models.License or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either License or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.License] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.License] = 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_update_initial( + resource_group_name=resource_group_name, + license_name=license_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("License", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + 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.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/licenses/{licenseName}" + } + + def _update_initial( + self, resource_group_name: str, license_name: str, parameters: Union[_models.LicenseUpdate, IO], **kwargs: Any + ) -> _models.License: + error_map = { + 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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.License] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LicenseUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + license_name=license_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("License", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/licenses/{licenseName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + license_name: str, + parameters: _models.LicenseUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.License]: + """The operation to update a license. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param license_name: The name of the license. Required. + :type license_name: str + :param parameters: Parameters supplied to the Update license operation. Required. + :type parameters: ~azure.mgmt.hybridcompute.models.LicenseUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either License or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.License] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + license_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.License]: + """The operation to update a license. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param license_name: The name of the license. Required. + :type license_name: str + :param parameters: Parameters supplied to the Update license operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either License or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.License] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, license_name: str, parameters: Union[_models.LicenseUpdate, IO], **kwargs: Any + ) -> LROPoller[_models.License]: + """The operation to update a license. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param license_name: The name of the license. Required. + :type license_name: str + :param parameters: Parameters supplied to the Update license operation. Is either a + LicenseUpdate type or a IO type. Required. + :type parameters: ~azure.mgmt.hybridcompute.models.LicenseUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either License or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.License] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.License] = 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, + license_name=license_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("License", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + 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.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/licenses/{licenseName}" + } + + @distributed_trace + def get(self, resource_group_name: str, license_name: str, **kwargs: Any) -> _models.License: + """Retrieves information about the view of a license. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param license_name: The name of the license. Required. + :type license_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: License or the result of cls(response) + :rtype: ~azure.mgmt.hybridcompute.models.License + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.License] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + license_name=license_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("License", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/licenses/{licenseName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, license_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + license_name=license_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/licenses/{licenseName}" + } + + @distributed_trace + def begin_delete(self, resource_group_name: str, license_name: str, **kwargs: Any) -> LROPoller[None]: + """The operation to delete a license. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param license_name: The name of the license. Required. + :type license_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[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, + license_name=license_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + 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.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/licenses/{licenseName}" + } + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.License"]: + """The operation to get all licenses of a non-Azure machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either License or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridcompute.models.License] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LicensesListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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 = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("LicensesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/licenses" + } + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.License"]: + """The operation to get all licenses of a non-Azure machine. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either License or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridcompute.models.License] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LicensesListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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 = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("LicensesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.HybridCompute/licenses" + } diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_machine_extensions_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_machine_extensions_operations.py index 1362e42cc39a..312eb39c4de9 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_machine_extensions_operations.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_machine_extensions_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,12 +30,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import HybridComputeManagementClientMixinABC, _convert_request, _format_url_section +from .._vendor import HybridComputeManagementClientMixinABC, _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +45,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -62,12 +58,14 @@ def build_create_or_update_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "machineName": _SERIALIZER.url("machine_name", machine_name, "str"), + "machineName": _SERIALIZER.url( + "machine_name", machine_name, "str", max_length=54, min_length=1, pattern=r"^[a-zA-Z0-9-_\.]{1,54}$" + ), "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -86,7 +84,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -99,12 +97,14 @@ def build_update_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "machineName": _SERIALIZER.url("machine_name", machine_name, "str"), + "machineName": _SERIALIZER.url( + "machine_name", machine_name, "str", max_length=54, min_length=1, pattern=r"^[a-zA-Z0-9-_\.]{1,54}$" + ), "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -123,7 +123,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -135,12 +135,14 @@ def build_delete_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "machineName": _SERIALIZER.url("machine_name", machine_name, "str"), + "machineName": _SERIALIZER.url( + "machine_name", machine_name, "str", max_length=54, min_length=1, pattern=r"^[a-zA-Z0-9-_\.]{1,54}$" + ), "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -157,7 +159,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -169,12 +171,14 @@ def build_get_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "machineName": _SERIALIZER.url("machine_name", machine_name, "str"), + "machineName": _SERIALIZER.url( + "machine_name", machine_name, "str", max_length=54, min_length=1, pattern=r"^[a-zA-Z0-9-_\.]{1,54}$" + ), "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -191,7 +195,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -203,11 +207,13 @@ def build_list_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "machineName": _SERIALIZER.url("machine_name", machine_name, "str"), + "machineName": _SERIALIZER.url( + "machine_name", machine_name, "str", max_length=54, min_length=1, pattern=r"^[a-zA-Z0-9-_\.]{1,54}$" + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if expand is not None: @@ -258,16 +264,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.MachineExtension]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(extension_parameters, (IO, bytes)): + if isinstance(extension_parameters, (IOBase, bytes)): _content = extension_parameters else: _json = self._serialize.body(extension_parameters, "MachineExtension") @@ -288,8 +292,9 @@ def _create_or_update_initial( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -414,7 +419,7 @@ def begin_create_or_update( :param extension_name: The name of the machine extension. Required. :type extension_name: str :param extension_parameters: Parameters supplied to the Create Machine Extension operation. Is - either a model type or a IO type. Required. + either a MachineExtension type or a IO type. Required. :type extension_parameters: ~azure.mgmt.hybridcompute.models.MachineExtension or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -435,9 +440,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -502,16 +505,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.MachineExtension]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(extension_parameters, (IO, bytes)): + if isinstance(extension_parameters, (IOBase, bytes)): _content = extension_parameters else: _json = self._serialize.body(extension_parameters, "MachineExtensionUpdate") @@ -532,8 +533,9 @@ def _update_initial( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -544,11 +546,19 @@ def _update_initial( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize("MachineExtension", pipeline_response) + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, response_headers) return deserialized @@ -658,7 +668,7 @@ def begin_update( :param extension_name: The name of the machine extension. Required. :type extension_name: str :param extension_parameters: Parameters supplied to the Create Machine Extension operation. Is - either a model type or a IO type. Required. + either a MachineExtensionUpdate type or a IO type. Required. :type extension_parameters: ~azure.mgmt.hybridcompute.models.MachineExtensionUpdate or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -679,9 +689,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -741,9 +749,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -759,8 +765,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -770,8 +777,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) 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")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, response_headers) _delete_initial.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/extensions/{extensionName}" @@ -805,9 +820,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) 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) @@ -877,9 +890,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None) request = build_get_request( @@ -895,8 +906,9 @@ def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -938,9 +950,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MachineExtensionsListResult] = kwargs.pop("cls", None) error_map = { @@ -995,8 +1005,9 @@ def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_machine_run_commands_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_machine_run_commands_operations.py new file mode 100644 index 000000000000..70548401f357 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_machine_run_commands_operations.py @@ -0,0 +1,1018 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import HybridComputeManagementClientMixinABC, _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_or_update_request( + resource_group_name: str, machine_name: str, run_command_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-10-03-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands/{runCommandName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "machineName": _SERIALIZER.url("machine_name", machine_name, "str", pattern=r"[a-zA-Z0-9-_\.]+"), + "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str", pattern=r"[a-zA-Z0-9-_\.]+"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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_update_request( + resource_group_name: str, machine_name: str, run_command_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-10-03-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands/{runCommandName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "machineName": _SERIALIZER.url("machine_name", machine_name, "str", pattern=r"[a-zA-Z0-9-_\.]+"), + "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str", pattern=r"[a-zA-Z0-9-_\.]+"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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_delete_request( + resource_group_name: str, machine_name: str, run_command_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-10-03-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands/{runCommandName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "machineName": _SERIALIZER.url("machine_name", machine_name, "str", pattern=r"[a-zA-Z0-9-_\.]+"), + "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str", pattern=r"[a-zA-Z0-9-_\.]+"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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_get_request( + resource_group_name: str, machine_name: str, run_command_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-10-03-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands/{runCommandName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "machineName": _SERIALIZER.url("machine_name", machine_name, "str", pattern=r"[a-zA-Z0-9-_\.]+"), + "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str", pattern=r"[a-zA-Z0-9-_\.]+"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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_list_request( + resource_group_name: str, machine_name: str, subscription_id: str, *, expand: Optional[str] = None, **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-10-03-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "machineName": _SERIALIZER.url("machine_name", machine_name, "str", pattern=r"[a-zA-Z0-9-_\.]+"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class MachineRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridcompute.HybridComputeManagementClient`'s + :attr:`machine_run_commands` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _create_or_update_initial( + self, + resource_group_name: str, + machine_name: str, + run_command_name: str, + run_command_properties: Union[_models.MachineRunCommand, IO], + **kwargs: Any + ) -> _models.MachineRunCommand: + error_map = { + 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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MachineRunCommand] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_command_properties, (IOBase, bytes)): + _content = run_command_properties + else: + _json = self._serialize.body(run_command_properties, "MachineRunCommand") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + run_command_name=run_command_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("MachineRunCommand", pipeline_response) + + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("MachineRunCommand", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands/{runCommandName}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + machine_name: str, + run_command_name: str, + run_command_properties: _models.MachineRunCommand, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MachineRunCommand]: + """The operation to create or update a run command. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param run_command_name: The name of the run command. Required. + :type run_command_name: str + :param run_command_properties: Parameters supplied to the Create Run Command. Required. + :type run_command_properties: ~azure.mgmt.hybridcompute.models.MachineRunCommand + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MachineRunCommand or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.MachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + machine_name: str, + run_command_name: str, + run_command_properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MachineRunCommand]: + """The operation to create or update a run command. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param run_command_name: The name of the run command. Required. + :type run_command_name: str + :param run_command_properties: Parameters supplied to the Create Run Command. Required. + :type run_command_properties: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MachineRunCommand or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.MachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + machine_name: str, + run_command_name: str, + run_command_properties: Union[_models.MachineRunCommand, IO], + **kwargs: Any + ) -> LROPoller[_models.MachineRunCommand]: + """The operation to create or update a run command. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param run_command_name: The name of the run command. Required. + :type run_command_name: str + :param run_command_properties: Parameters supplied to the Create Run Command. Is either a + MachineRunCommand type or a IO type. Required. + :type run_command_properties: ~azure.mgmt.hybridcompute.models.MachineRunCommand or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MachineRunCommand or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.MachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MachineRunCommand] = 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_update_initial( + resource_group_name=resource_group_name, + machine_name=machine_name, + run_command_name=run_command_name, + run_command_properties=run_command_properties, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("MachineRunCommand", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands/{runCommandName}" + } + + def _update_initial( + self, + resource_group_name: str, + machine_name: str, + run_command_name: str, + run_command_properties: Union[_models.MachineRunCommandUpdate, IO], + **kwargs: Any + ) -> Optional[_models.MachineRunCommand]: + error_map = { + 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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MachineRunCommand]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_command_properties, (IOBase, bytes)): + _content = run_command_properties + else: + _json = self._serialize.body(run_command_properties, "MachineRunCommandUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + run_command_name=run_command_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("MachineRunCommand", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands/{runCommandName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + machine_name: str, + run_command_name: str, + run_command_properties: _models.MachineRunCommandUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MachineRunCommand]: + """The operation to update the run command. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param run_command_name: The name of the run command. Required. + :type run_command_name: str + :param run_command_properties: Parameters supplied to the Create Run Command. Required. + :type run_command_properties: ~azure.mgmt.hybridcompute.models.MachineRunCommandUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MachineRunCommand or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.MachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + machine_name: str, + run_command_name: str, + run_command_properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MachineRunCommand]: + """The operation to update the run command. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param run_command_name: The name of the run command. Required. + :type run_command_name: str + :param run_command_properties: Parameters supplied to the Create Run Command. Required. + :type run_command_properties: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MachineRunCommand or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.MachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + machine_name: str, + run_command_name: str, + run_command_properties: Union[_models.MachineRunCommandUpdate, IO], + **kwargs: Any + ) -> LROPoller[_models.MachineRunCommand]: + """The operation to update the run command. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param run_command_name: The name of the run command. Required. + :type run_command_name: str + :param run_command_properties: Parameters supplied to the Create Run Command. Is either a + MachineRunCommandUpdate type or a IO type. Required. + :type run_command_properties: ~azure.mgmt.hybridcompute.models.MachineRunCommandUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MachineRunCommand or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.MachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MachineRunCommand] = 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, + machine_name=machine_name, + run_command_name=run_command_name, + run_command_properties=run_command_properties, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("MachineRunCommand", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + 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.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands/{runCommandName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, machine_name: str, run_command_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + run_command_name=run_command_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands/{runCommandName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, machine_name: str, run_command_name: str, **kwargs: Any + ) -> LROPoller[None]: + """The operation to delete a run command. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param run_command_name: The name of the run command. Required. + :type run_command_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[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, + machine_name=machine_name, + run_command_name=run_command_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands/{runCommandName}" + } + + @distributed_trace + def get( + self, resource_group_name: str, machine_name: str, run_command_name: str, **kwargs: Any + ) -> _models.MachineRunCommand: + """The operation to get a run command. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param run_command_name: The name of the run command. Required. + :type run_command_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MachineRunCommand or the result of cls(response) + :rtype: ~azure.mgmt.hybridcompute.models.MachineRunCommand + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.MachineRunCommand] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + run_command_name=run_command_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MachineRunCommand", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands/{runCommandName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, machine_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.MachineRunCommand"]: + """The operation to get all the run commands of a non-Azure machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :param expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MachineRunCommand or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridcompute.models.MachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.MachineRunCommandsListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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 = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("MachineRunCommandsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands" + } diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_machines_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_machines_operations.py index 9de684ceaf32..c5d4819b2c95 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_machines_operations.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_machines_operations.py @@ -6,8 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -21,19 +21,17 @@ from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.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 .._serialization import Serializer -from .._vendor import HybridComputeManagementClientMixinABC, _convert_request, _format_url_section +from .._vendor import HybridComputeManagementClientMixinABC, _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +45,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -60,10 +58,12 @@ def build_delete_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "machineName": _SERIALIZER.url("machine_name", machine_name, "str"), + "machineName": _SERIALIZER.url( + "machine_name", machine_name, "str", max_length=54, min_length=1, pattern=r"^[a-zA-Z0-9-_\.]{1,54}$" + ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -85,7 +85,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -98,10 +98,12 @@ def build_get_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "machineName": _SERIALIZER.url("machine_name", machine_name, "str"), + "machineName": _SERIALIZER.url( + "machine_name", machine_name, "str", max_length=54, min_length=1, pattern=r"^[a-zA-Z0-9-_\.]{1,54}$" + ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,11 +116,78 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_assess_patches_request( + resource_group_name: str, 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-10-03-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/assessPatches", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "name": _SERIALIZER.url("name", 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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_install_patches_request( + resource_group_name: str, 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-10-03-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/installPatches", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "name": _SERIALIZER.url("name", 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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request( + resource_group_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -133,10 +202,12 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -148,7 +219,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -157,7 +228,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -191,7 +262,7 @@ def __init__(self, *args, **kwargs): def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, machine_name: str, **kwargs: Any ) -> None: - """The operation to remove a hybrid machine identity in Azure. + """The operation to delete a hybrid machine. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -214,9 +285,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -231,8 +300,9 @@ def delete( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -283,9 +353,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Machine] = kwargs.pop("cls", None) request = build_get_request( @@ -301,8 +369,9 @@ def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -323,14 +392,380 @@ def get( "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}" } + def _assess_patches_initial( + self, resource_group_name: str, name: str, **kwargs: Any + ) -> Optional[_models.MachineAssessPatchesResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.MachineAssessPatchesResult]] = kwargs.pop("cls", None) + + request = build_assess_patches_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._assess_patches_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("MachineAssessPatchesResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _assess_patches_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/assessPatches" + } + + @distributed_trace + def begin_assess_patches( + self, resource_group_name: str, name: str, **kwargs: Any + ) -> LROPoller[_models.MachineAssessPatchesResult]: + """The operation to assess patches on a hybrid machine identity in Azure. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param name: The name of the hybrid machine. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MachineAssessPatchesResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.MachineAssessPatchesResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.MachineAssessPatchesResult] = 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._assess_patches_initial( + resource_group_name=resource_group_name, + name=name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("MachineAssessPatchesResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_assess_patches.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/assessPatches" + } + + def _install_patches_initial( + self, + resource_group_name: str, + name: str, + install_patches_input: Union[_models.MachineInstallPatchesParameters, IO], + **kwargs: Any + ) -> Optional[_models.MachineInstallPatchesResult]: + error_map = { + 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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MachineInstallPatchesResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(install_patches_input, (IOBase, bytes)): + _content = install_patches_input + else: + _json = self._serialize.body(install_patches_input, "MachineInstallPatchesParameters") + + request = build_install_patches_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._install_patches_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("MachineInstallPatchesResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _install_patches_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/installPatches" + } + + @overload + def begin_install_patches( + self, + resource_group_name: str, + name: str, + install_patches_input: _models.MachineInstallPatchesParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MachineInstallPatchesResult]: + """The operation to install patches on a hybrid machine identity in Azure. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param name: The name of the hybrid machine. Required. + :type name: str + :param install_patches_input: Input for InstallPatches as directly received by the API. + Required. + :type install_patches_input: ~azure.mgmt.hybridcompute.models.MachineInstallPatchesParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MachineInstallPatchesResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.MachineInstallPatchesResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_install_patches( + self, + resource_group_name: str, + name: str, + install_patches_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MachineInstallPatchesResult]: + """The operation to install patches on a hybrid machine identity in Azure. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param name: The name of the hybrid machine. Required. + :type name: str + :param install_patches_input: Input for InstallPatches as directly received by the API. + Required. + :type install_patches_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MachineInstallPatchesResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.MachineInstallPatchesResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_install_patches( + self, + resource_group_name: str, + name: str, + install_patches_input: Union[_models.MachineInstallPatchesParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.MachineInstallPatchesResult]: + """The operation to install patches on a hybrid machine identity in Azure. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param name: The name of the hybrid machine. Required. + :type name: str + :param install_patches_input: Input for InstallPatches as directly received by the API. Is + either a MachineInstallPatchesParameters type or a IO type. Required. + :type install_patches_input: ~azure.mgmt.hybridcompute.models.MachineInstallPatchesParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MachineInstallPatchesResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.MachineInstallPatchesResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MachineInstallPatchesResult] = 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._install_patches_initial( + resource_group_name=resource_group_name, + name=name, + install_patches_input=install_patches_input, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("MachineInstallPatchesResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_install_patches.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/installPatches" + } + @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Machine"]: + def list_by_resource_group( + self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Machine"]: """Lists all the hybrid machines in the specified resource group. Use the nextLink property in the response to get the next page of hybrid machines. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str + :param expand: Expands referenced resources. Default value is None. + :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Machine or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridcompute.models.Machine] @@ -339,9 +774,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MachineListResult] = kwargs.pop("cls", None) error_map = { @@ -358,6 +791,7 @@ def prepare_request(next_link=None): request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, template_url=self.list_by_resource_group.metadata["url"], headers=_headers, @@ -394,8 +828,9 @@ def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -425,9 +860,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Machine"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MachineListResult] = kwargs.pop("cls", None) error_map = { @@ -479,8 +912,9 @@ def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_network_profile_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_network_profile_operations.py new file mode 100644 index 000000000000..cb79c32c1abf --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_network_profile_operations.py @@ -0,0 +1,150 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import HybridComputeManagementClientMixinABC, _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(resource_group_name: str, machine_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-10-03-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/networkProfile", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "machineName": _SERIALIZER.url( + "machine_name", machine_name, "str", max_length=54, min_length=1, pattern=r"^[a-zA-Z0-9-_\.]{1,54}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class NetworkProfileOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hybridcompute.HybridComputeManagementClient`'s + :attr:`network_profile` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, machine_name: str, **kwargs: Any) -> _models.NetworkProfile: + """The operation to get network information of hybrid machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param machine_name: The name of the hybrid machine. Required. + :type machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NetworkProfile or the result of cls(response) + :rtype: ~azure.mgmt.hybridcompute.models.NetworkProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NetworkProfile] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + machine_name=machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NetworkProfile", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/networkProfile" + } diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_operations.py index ac2c41358c96..6af2a8a5b401 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_operations.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from .._serialization import Serializer from .._vendor import HybridComputeManagementClientMixinABC, _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +40,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -91,9 +86,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.OperationValue"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { @@ -144,8 +137,9 @@ def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_private_endpoint_connections_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_private_endpoint_connections_operations.py index 273666ba7307..5ee5d14cbfca 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_private_endpoint_connections_operations.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_private_endpoint_connections_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,12 +30,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import HybridComputeManagementClientMixinABC, _convert_request, _format_url_section +from .._vendor import HybridComputeManagementClientMixinABC, _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +49,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +68,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,7 +89,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -113,7 +109,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -136,7 +132,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -155,7 +151,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -172,7 +168,7 @@ def build_list_by_private_link_scope_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -188,7 +184,7 @@ def build_list_by_private_link_scope_request( "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -247,9 +243,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) request = build_get_request( @@ -265,8 +259,9 @@ def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -306,16 +301,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "PrivateEndpointConnection") @@ -336,8 +329,9 @@ def _create_or_update_initial( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -458,7 +452,7 @@ def begin_create_or_update( :type scope_name: str :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :param parameters: Is either a model type or a IO type. Required. + :param parameters: Is either a PrivateEndpointConnection type or a IO type. Required. :type parameters: ~azure.mgmt.hybridcompute.models.PrivateEndpointConnection or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -480,9 +474,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -542,9 +534,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -560,8 +550,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -571,8 +562,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) 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")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, response_headers) _delete_initial.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" @@ -606,9 +605,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) 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) @@ -670,9 +667,7 @@ def list_by_private_link_scope( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) error_map = { @@ -726,8 +721,9 @@ def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_private_link_resources_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_private_link_resources_operations.py index 1996f1c9bba4..94ffd19dae3f 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_private_link_resources_operations.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_private_link_resources_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -28,12 +27,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import HybridComputeManagementClientMixinABC, _convert_request, _format_url_section +from .._vendor import HybridComputeManagementClientMixinABC, _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +42,7 @@ def build_list_by_private_link_scope_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +58,7 @@ def build_list_by_private_link_scope_request( "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +75,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,7 +92,7 @@ def build_get_request( "groupName": _SERIALIZER.url("group_name", group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -146,9 +141,7 @@ def list_by_private_link_scope( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) error_map = { @@ -202,8 +195,9 @@ def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -249,9 +243,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) request = build_get_request( @@ -267,8 +259,9 @@ def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_private_link_scopes_operations.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_private_link_scopes_operations.py index f67a6360fb4c..a9d171cce958 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_private_link_scopes_operations.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/azure/mgmt/hybridcompute/operations/_private_link_scopes_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,12 +30,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import HybridComputeManagementClientMixinABC, _convert_request, _format_url_section +from .._vendor import HybridComputeManagementClientMixinABC, _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -58,7 +54,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -73,7 +69,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -88,7 +84,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -103,7 +99,7 @@ def build_delete_request(resource_group_name: str, scope_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -119,7 +115,7 @@ def build_delete_request(resource_group_name: str, scope_name: str, subscription "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -134,7 +130,7 @@ def build_get_request(resource_group_name: str, scope_name: str, subscription_id _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -150,7 +146,7 @@ def build_get_request(resource_group_name: str, scope_name: str, subscription_id "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -167,7 +163,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -184,7 +180,7 @@ def build_create_or_update_request( "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -203,7 +199,7 @@ def build_update_tags_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -220,7 +216,7 @@ def build_update_tags_request( "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -239,7 +235,7 @@ def build_get_validation_details_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -253,7 +249,7 @@ def build_get_validation_details_request( "privateLinkScopeId": _SERIALIZER.url("private_link_scope_id", private_link_scope_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -270,7 +266,7 @@ def build_get_validation_details_for_machine_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-10")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -286,7 +282,7 @@ def build_get_validation_details_for_machine_request( "machineName": _SERIALIZER.url("machine_name", machine_name, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -330,9 +326,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.HybridComputePrivateLinkScope _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.HybridComputePrivateLinkScopeListResult] = kwargs.pop("cls", None) error_map = { @@ -384,8 +378,9 @@ def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -419,9 +414,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.HybridComputePrivateLinkScopeListResult] = kwargs.pop("cls", None) error_map = { @@ -474,8 +467,9 @@ def extract_data(pipeline_response): 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=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -506,9 +500,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -523,8 +515,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -534,8 +527,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) 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")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, response_headers) _delete_initial.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/privateLinkScopes/{scopeName}" @@ -565,9 +566,7 @@ def begin_delete(self, resource_group_name: str, scope_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) 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) @@ -632,9 +631,7 @@ def get(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> _mode _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.HybridComputePrivateLinkScope] = kwargs.pop("cls", None) request = build_get_request( @@ -649,8 +646,9 @@ def get(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> _mode request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -748,7 +746,8 @@ def create_or_update( :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. :type scope_name: str :param parameters: Properties that need to be specified to create or update a Azure Arc for - Servers and Clusters PrivateLinkScope. Is either a model type or a IO type. Required. + Servers and Clusters PrivateLinkScope. Is either a HybridComputePrivateLinkScope type or a IO + type. Required. :type parameters: ~azure.mgmt.hybridcompute.models.HybridComputePrivateLinkScope or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -769,16 +768,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.HybridComputePrivateLinkScope] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "HybridComputePrivateLinkScope") @@ -798,8 +795,9 @@ def create_or_update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -901,7 +899,7 @@ def update_tags( :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. :type scope_name: str :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope - instance. Is either a model type or a IO type. Required. + instance. Is either a TagsResource type or a IO type. Required. :type private_link_scope_tags: ~azure.mgmt.hybridcompute.models.TagsResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -922,16 +920,14 @@ def update_tags( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.HybridComputePrivateLinkScope] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_link_scope_tags, (IO, bytes)): + if isinstance(private_link_scope_tags, (IOBase, bytes)): _content = private_link_scope_tags else: _json = self._serialize.body(private_link_scope_tags, "TagsResource") @@ -951,8 +947,9 @@ def update_tags( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1000,9 +997,7 @@ def get_validation_details( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkScopeValidationDetails] = kwargs.pop("cls", None) request = build_get_validation_details_request( @@ -1017,8 +1012,9 @@ def get_validation_details( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1067,9 +1063,7 @@ def get_validation_details_for_machine( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-10"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkScopeValidationDetails] = kwargs.pop("cls", None) request = build_get_validation_details_for_machine_request( @@ -1084,8 +1078,9 @@ def get_validation_details_for_machine( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/agent_version_get_latest.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/agent_version_get_latest.py new file mode 100644 index 000000000000..c05bdda5d58f --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/agent_version_get_latest.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python agent_version_get_latest.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.agent_version.get( + os_type="myOsType", + version="1.27", + ) + print(response) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/AgentVersion_GetLatest.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/agent_versions_get.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/agent_versions_get.py new file mode 100644 index 000000000000..8f9dddc469bf --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/agent_versions_get.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python agent_versions_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.agent_version.list( + os_type="myOsType", + ) + print(response) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/AgentVersions_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/put_extension.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extension_create_or_update.py similarity index 93% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/put_extension.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extension_create_or_update.py index f0c1acd58846..cdabcc880f85 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/put_extension.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extension_create_or_update.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-hybridcompute # USAGE - python put_extension.py + python extension_create_or_update.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/PUTExtension.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/extension/Extension_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/delete_extension.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extension_delete.py similarity index 88% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/delete_extension.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extension_delete.py index 815837a8162d..94a06c845247 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/delete_extension.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extension_delete.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-hybridcompute # USAGE - python delete_extension.py + python extension_delete.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -29,14 +29,13 @@ def main(): subscription_id="{subscriptionId}", ) - response = client.machine_extensions.begin_delete( + client.machine_extensions.begin_delete( resource_group_name="myResourceGroup", machine_name="myMachine", extension_name="MMA", ).result() - print(response) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/DELETEExtension.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/extension/Extension_Delete.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/get_extension.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extension_get.py similarity index 92% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/get_extension.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extension_get.py index 3810ab40ff02..9c3246c607f0 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/get_extension.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extension_get.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-hybridcompute # USAGE - python get_extension.py + python extension_get.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/GETExtension.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/extension/Extension_Get.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/list_extension.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extension_list.py similarity index 92% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/list_extension.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extension_list.py index d08aeda3992c..e17f9a361e1b 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/list_extension.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extension_list.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-hybridcompute # USAGE - python list_extension.py + python extension_list.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/LISTExtension.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/extension/Extension_List.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extension_metadata_get.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extension_metadata_get.py new file mode 100644 index 000000000000..24d5ac215085 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extension_metadata_get.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python extension_metadata_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.extension_metadata.get( + location="EastUS", + publisher="microsoft.azure.monitor", + extension_type="azuremonitorlinuxagent", + version="1.9.1", + ) + print(response) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/extension/ExtensionMetadata_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extension_metadata_list.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extension_metadata_list.py new file mode 100644 index 000000000000..e71a52cd3eea --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extension_metadata_list.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python extension_metadata_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + response = client.extension_metadata.list( + location="EastUS", + publisher="microsoft.azure.monitor", + extension_type="azuremonitorlinuxagent", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/extension/ExtensionMetadata_List.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/update_extension.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extension_update.py similarity index 91% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/update_extension.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extension_update.py index 59f1c0959211..927247c9186a 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/update_extension.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extension_update.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-hybridcompute # USAGE - python update_extension.py + python extension_update.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -35,6 +35,7 @@ def main(): extension_name="CustomScriptExtension", extension_parameters={ "properties": { + "enableAutomaticUpgrade": True, "publisher": "Microsoft.Compute", "settings": {"commandToExecute": 'powershell.exe -c "Get-Process | Where-Object { $_.CPU -lt 100 }"'}, "type": "CustomScriptExtension", @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/UpdateExtension.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/extension/Extension_Update.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extensions_upgrade.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extensions_upgrade.py similarity index 92% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extensions_upgrade.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extensions_upgrade.py index bc32f852f1be..0ee6412781e8 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extensions_upgrade.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/extension/extensions_upgrade.py @@ -29,7 +29,7 @@ def main(): subscription_id="{subscriptionId}", ) - response = client.begin_upgrade_extensions( + client.begin_upgrade_extensions( resource_group_name="myResourceGroup", machine_name="myMachine", extension_upgrade_parameters={ @@ -39,9 +39,8 @@ def main(): } }, ).result() - print(response) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/Extensions_Upgrade.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/extension/Extensions_Upgrade.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/hybrid_identity_metadata_get.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/hybrid_identity_metadata_get.py new file mode 100644 index 000000000000..8ca7cfde687d --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/hybrid_identity_metadata_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python hybrid_identity_metadata_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.hybrid_identity_metadata.get( + resource_group_name="testrg", + machine_name="ContosoVm", + metadata_name="default", + ) + print(response) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/HybridIdentityMetadata_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/hybrid_identity_metadata_list_by_virtual_machines.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/hybrid_identity_metadata_list_by_virtual_machines.py new file mode 100644 index 000000000000..d8e3a57a4236 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/hybrid_identity_metadata_list_by_virtual_machines.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python hybrid_identity_metadata_list_by_virtual_machines.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.hybrid_identity_metadata.list_by_machines( + resource_group_name="testrg", + machine_name="ContosoVm", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/HybridIdentityMetadata_ListByVirtualMachines.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license/license_create_or_update.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license/license_create_or_update.py new file mode 100644 index 000000000000..6aa57006fd45 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license/license_create_or_update.py @@ -0,0 +1,54 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python license_create_or_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.licenses.begin_create_or_update( + resource_group_name="myResourceGroup", + license_name="{licenseName}", + parameters={ + "location": "eastus2euap", + "properties": { + "licenseDetails": { + "edition": "Datacenter", + "processors": 6, + "state": "Activated", + "target": "Windows Server 2012", + "type": "pCore", + }, + "licenseType": "ESU", + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/license/License_CreateOrUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license/license_delete.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license/license_delete.py new file mode 100644 index 000000000000..df3eb479ce14 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license/license_delete.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python license_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + client.licenses.begin_delete( + resource_group_name="myResourceGroup", + license_name="{licenseName}", + ).result() + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/license/License_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license/license_get.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license/license_get.py new file mode 100644 index 000000000000..3a7736bb8f2e --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license/license_get.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python license_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.licenses.get( + resource_group_name="myResourceGroup", + license_name="{licenseName}", + ) + print(response) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/license/License_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license/license_list_by_resource_group.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license/license_list_by_resource_group.py new file mode 100644 index 000000000000..f0bf23c8fd07 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license/license_list_by_resource_group.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python license_list_by_resource_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.licenses.list_by_resource_group( + resource_group_name="myResourceGroup", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/license/License_ListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license/license_list_by_subscription.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license/license_list_by_subscription.py new file mode 100644 index 000000000000..88c2c224f7ae --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license/license_list_by_subscription.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python license_list_by_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.licenses.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/license/License_ListBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license/license_update.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license/license_update.py new file mode 100644 index 000000000000..3aa39fe3dccb --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license/license_update.py @@ -0,0 +1,53 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python license_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.licenses.begin_update( + resource_group_name="myResourceGroup", + license_name="{licenseName}", + parameters={ + "properties": { + "licenseDetails": { + "edition": "Datacenter", + "processors": 6, + "state": "Activated", + "target": "Windows Server 2012", + "type": "pCore", + }, + "licenseType": "ESU", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/license/License_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license/license_validate_license.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license/license_validate_license.py new file mode 100644 index 000000000000..e56fe83e4d78 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license/license_validate_license.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python license_validate_license.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.licenses.begin_validate_license( + parameters={ + "location": "eastus2euap", + "properties": { + "licenseDetails": { + "edition": "Datacenter", + "processors": 6, + "state": "Activated", + "target": "Windows Server 2012", + "type": "pCore", + }, + "licenseType": "ESU", + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/license/License_ValidateLicense.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license_profile/license_profile_create_or_update.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license_profile/license_profile_create_or_update.py new file mode 100644 index 000000000000..820dcb4eb324 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license_profile/license_profile_create_or_update.py @@ -0,0 +1,53 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python license_profile_create_or_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.license_profiles.begin_create_or_update( + resource_group_name="myResourceGroup", + machine_name="myMachine", + parameters={ + "location": "eastus2euap", + "properties": { + "esuProfile": {"assignedLicense": "{LicenseResourceId}"}, + "productProfile": { + "productFeatures": [{"name": "HotPatching", "subscriptionStatus": "Enabled"}], + "productType": "WindowsServer", + "subscriptionStatus": "Enabled", + }, + "softwareAssurance": {"softwareAssuranceCustomer": True}, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/licenseProfile/LicenseProfile_CreateOrUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license_profile/license_profile_delete.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license_profile/license_profile_delete.py new file mode 100644 index 000000000000..ef9bd615e49a --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license_profile/license_profile_delete.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python license_profile_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + client.license_profiles.begin_delete( + resource_group_name="myResourceGroup", + machine_name="myMachine", + ).result() + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/licenseProfile/LicenseProfile_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license_profile/license_profile_get.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license_profile/license_profile_get.py new file mode 100644 index 000000000000..3c3539ea5629 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license_profile/license_profile_get.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python license_profile_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.license_profiles.get( + resource_group_name="myResourceGroup", + machine_name="myMachine", + ) + print(response) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/licenseProfile/LicenseProfile_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license_profile/license_profile_list.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license_profile/license_profile_list.py new file mode 100644 index 000000000000..18cbe7439b0e --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license_profile/license_profile_list.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python license_profile_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.license_profiles.list( + resource_group_name="myResourceGroup", + machine_name="myMachine", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/licenseProfile/LicenseProfile_List.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license_profile/license_profile_update.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license_profile/license_profile_update.py new file mode 100644 index 000000000000..df84b9ca3b6d --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/license_profile/license_profile_update.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python license_profile_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.license_profiles.begin_update( + resource_group_name="myResourceGroup", + machine_name="myMachine", + parameters={ + "properties": { + "esuProfile": {"assignedLicense": "{LicenseResourceId}"}, + "productProfile": { + "productFeatures": [{"name": "HotPatching", "subscriptionStatus": "Enable"}], + "productType": "WindowsServer", + "subscriptionStatus": "Enable", + }, + "softwareAssurance": {"softwareAssuranceCustomer": True}, + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/licenseProfile/LicenseProfile_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machine/machine_assess_patches.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machine/machine_assess_patches.py new file mode 100644 index 000000000000..2c86a09144a9 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machine/machine_assess_patches.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python machine_assess_patches.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.machines.begin_assess_patches( + resource_group_name="myResourceGroupName", + name="myMachineName", + ).result() + print(response) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/machine/Machine_AssessPatches.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machine/machine_install_patches.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machine/machine_install_patches.py new file mode 100644 index 000000000000..00be2aa61ecb --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machine/machine_install_patches.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python machine_install_patches.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.machines.begin_install_patches( + resource_group_name="myResourceGroupName", + name="myMachineName", + install_patches_input={ + "maximumDuration": "PT4H", + "rebootSetting": "IfRequired", + "windowsParameters": { + "classificationsToInclude": ["Critical", "Security"], + "maxPatchPublishDate": "2021-08-19T02:36:43.0539904+00:00", + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/machine/Machine_InstallPatches.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machines_delete.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machine/machines_delete.py similarity index 91% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machines_delete.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machine/machines_delete.py index 45849dd24257..132ded35eeda 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machines_delete.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machine/machines_delete.py @@ -29,13 +29,12 @@ def main(): subscription_id="{subscriptionId}", ) - response = client.machines.delete( + client.machines.delete( resource_group_name="myResourceGroup", machine_name="myMachine", ) - print(response) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/Machines_Delete.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/machine/Machines_Delete.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machines_get.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machine/machines_get.py similarity index 94% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machines_get.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machine/machines_get.py index 1823a3c4d527..370ddd191408 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machines_get.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machine/machines_get.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/Machines_Get.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/machine/Machines_Get.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machine/machines_get_license_profile_instance_view.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machine/machines_get_license_profile_instance_view.py new file mode 100644 index 000000000000..7c36ddbf8005 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machine/machines_get_license_profile_instance_view.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python machines_get_license_profile_instance_view.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.machines.get( + resource_group_name="myResourceGroup", + machine_name="myMachine", + ) + print(response) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/machine/Machines_Get_LicenseProfileInstanceView.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machines_list_by_resource_group.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machine/machines_list_by_resource_group.py similarity index 93% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machines_list_by_resource_group.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machine/machines_list_by_resource_group.py index 15bfc7fb6ab2..489bb0e9990f 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machines_list_by_resource_group.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machine/machines_list_by_resource_group.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/Machines_ListByResourceGroup.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/machine/Machines_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machines_list_by_subscription.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machine/machines_list_by_subscription.py similarity index 93% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machines_list_by_subscription.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machine/machines_list_by_subscription.py index c63d3cf642d7..965c11f78478 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machines_list_by_subscription.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/machine/machines_list_by_subscription.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/Machines_ListBySubscription.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/machine/Machines_ListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/network_profile_get.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/network_profile_get.py new file mode 100644 index 000000000000..6b67286aa0cf --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/network_profile_get.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python network_profile_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.network_profile.get( + resource_group_name="myResourceGroup", + machine_name="myMachine", + ) + print(response) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/NetworkProfile_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/operations_list.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/operations_list.py index e6329473690d..160d399947ea 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/operations_list.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/operations_list.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/Operations_List.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/Operations_List.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint_connection_delete.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint/private_endpoint_connection_delete.py similarity index 89% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint_connection_delete.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint/private_endpoint_connection_delete.py index 7bcd012c70fe..645533c7bb01 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint_connection_delete.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint/private_endpoint_connection_delete.py @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.private_endpoint_connections.begin_delete( + client.private_endpoint_connections.begin_delete( resource_group_name="myResourceGroup", scope_name="myPrivateLinkScope", private_endpoint_connection_name="private-endpoint-connection-name", ).result() - print(response) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/PrivateEndpointConnectionDelete.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/privateEndpoint/PrivateEndpointConnection_Delete.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint_connection_get.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint/private_endpoint_connection_get.py similarity index 93% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint_connection_get.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint/private_endpoint_connection_get.py index be41316b1d8a..bdb8d27756c4 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint_connection_get.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint/private_endpoint_connection_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/PrivateEndpointConnectionGet.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/privateEndpoint/PrivateEndpointConnection_Get.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint_connection_list.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint/private_endpoint_connection_list.py similarity index 93% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint_connection_list.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint/private_endpoint_connection_list.py index 468ae8970a10..06ae3da4f3bc 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint_connection_list.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint/private_endpoint_connection_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/PrivateEndpointConnectionList.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/privateEndpoint/PrivateEndpointConnection_List.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint_connection_update.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint/private_endpoint_connection_update.py similarity index 94% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint_connection_update.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint/private_endpoint_connection_update.py index b3cf25f2dbae..7aed0fdc8cee 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint_connection_update.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_endpoint/private_endpoint_connection_update.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/PrivateEndpointConnectionUpdate.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/privateEndpoint/PrivateEndpointConnection_Update.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope_private_link_resource_get.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scope_private_link_resource_get.py similarity index 92% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope_private_link_resource_get.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scope_private_link_resource_get.py index 2260809654e9..2c349c23b5bf 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope_private_link_resource_get.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scope_private_link_resource_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/PrivateLinkScopePrivateLinkResourceGet.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/privateLinkScope/PrivateLinkScopePrivateLinkResource_Get.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope_private_link_resource_list_get.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scope_private_link_resource_list_get.py similarity index 92% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope_private_link_resource_list_get.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scope_private_link_resource_list_get.py index f2ebf4d78f9a..50db587e0091 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope_private_link_resource_list_get.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scope_private_link_resource_list_get.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/PrivateLinkScopePrivateLinkResourceListGet.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/privateLinkScope/PrivateLinkScopePrivateLinkResource_ListGet.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_create.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_create.py similarity index 93% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_create.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_create.py index 884fbc9f0054..9c619ba07f3a 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_create.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_create.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/PrivateLinkScopesCreate.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/privateLinkScope/PrivateLinkScopes_Create.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_delete.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_delete.py similarity index 90% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_delete.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_delete.py index 95f6bd430319..b85c6bc782c0 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_delete.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_delete.py @@ -29,13 +29,12 @@ def main(): subscription_id="86dc51d3-92ed-4d7e-947a-775ea79b4919", ) - response = client.private_link_scopes.begin_delete( + client.private_link_scopes.begin_delete( resource_group_name="my-resource-group", scope_name="my-privatelinkscope", ).result() - print(response) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/PrivateLinkScopesDelete.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/privateLinkScope/PrivateLinkScopes_Delete.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_get.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_get.py similarity index 93% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_get.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_get.py index 2ea1de7c6a66..7db2fb476641 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_get.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_get.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/PrivateLinkScopesGet.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/privateLinkScope/PrivateLinkScopes_Get.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_get_validation.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_get_validation.py similarity index 93% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_get_validation.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_get_validation.py index a5fa356f2030..760526cf5b57 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_get_validation.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_get_validation.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/PrivateLinkScopesGetValidation.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/privateLinkScope/PrivateLinkScopes_GetValidation.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_get_validation_for_machine.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_get_validation_for_machine.py similarity index 92% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_get_validation_for_machine.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_get_validation_for_machine.py index 73d51134638a..ee57c68c9531 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_get_validation_for_machine.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_get_validation_for_machine.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/PrivateLinkScopesGetValidationForMachine.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/privateLinkScope/PrivateLinkScopes_GetValidationForMachine.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_list.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_list.py similarity index 93% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_list.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_list.py index a54f4093e333..abab63068fcc 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_list.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_list.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/PrivateLinkScopesList.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/privateLinkScope/PrivateLinkScopes_List.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_list_by_resource_group.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_list_by_resource_group.py similarity index 92% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_list_by_resource_group.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_list_by_resource_group.py index 716c781d68a3..df00fcd26473 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_list_by_resource_group.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_list_by_resource_group.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/PrivateLinkScopesListByResourceGroup.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/privateLinkScope/PrivateLinkScopes_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_update.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_update.py similarity index 93% rename from sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_update.py rename to sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_update.py index 9bd9543f150e..a69caea9aa74 100644 --- a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scopes_update.py +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_update.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-03-10/examples/PrivateLinkScopesUpdate.json +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/privateLinkScope/PrivateLinkScopes_Update.json if __name__ == "__main__": main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_update_tags_only.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_update_tags_only.py new file mode 100644 index 000000000000..a2503f9b432e --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/private_link_scope/private_link_scopes_update_tags_only.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python private_link_scopes_update_tags_only.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.private_link_scopes.update_tags( + resource_group_name="my-resource-group", + scope_name="my-privatelinkscope", + private_link_scope_tags={"tags": {"Tag1": "Value1", "Tag2": "Value2"}}, + ) + print(response) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/privateLinkScope/PrivateLinkScopes_UpdateTagsOnly.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/run_command/run_commands_create_or_update.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/run_command/run_commands_create_or_update.py new file mode 100644 index 000000000000..695e5dc21a40 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/run_command/run_commands_create_or_update.py @@ -0,0 +1,55 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python run_commands_create_or_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.machine_run_commands.begin_create_or_update( + resource_group_name="myResourceGroup", + machine_name="myMachine", + run_command_name="myRunCommand", + run_command_properties={ + "location": "eastus2", + "properties": { + "asyncExecution": False, + "errorBlobUri": "https://mystorageaccount.blob.core.windows.net/mycontainer/MyScriptError.txt?sp=racw&st=2022-10-07T19:40:21Z&se=2022-10-08T03:40:21Z&spr=https&sv=2021-06-08&sr=b&sig=Yh7B%2Fy83olbYBdfsfbUREvd7ol8Dq5EVP3lAO4Kj4xDcN8%3D", + "outputBlobUri": "https://mystorageaccount.blob.core.windows.net/myscriptoutputcontainer/MyScriptoutput.txt", + "parameters": [{"name": "param1", "value": "value1"}, {"name": "param2", "value": "value2"}], + "runAsPassword": "", + "runAsUser": "user1", + "source": {"script": "Write-Host Hello World!"}, + "timeoutInSeconds": 3600, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/runCommand/RunCommands_CreateOrUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/run_command/run_commands_delete.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/run_command/run_commands_delete.py new file mode 100644 index 000000000000..c052040c47a0 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/run_command/run_commands_delete.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python run_commands_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + client.machine_run_commands.begin_delete( + resource_group_name="myResourceGroup", + machine_name="myMachine", + run_command_name="myRunCommand", + ).result() + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/runCommand/RunCommands_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/run_command/run_commands_get.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/run_command/run_commands_get.py new file mode 100644 index 000000000000..b381b7e1e57a --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/run_command/run_commands_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python run_commands_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.machine_run_commands.get( + resource_group_name="myResourceGroup", + machine_name="myMachine", + run_command_name="myRunCommand", + ) + print(response) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/runCommand/RunCommands_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/run_command/run_commands_list.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/run_command/run_commands_list.py new file mode 100644 index 000000000000..8187b69bde46 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/run_command/run_commands_list.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python run_commands_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.machine_run_commands.list( + resource_group_name="myResourceGroup", + machine_name="myMachine", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/runCommand/RunCommands_List.json +if __name__ == "__main__": + main() diff --git a/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/run_command/run_commands_update.py b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/run_command/run_commands_update.py new file mode 100644 index 000000000000..7e8a881c4057 --- /dev/null +++ b/sdk/hybridcompute/azure-mgmt-hybridcompute/generated_samples/run_command/run_commands_update.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.hybridcompute import HybridComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hybridcompute +# USAGE + python run_commands_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = HybridComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscriptionId}", + ) + + response = client.machine_run_commands.begin_update( + resource_group_name="myResourceGroup", + machine_name="myMachine", + run_command_name="myRunCommand", + run_command_properties={"tags": {"tag1": "value1", "tag2": "value2"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/preview/2023-10-03-preview/examples/runCommand/RunCommands_Update.json +if __name__ == "__main__": + main()