diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/_meta.json b/sdk/machinelearning/azure-mgmt-guestconfig/_meta.json index acfcecc0577c0..268f0823f1f61 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/_meta.json +++ b/sdk/machinelearning/azure-mgmt-guestconfig/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.2", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.1", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.16.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "33b8d6f7bf2eb081fe134333b0fc445777e488d6", + "commit": "1b301846a0e31a668c59b264c900be2128762fac", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/guestconfiguration/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.1 --use=@autorest/modelerfour@4.19.2 --version=3.4.2", + "autorest_command": "autorest specification/guestconfiguration/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/guestconfiguration/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/__init__.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/__init__.py index decfff5bcc082..3ea67baef123a 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/__init__.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/__init__.py @@ -10,10 +10,14 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['GuestConfigurationClient'] try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import except ImportError: - pass + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['GuestConfigurationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/_configuration.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/_configuration.py index 9aa902bd47452..ea55238d816df 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/_configuration.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class GuestConfigurationClientConfiguration(Configuration): +class GuestConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for GuestConfigurationClient. Note that all parameters used to create this instance are saved as instance @@ -29,26 +27,31 @@ class GuestConfigurationClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription ID which uniquely identify Microsoft Azure subscription. + The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-01-25". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(GuestConfigurationClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-01-25") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(GuestConfigurationClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-06-25" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-guestconfig/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +71,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/_guest_configuration_client.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/_guest_configuration_client.py index 01babb7e9978f..11c2353ee3441 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/_guest_configuration_client.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/_guest_configuration_client.py @@ -6,93 +6,124 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import GuestConfigurationClientConfiguration -from .operations import GuestConfigurationAssignmentsOperations -from .operations import GuestConfigurationAssignmentReportsOperations -from .operations import GuestConfigurationHCRPAssignmentsOperations -from .operations import GuestConfigurationHCRPAssignmentReportsOperations -from .operations import Operations from . import models +from ._configuration import GuestConfigurationClientConfiguration +from .operations import GuestConfigurationAssignmentReportsOperations, GuestConfigurationAssignmentReportsVMSSOperations, GuestConfigurationAssignmentsOperations, GuestConfigurationAssignmentsVMSSOperations, GuestConfigurationHCRPAssignmentReportsOperations, GuestConfigurationHCRPAssignmentsOperations, Operations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class GuestConfigurationClient(object): +class GuestConfigurationClient: # pylint: disable=too-many-instance-attributes """Guest Configuration Client. :ivar guest_configuration_assignments: GuestConfigurationAssignmentsOperations operations - :vartype guest_configuration_assignments: azure.mgmt.guestconfig.operations.GuestConfigurationAssignmentsOperations - :ivar guest_configuration_assignment_reports: GuestConfigurationAssignmentReportsOperations operations - :vartype guest_configuration_assignment_reports: azure.mgmt.guestconfig.operations.GuestConfigurationAssignmentReportsOperations - :ivar guest_configuration_hcrp_assignments: GuestConfigurationHCRPAssignmentsOperations operations - :vartype guest_configuration_hcrp_assignments: azure.mgmt.guestconfig.operations.GuestConfigurationHCRPAssignmentsOperations - :ivar guest_configuration_hcrp_assignment_reports: GuestConfigurationHCRPAssignmentReportsOperations operations - :vartype guest_configuration_hcrp_assignment_reports: azure.mgmt.guestconfig.operations.GuestConfigurationHCRPAssignmentReportsOperations + :vartype guest_configuration_assignments: + azure.mgmt.guestconfig.operations.GuestConfigurationAssignmentsOperations + :ivar guest_configuration_assignment_reports: GuestConfigurationAssignmentReportsOperations + operations + :vartype guest_configuration_assignment_reports: + azure.mgmt.guestconfig.operations.GuestConfigurationAssignmentReportsOperations + :ivar guest_configuration_hcrp_assignments: GuestConfigurationHCRPAssignmentsOperations + operations + :vartype guest_configuration_hcrp_assignments: + azure.mgmt.guestconfig.operations.GuestConfigurationHCRPAssignmentsOperations + :ivar guest_configuration_hcrp_assignment_reports: + GuestConfigurationHCRPAssignmentReportsOperations operations + :vartype guest_configuration_hcrp_assignment_reports: + azure.mgmt.guestconfig.operations.GuestConfigurationHCRPAssignmentReportsOperations + :ivar guest_configuration_assignments_vmss: GuestConfigurationAssignmentsVMSSOperations + operations + :vartype guest_configuration_assignments_vmss: + azure.mgmt.guestconfig.operations.GuestConfigurationAssignmentsVMSSOperations + :ivar guest_configuration_assignment_reports_vmss: + GuestConfigurationAssignmentReportsVMSSOperations operations + :vartype guest_configuration_assignment_reports_vmss: + azure.mgmt.guestconfig.operations.GuestConfigurationAssignmentReportsVMSSOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.guestconfig.operations.Operations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription ID which uniquely identify Microsoft Azure subscription. + The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL + :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-01-25". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = GuestConfigurationClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = GuestConfigurationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = 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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.guest_configuration_assignments = GuestConfigurationAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.guest_configuration_assignment_reports = GuestConfigurationAssignmentReportsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.guest_configuration_hcrp_assignments = GuestConfigurationHCRPAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.guest_configuration_hcrp_assignment_reports = GuestConfigurationHCRPAssignmentReportsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.guest_configuration_assignments_vmss = GuestConfigurationAssignmentsVMSSOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.guest_configuration_assignment_reports_vmss = GuestConfigurationAssignmentReportsVMSSOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/_metadata.json b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/_metadata.json deleted file mode 100644 index 8b0f39452c809..0000000000000 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/_metadata.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "chosen_version": "2020-06-25", - "total_api_version_list": ["2020-06-25"], - "client": { - "name": "GuestConfigurationClient", - "filename": "_guest_configuration_client", - "description": "Guest Configuration Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"GuestConfigurationClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"GuestConfigurationClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "docstring_type": "str", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=None, # type: Optional[str]", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "guest_configuration_assignments": "GuestConfigurationAssignmentsOperations", - "guest_configuration_assignment_reports": "GuestConfigurationAssignmentReportsOperations", - "guest_configuration_hcrp_assignments": "GuestConfigurationHCRPAssignmentsOperations", - "guest_configuration_hcrp_assignment_reports": "GuestConfigurationHCRPAssignmentReportsOperations", - "operations": "Operations" - } -} \ No newline at end of file diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/_patch.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/_patch.py new file mode 100644 index 0000000000000..0ad201a8c586e --- /dev/null +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/_vendor.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/__init__.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/__init__.py index 87d64022a9db9..343e4e0f8831a 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/__init__.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/__init__.py @@ -7,4 +7,14 @@ # -------------------------------------------------------------------------- from ._guest_configuration_client import GuestConfigurationClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['GuestConfigurationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/_configuration.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/_configuration.py index 7197706b1623a..485fc00302d84 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/_configuration.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class GuestConfigurationClientConfiguration(Configuration): +class GuestConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for GuestConfigurationClient. Note that all parameters used to create this instance are saved as instance @@ -27,8 +27,12 @@ class GuestConfigurationClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription ID which uniquely identify Microsoft Azure subscription. + The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-01-25". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +41,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(GuestConfigurationClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-01-25") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(GuestConfigurationClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-06-25" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-guestconfig/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +70,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/_guest_configuration_client.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/_guest_configuration_client.py index 988d61a323213..ec1d1247c4650 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/_guest_configuration_client.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/_guest_configuration_client.py @@ -6,89 +6,124 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import GuestConfigurationClientConfiguration -from .operations import GuestConfigurationAssignmentsOperations -from .operations import GuestConfigurationAssignmentReportsOperations -from .operations import GuestConfigurationHCRPAssignmentsOperations -from .operations import GuestConfigurationHCRPAssignmentReportsOperations -from .operations import Operations from .. import models +from ._configuration import GuestConfigurationClientConfiguration +from .operations import GuestConfigurationAssignmentReportsOperations, GuestConfigurationAssignmentReportsVMSSOperations, GuestConfigurationAssignmentsOperations, GuestConfigurationAssignmentsVMSSOperations, GuestConfigurationHCRPAssignmentReportsOperations, GuestConfigurationHCRPAssignmentsOperations, Operations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class GuestConfigurationClient(object): +class GuestConfigurationClient: # pylint: disable=too-many-instance-attributes """Guest Configuration Client. :ivar guest_configuration_assignments: GuestConfigurationAssignmentsOperations operations - :vartype guest_configuration_assignments: azure.mgmt.guestconfig.aio.operations.GuestConfigurationAssignmentsOperations - :ivar guest_configuration_assignment_reports: GuestConfigurationAssignmentReportsOperations operations - :vartype guest_configuration_assignment_reports: azure.mgmt.guestconfig.aio.operations.GuestConfigurationAssignmentReportsOperations - :ivar guest_configuration_hcrp_assignments: GuestConfigurationHCRPAssignmentsOperations operations - :vartype guest_configuration_hcrp_assignments: azure.mgmt.guestconfig.aio.operations.GuestConfigurationHCRPAssignmentsOperations - :ivar guest_configuration_hcrp_assignment_reports: GuestConfigurationHCRPAssignmentReportsOperations operations - :vartype guest_configuration_hcrp_assignment_reports: azure.mgmt.guestconfig.aio.operations.GuestConfigurationHCRPAssignmentReportsOperations + :vartype guest_configuration_assignments: + azure.mgmt.guestconfig.aio.operations.GuestConfigurationAssignmentsOperations + :ivar guest_configuration_assignment_reports: GuestConfigurationAssignmentReportsOperations + operations + :vartype guest_configuration_assignment_reports: + azure.mgmt.guestconfig.aio.operations.GuestConfigurationAssignmentReportsOperations + :ivar guest_configuration_hcrp_assignments: GuestConfigurationHCRPAssignmentsOperations + operations + :vartype guest_configuration_hcrp_assignments: + azure.mgmt.guestconfig.aio.operations.GuestConfigurationHCRPAssignmentsOperations + :ivar guest_configuration_hcrp_assignment_reports: + GuestConfigurationHCRPAssignmentReportsOperations operations + :vartype guest_configuration_hcrp_assignment_reports: + azure.mgmt.guestconfig.aio.operations.GuestConfigurationHCRPAssignmentReportsOperations + :ivar guest_configuration_assignments_vmss: GuestConfigurationAssignmentsVMSSOperations + operations + :vartype guest_configuration_assignments_vmss: + azure.mgmt.guestconfig.aio.operations.GuestConfigurationAssignmentsVMSSOperations + :ivar guest_configuration_assignment_reports_vmss: + GuestConfigurationAssignmentReportsVMSSOperations operations + :vartype guest_configuration_assignment_reports_vmss: + azure.mgmt.guestconfig.aio.operations.GuestConfigurationAssignmentReportsVMSSOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.guestconfig.aio.operations.Operations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription ID which uniquely identify Microsoft Azure subscription. + The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL + :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-01-25". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = GuestConfigurationClientConfiguration(credential, subscription_id, **kwargs) + self._config = GuestConfigurationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = 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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.guest_configuration_assignments = GuestConfigurationAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.guest_configuration_assignment_reports = GuestConfigurationAssignmentReportsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.guest_configuration_hcrp_assignments = GuestConfigurationHCRPAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.guest_configuration_hcrp_assignment_reports = GuestConfigurationHCRPAssignmentReportsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.guest_configuration_assignments_vmss = GuestConfigurationAssignmentsVMSSOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.guest_configuration_assignment_reports_vmss = GuestConfigurationAssignmentReportsVMSSOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/_patch.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/_patch.py new file mode 100644 index 0000000000000..0ad201a8c586e --- /dev/null +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/__init__.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/__init__.py index 9ec9e96e98e59..8e546ba6ff4e0 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/__init__.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/__init__.py @@ -10,12 +10,21 @@ from ._guest_configuration_assignment_reports_operations import GuestConfigurationAssignmentReportsOperations from ._guest_configuration_hcrp_assignments_operations import GuestConfigurationHCRPAssignmentsOperations from ._guest_configuration_hcrp_assignment_reports_operations import GuestConfigurationHCRPAssignmentReportsOperations +from ._guest_configuration_assignments_vmss_operations import GuestConfigurationAssignmentsVMSSOperations +from ._guest_configuration_assignment_reports_vmss_operations import GuestConfigurationAssignmentReportsVMSSOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'GuestConfigurationAssignmentsOperations', 'GuestConfigurationAssignmentReportsOperations', 'GuestConfigurationHCRPAssignmentsOperations', 'GuestConfigurationHCRPAssignmentReportsOperations', + 'GuestConfigurationAssignmentsVMSSOperations', + 'GuestConfigurationAssignmentReportsVMSSOperations', 'Operations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_guest_configuration_assignment_reports_operations.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_guest_configuration_assignment_reports_operations.py index a3b276b4a1392..747fa453b17fb 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_guest_configuration_assignment_reports_operations.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_guest_configuration_assignment_reports_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,50 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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._guest_configuration_assignment_reports_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GuestConfigurationAssignmentReportsOperations: - """GuestConfigurationAssignmentReportsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.guestconfig.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.guestconfig.aio.GuestConfigurationClient`'s + :attr:`guest_configuration_assignment_reports` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def list( self, resource_group_name: str, guest_configuration_assignment_name: str, vm_name: str, **kwargs: Any - ) -> "_models.GuestConfigurationAssignmentReportList": + ) -> _models.GuestConfigurationAssignmentReportList: """List all reports for the guest configuration assignment, latest report first. :param resource_group_name: The resource group name. @@ -60,39 +63,41 @@ async def list( :rtype: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentReportList :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignmentReportList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'guestConfigurationAssignmentName': self._serialize.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'vmName': self._serialize.url("vm_name", vm_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignmentReportList] + + + request = build_list_request( + resource_group_name=resource_group_name, + guest_configuration_assignment_name=guest_configuration_assignment_name, + subscription_id=self._config.subscription_id, + vm_name=vm_name, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GuestConfigurationAssignmentReportList', pipeline_response) @@ -101,8 +106,11 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports"} # type: ignore + + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -110,7 +118,7 @@ async def get( report_id: str, vm_name: str, **kwargs: Any - ) -> "_models.GuestConfigurationAssignmentReport": + ) -> _models.GuestConfigurationAssignmentReport: """Get a report for the guest configuration assignment, by reportId. :param resource_group_name: The resource group name. @@ -126,40 +134,42 @@ async def get( :rtype: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentReport :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignmentReport"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'guestConfigurationAssignmentName': self._serialize.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), - 'reportId': self._serialize.url("report_id", report_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'vmName': self._serialize.url("vm_name", vm_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignmentReport] + + + request = build_get_request( + resource_group_name=resource_group_name, + guest_configuration_assignment_name=guest_configuration_assignment_name, + report_id=report_id, + subscription_id=self._config.subscription_id, + vm_name=vm_name, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GuestConfigurationAssignmentReport', pipeline_response) @@ -168,4 +178,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports/{reportId}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports/{reportId}"} # type: ignore + diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_guest_configuration_assignment_reports_vmss_operations.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_guest_configuration_assignment_reports_vmss_operations.py new file mode 100644 index 0000000000000..f8a06deeba800 --- /dev/null +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_guest_configuration_assignment_reports_vmss_operations.py @@ -0,0 +1,213 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.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._guest_configuration_assignment_reports_vmss_operations import build_get_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class GuestConfigurationAssignmentReportsVMSSOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.guestconfig.aio.GuestConfigurationClient`'s + :attr:`guest_configuration_assignment_reports_vmss` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list( + self, + resource_group_name: str, + vmss_name: str, + name: str, + **kwargs: Any + ) -> AsyncIterable[_models.GuestConfigurationAssignmentReportList]: + """List all reports for the VMSS guest configuration assignment, latest report first. + + :param resource_group_name: The resource group name. + :type resource_group_name: str + :param vmss_name: The name of the virtual machine scale set. + :type vmss_name: str + :param name: The guest configuration assignment name. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GuestConfigurationAssignmentReportList or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentReportList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignmentReportList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmss_name=vmss_name, + name=name, + 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) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmss_name=vmss_name, + name=name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GuestConfigurationAssignmentReportList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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.Compute/virtualMachineScaleSets/{vmssName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{name}/reports"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + vmss_name: str, + name: str, + id: str, + **kwargs: Any + ) -> _models.GuestConfigurationAssignmentReport: + """Get a report for the VMSS guest configuration assignment, by reportId. + + :param resource_group_name: The resource group name. + :type resource_group_name: str + :param vmss_name: The name of the virtual machine scale set. + :type vmss_name: str + :param name: The guest configuration assignment name. + :type name: str + :param id: The GUID for the guest configuration assignment report. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GuestConfigurationAssignmentReport, or the result of cls(response) + :rtype: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentReport + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignmentReport] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmss_name=vmss_name, + name=name, + id=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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GuestConfigurationAssignmentReport', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{name}/reports/{id}"} # type: ignore + diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_guest_configuration_assignments_operations.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_guest_configuration_assignments_operations.py index cd28e6abc4d23..1fcce0bab8fb5 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_guest_configuration_assignments_operations.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_guest_configuration_assignments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,50 +6,53 @@ # 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, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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._guest_configuration_assignments_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request, build_rg_list_request, build_subscription_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GuestConfigurationAssignmentsOperations: - """GuestConfigurationAssignmentsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.guestconfig.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.guestconfig.aio.GuestConfigurationClient`'s + :attr:`guest_configuration_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def create_or_update( self, guest_configuration_assignment_name: str, resource_group_name: str, vm_name: str, - parameters: "_models.GuestConfigurationAssignment", + parameters: _models.GuestConfigurationAssignment, **kwargs: Any - ) -> "_models.GuestConfigurationAssignment": + ) -> _models.GuestConfigurationAssignment: """Creates an association between a VM and guest configuration. :param guest_configuration_assignment_name: Name of the guest configuration assignment. @@ -64,44 +68,45 @@ async def create_or_update( :rtype: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'guestConfigurationAssignmentName': self._serialize.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'vmName': self._serialize.url("vm_name", vm_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GuestConfigurationAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignment] + + _json = self._serialize.body(parameters, 'GuestConfigurationAssignment') + + request = build_create_or_update_request( + guest_configuration_assignment_name=guest_configuration_assignment_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vm_name=vm_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -114,15 +119,18 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}"} # type: ignore + + + @distributed_trace_async async def get( self, resource_group_name: str, guest_configuration_assignment_name: str, vm_name: str, **kwargs: Any - ) -> "_models.GuestConfigurationAssignment": + ) -> _models.GuestConfigurationAssignment: """Get information about a guest configuration assignment. :param resource_group_name: The resource group name. @@ -136,39 +144,41 @@ async def get( :rtype: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'guestConfigurationAssignmentName': self._serialize.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'vmName': self._serialize.url("vm_name", vm_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignment] + + + request = build_get_request( + resource_group_name=resource_group_name, + guest_configuration_assignment_name=guest_configuration_assignment_name, + subscription_id=self._config.subscription_id, + vm_name=vm_name, + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GuestConfigurationAssignment', pipeline_response) @@ -177,9 +187,12 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}'} # type: ignore - async def delete( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, guest_configuration_assignment_name: str, @@ -199,52 +212,223 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'guestConfigurationAssignmentName': self._serialize.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'vmName': self._serialize.url("vm_name", vm_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + guest_configuration_assignment_name=guest_configuration_assignment_name, + subscription_id=self._config.subscription_id, + vm_name=vm_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + 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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}"} # type: ignore + + + @distributed_trace + def subscription_list( + self, + **kwargs: Any + ) -> AsyncIterable[_models.GuestConfigurationAssignmentList]: + """List all guest configuration assignments for a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GuestConfigurationAssignmentList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_subscription_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.subscription_list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_subscription_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GuestConfigurationAssignmentList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 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) + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + subscription_list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments"} # type: ignore + + @distributed_trace + def rg_list( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.GuestConfigurationAssignmentList]: + """List all guest configuration assignments for a resource group. + + :param resource_group_name: The resource group name. + :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 GuestConfigurationAssignmentList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_rg_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.rg_list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_rg_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GuestConfigurationAssignmentList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 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) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + rg_list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments"} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GuestConfigurationAssignmentList"]: + ) -> AsyncIterable[_models.GuestConfigurationAssignmentList]: """List all guest configuration assignments for a virtual machine. :param resource_group_name: The resource group name. @@ -252,45 +436,55 @@ def list( :param vm_name: The name of the virtual machine. :type vm_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GuestConfigurationAssignmentList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentList] + :return: An iterator like instance of either GuestConfigurationAssignmentList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignmentList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignmentList] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'vmName': self._serialize.url("vm_name", vm_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + vm_name=vm_name, + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + vm_name=vm_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('GuestConfigurationAssignmentList', pipeline_response) + deserialized = self._deserialize("GuestConfigurationAssignmentList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -299,17 +493,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments"} # type: ignore diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_guest_configuration_assignments_vmss_operations.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_guest_configuration_assignments_vmss_operations.py new file mode 100644 index 0000000000000..a021a8562379d --- /dev/null +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_guest_configuration_assignments_vmss_operations.py @@ -0,0 +1,274 @@ +# 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 + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.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._guest_configuration_assignments_vmss_operations import build_delete_request, build_get_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class GuestConfigurationAssignmentsVMSSOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.guestconfig.aio.GuestConfigurationClient`'s + :attr:`guest_configuration_assignments_vmss` 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, + vmss_name: str, + name: str, + **kwargs: Any + ) -> _models.GuestConfigurationAssignment: + """Get information about a guest configuration assignment for VMSS. + + :param resource_group_name: The resource group name. + :type resource_group_name: str + :param vmss_name: The name of the virtual machine scale set. + :type vmss_name: str + :param name: The guest configuration assignment name. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GuestConfigurationAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignment] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmss_name=vmss_name, + name=name, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GuestConfigurationAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{name}"} # type: ignore + + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + vmss_name: str, + name: str, + **kwargs: Any + ) -> Optional[_models.GuestConfigurationAssignment]: + """Delete a guest configuration assignment for VMSS. + + :param resource_group_name: The resource group name. + :type resource_group_name: str + :param vmss_name: The name of the virtual machine scale set. + :type vmss_name: str + :param name: The guest configuration assignment name. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GuestConfigurationAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.GuestConfigurationAssignment]] + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmss_name=vmss_name, + name=name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 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) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GuestConfigurationAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{name}"} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + vmss_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.GuestConfigurationAssignmentList]: + """List all guest configuration assignments for VMSS. + + :param resource_group_name: The resource group name. + :type resource_group_name: str + :param vmss_name: The name of the virtual machine scale set. + :type vmss_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GuestConfigurationAssignmentList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + vmss_name=vmss_name, + 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) # type: ignore + + else: + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + vmss_name=vmss_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GuestConfigurationAssignmentList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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.Compute/virtualMachineScaleSets/{vmssName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments"} # type: ignore diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_guest_configuration_hcrp_assignment_reports_operations.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_guest_configuration_hcrp_assignment_reports_operations.py index 688dddd417e28..aac9ba86b4793 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_guest_configuration_hcrp_assignment_reports_operations.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_guest_configuration_hcrp_assignment_reports_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,50 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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._guest_configuration_hcrp_assignment_reports_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GuestConfigurationHCRPAssignmentReportsOperations: - """GuestConfigurationHCRPAssignmentReportsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.guestconfig.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.guestconfig.aio.GuestConfigurationClient`'s + :attr:`guest_configuration_hcrp_assignment_reports` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def list( self, resource_group_name: str, guest_configuration_assignment_name: str, machine_name: str, **kwargs: Any - ) -> "_models.GuestConfigurationAssignmentReportList": + ) -> _models.GuestConfigurationAssignmentReportList: """List all reports for the guest configuration assignment, latest report first. :param resource_group_name: The resource group name. @@ -60,39 +63,41 @@ async def list( :rtype: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentReportList :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignmentReportList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'guestConfigurationAssignmentName': self._serialize.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'machineName': self._serialize.url("machine_name", machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignmentReportList] + + + request = build_list_request( + resource_group_name=resource_group_name, + guest_configuration_assignment_name=guest_configuration_assignment_name, + subscription_id=self._config.subscription_id, + machine_name=machine_name, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GuestConfigurationAssignmentReportList', pipeline_response) @@ -101,8 +106,11 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports"} # type: ignore + + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -110,7 +118,7 @@ async def get( report_id: str, machine_name: str, **kwargs: Any - ) -> "_models.GuestConfigurationAssignmentReport": + ) -> _models.GuestConfigurationAssignmentReport: """Get a report for the guest configuration assignment, by reportId. :param resource_group_name: The resource group name. @@ -126,40 +134,42 @@ async def get( :rtype: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentReport :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignmentReport"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'guestConfigurationAssignmentName': self._serialize.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), - 'reportId': self._serialize.url("report_id", report_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'machineName': self._serialize.url("machine_name", machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignmentReport] + + + request = build_get_request( + resource_group_name=resource_group_name, + guest_configuration_assignment_name=guest_configuration_assignment_name, + report_id=report_id, + subscription_id=self._config.subscription_id, + machine_name=machine_name, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GuestConfigurationAssignmentReport', pipeline_response) @@ -168,4 +178,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports/{reportId}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports/{reportId}"} # type: ignore + diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_guest_configuration_hcrp_assignments_operations.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_guest_configuration_hcrp_assignments_operations.py index 363a7f8cb58cf..a0fd53f5a86f0 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_guest_configuration_hcrp_assignments_operations.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_guest_configuration_hcrp_assignments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,50 +6,53 @@ # 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, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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._guest_configuration_hcrp_assignments_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GuestConfigurationHCRPAssignmentsOperations: - """GuestConfigurationHCRPAssignmentsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.guestconfig.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.guestconfig.aio.GuestConfigurationClient`'s + :attr:`guest_configuration_hcrp_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def create_or_update( self, guest_configuration_assignment_name: str, resource_group_name: str, machine_name: str, - parameters: "_models.GuestConfigurationAssignment", + parameters: _models.GuestConfigurationAssignment, **kwargs: Any - ) -> "_models.GuestConfigurationAssignment": + ) -> _models.GuestConfigurationAssignment: """Creates an association between a ARC machine and guest configuration. :param guest_configuration_assignment_name: Name of the guest configuration assignment. @@ -64,44 +68,45 @@ async def create_or_update( :rtype: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'guestConfigurationAssignmentName': self._serialize.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'machineName': self._serialize.url("machine_name", machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GuestConfigurationAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignment] + + _json = self._serialize.body(parameters, 'GuestConfigurationAssignment') + + request = build_create_or_update_request( + guest_configuration_assignment_name=guest_configuration_assignment_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + machine_name=machine_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -114,15 +119,18 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}"} # type: ignore + + + @distributed_trace_async async def get( self, resource_group_name: str, guest_configuration_assignment_name: str, machine_name: str, **kwargs: Any - ) -> "_models.GuestConfigurationAssignment": + ) -> _models.GuestConfigurationAssignment: """Get information about a guest configuration assignment. :param resource_group_name: The resource group name. @@ -136,39 +144,41 @@ async def get( :rtype: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'guestConfigurationAssignmentName': self._serialize.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'machineName': self._serialize.url("machine_name", machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignment] + + + request = build_get_request( + resource_group_name=resource_group_name, + guest_configuration_assignment_name=guest_configuration_assignment_name, + subscription_id=self._config.subscription_id, + machine_name=machine_name, + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GuestConfigurationAssignment', pipeline_response) @@ -177,9 +187,12 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}'} # type: ignore - async def delete( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, guest_configuration_assignment_name: str, @@ -199,52 +212,56 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'guestConfigurationAssignmentName': self._serialize.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'machineName': self._serialize.url("machine_name", machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + guest_configuration_assignment_name=guest_configuration_assignment_name, + subscription_id=self._config.subscription_id, + machine_name=machine_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + 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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}"} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, machine_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GuestConfigurationAssignmentList"]: + ) -> AsyncIterable[_models.GuestConfigurationAssignmentList]: """List all guest configuration assignments for an ARC machine. :param resource_group_name: The resource group name. @@ -252,45 +269,55 @@ def list( :param machine_name: The name of the ARC machine. :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 GuestConfigurationAssignmentList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentList] + :return: An iterator like instance of either GuestConfigurationAssignmentList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignmentList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignmentList] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'machineName': self._serialize.url("machine_name", machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + machine_name=machine_name, + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + machine_name=machine_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('GuestConfigurationAssignmentList', pipeline_response) + deserialized = self._deserialize("GuestConfigurationAssignmentList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -299,17 +326,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments"} # type: ignore diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_operations.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_operations.py index 7b7206df99dfa..bc4c8eed20241 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_operations.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,48 @@ # 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, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +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 ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.guestconfig.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.guestconfig.aio.GuestConfigurationClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationList"]: + ) -> AsyncIterable[_models.OperationList]: """Lists all of the available GuestConfiguration REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -52,35 +55,43 @@ def list( :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.guestconfig.models.OperationList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationList] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationList', pipeline_response) + deserialized = self._deserialize("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,17 +100,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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': '/providers/Microsoft.GuestConfiguration/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.GuestConfiguration/operations"} # type: ignore diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_patch.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_patch.py new file mode 100644 index 0000000000000..0ad201a8c586e --- /dev/null +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/models/__init__.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/models/__init__.py index 1fbc819ce4c0b..5285a028d7ac3 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/models/__init__.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/models/__init__.py @@ -6,65 +6,46 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AssignmentInfo - from ._models_py3 import AssignmentReport - from ._models_py3 import AssignmentReportDetails - from ._models_py3 import AssignmentReportResource - from ._models_py3 import AssignmentReportResourceComplianceReason - from ._models_py3 import ConfigurationInfo - from ._models_py3 import ConfigurationParameter - from ._models_py3 import ConfigurationSetting - from ._models_py3 import ErrorResponse - from ._models_py3 import ErrorResponseError - from ._models_py3 import GuestConfigurationAssignment - from ._models_py3 import GuestConfigurationAssignmentList - from ._models_py3 import GuestConfigurationAssignmentProperties - from ._models_py3 import GuestConfigurationAssignmentReport - from ._models_py3 import GuestConfigurationAssignmentReportList - from ._models_py3 import GuestConfigurationAssignmentReportProperties - from ._models_py3 import GuestConfigurationNavigation - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationList - from ._models_py3 import ProxyResource - from ._models_py3 import Resource - from ._models_py3 import VMInfo -except (SyntaxError, ImportError): - from ._models import AssignmentInfo # type: ignore - from ._models import AssignmentReport # type: ignore - from ._models import AssignmentReportDetails # type: ignore - from ._models import AssignmentReportResource # type: ignore - from ._models import AssignmentReportResourceComplianceReason # type: ignore - from ._models import ConfigurationInfo # type: ignore - from ._models import ConfigurationParameter # type: ignore - from ._models import ConfigurationSetting # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ErrorResponseError # type: ignore - from ._models import GuestConfigurationAssignment # type: ignore - from ._models import GuestConfigurationAssignmentList # type: ignore - from ._models import GuestConfigurationAssignmentProperties # type: ignore - from ._models import GuestConfigurationAssignmentReport # type: ignore - from ._models import GuestConfigurationAssignmentReportList # type: ignore - from ._models import GuestConfigurationAssignmentReportProperties # type: ignore - from ._models import GuestConfigurationNavigation # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationList # type: ignore - from ._models import ProxyResource # type: ignore - from ._models import Resource # type: ignore - from ._models import VMInfo # type: ignore +from ._models_py3 import AssignmentInfo +from ._models_py3 import AssignmentReport +from ._models_py3 import AssignmentReportDetails +from ._models_py3 import AssignmentReportResource +from ._models_py3 import AssignmentReportResourceComplianceReason +from ._models_py3 import ConfigurationInfo +from ._models_py3 import ConfigurationParameter +from ._models_py3 import ConfigurationSetting +from ._models_py3 import ErrorResponse +from ._models_py3 import ErrorResponseError +from ._models_py3 import GuestConfigurationAssignment +from ._models_py3 import GuestConfigurationAssignmentList +from ._models_py3 import GuestConfigurationAssignmentProperties +from ._models_py3 import GuestConfigurationAssignmentReport +from ._models_py3 import GuestConfigurationAssignmentReportList +from ._models_py3 import GuestConfigurationAssignmentReportProperties +from ._models_py3 import GuestConfigurationNavigation +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationList +from ._models_py3 import ProxyResource +from ._models_py3 import Resource +from ._models_py3 import SystemData +from ._models_py3 import VMInfo +from ._models_py3 import VMSSVMInfo + from ._guest_configuration_client_enums import ( ActionAfterReboot, AssignmentType, ComplianceStatus, ConfigurationMode, + CreatedByType, Kind, ProvisioningState, Type, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'AssignmentInfo', 'AssignmentReport', @@ -88,12 +69,17 @@ 'OperationList', 'ProxyResource', 'Resource', + 'SystemData', 'VMInfo', + 'VMSSVMInfo', 'ActionAfterReboot', 'AssignmentType', 'ComplianceStatus', 'ConfigurationMode', + 'CreatedByType', 'Kind', 'ProvisioningState', 'Type', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/models/_guest_configuration_client_enums.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/models/_guest_configuration_client_enums.py index eda3b30975551..bed6bbe69c57f 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/models/_guest_configuration_client_enums.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/models/_guest_configuration_client_enums.py @@ -6,27 +6,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class ActionAfterReboot(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class ActionAfterReboot(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies what happens after a reboot during the application of a configuration. The possible values are ContinueConfiguration and StopConfiguration """ @@ -34,7 +18,7 @@ class ActionAfterReboot(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CONTINUE_CONFIGURATION = "ContinueConfiguration" STOP_CONFIGURATION = "StopConfiguration" -class AssignmentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AssignmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the assignment type and execution of the configuration. Possible values are Audit, DeployAndAutoCorrect, ApplyAndAutoCorrect and ApplyAndMonitor. """ @@ -44,7 +28,7 @@ class AssignmentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): APPLY_AND_AUTO_CORRECT = "ApplyAndAutoCorrect" APPLY_AND_MONITOR = "ApplyAndMonitor" -class ComplianceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ComplianceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """A value indicating compliance status of the machine for the assigned guest configuration. """ @@ -52,7 +36,7 @@ class ComplianceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): NON_COMPLIANT = "NonCompliant" PENDING = "Pending" -class ConfigurationMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ConfigurationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies how the LCM(Local Configuration Manager) actually applies the configuration to the target nodes. Possible values are ApplyOnly, ApplyAndMonitor, and ApplyAndAutoCorrect. """ @@ -61,13 +45,22 @@ class ConfigurationMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): APPLY_AND_MONITOR = "ApplyAndMonitor" APPLY_AND_AUTO_CORRECT = "ApplyAndAutoCorrect" -class Kind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Kind of the guest configuration. For example:DSC """ DSC = "DSC" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -76,7 +69,7 @@ class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CANCELED = "Canceled" CREATED = "Created" -class Type(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of report, Consistency or Initial """ diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/models/_models.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/models/_models.py deleted file mode 100644 index b3a277e772d4d..0000000000000 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/models/_models.py +++ /dev/null @@ -1,843 +0,0 @@ -# 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.core.exceptions import HttpResponseError -import msrest.serialization - - -class AssignmentInfo(msrest.serialization.Model): - """Information about the guest configuration assignment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name of the guest configuration assignment. - :vartype name: str - :param configuration: Information about the configuration. - :type configuration: ~azure.mgmt.guestconfig.models.ConfigurationInfo - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'configuration': {'key': 'configuration', 'type': 'ConfigurationInfo'}, - } - - def __init__( - self, - **kwargs - ): - super(AssignmentInfo, self).__init__(**kwargs) - self.name = None - self.configuration = kwargs.get('configuration', None) - - -class AssignmentReport(msrest.serialization.Model): - """AssignmentReport. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: ARM resource id of the report for the guest configuration assignment. - :vartype id: str - :ivar report_id: GUID that identifies the guest configuration assignment report under a - subscription, resource group. - :vartype report_id: str - :param assignment: Configuration details of the guest configuration assignment. - :type assignment: ~azure.mgmt.guestconfig.models.AssignmentInfo - :param vm: Information about the VM. - :type vm: ~azure.mgmt.guestconfig.models.VMInfo - :ivar start_time: Start date and time of the guest configuration assignment compliance status - check. - :vartype start_time: ~datetime.datetime - :ivar end_time: End date and time of the guest configuration assignment compliance status - check. - :vartype end_time: ~datetime.datetime - :ivar compliance_status: A value indicating compliance status of the machine for the assigned - guest configuration. Possible values include: "Compliant", "NonCompliant", "Pending". - :vartype compliance_status: str or ~azure.mgmt.guestconfig.models.ComplianceStatus - :ivar operation_type: Type of report, Consistency or Initial. Possible values include: - "Consistency", "Initial". - :vartype operation_type: str or ~azure.mgmt.guestconfig.models.Type - :param resources: The list of resources for which guest configuration assignment compliance is - checked. - :type resources: list[~azure.mgmt.guestconfig.models.AssignmentReportResource] - """ - - _validation = { - 'id': {'readonly': True}, - 'report_id': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'compliance_status': {'readonly': True}, - 'operation_type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'report_id': {'key': 'reportId', 'type': 'str'}, - 'assignment': {'key': 'assignment', 'type': 'AssignmentInfo'}, - 'vm': {'key': 'vm', 'type': 'VMInfo'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'compliance_status': {'key': 'complianceStatus', 'type': 'str'}, - 'operation_type': {'key': 'operationType', 'type': 'str'}, - 'resources': {'key': 'resources', 'type': '[AssignmentReportResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(AssignmentReport, self).__init__(**kwargs) - self.id = None - self.report_id = None - self.assignment = kwargs.get('assignment', None) - self.vm = kwargs.get('vm', None) - self.start_time = None - self.end_time = None - self.compliance_status = None - self.operation_type = None - self.resources = kwargs.get('resources', None) - - -class AssignmentReportDetails(msrest.serialization.Model): - """Details of the guest configuration assignment report. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar compliance_status: A value indicating compliance status of the machine for the assigned - guest configuration. Possible values include: "Compliant", "NonCompliant", "Pending". - :vartype compliance_status: str or ~azure.mgmt.guestconfig.models.ComplianceStatus - :ivar start_time: Start date and time of the guest configuration assignment compliance status - check. - :vartype start_time: ~datetime.datetime - :ivar end_time: End date and time of the guest configuration assignment compliance status - check. - :vartype end_time: ~datetime.datetime - :ivar job_id: GUID of the report. - :vartype job_id: str - :ivar operation_type: Type of report, Consistency or Initial. Possible values include: - "Consistency", "Initial". - :vartype operation_type: str or ~azure.mgmt.guestconfig.models.Type - :param resources: The list of resources for which guest configuration assignment compliance is - checked. - :type resources: list[~azure.mgmt.guestconfig.models.AssignmentReportResource] - """ - - _validation = { - 'compliance_status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'job_id': {'readonly': True}, - 'operation_type': {'readonly': True}, - } - - _attribute_map = { - 'compliance_status': {'key': 'complianceStatus', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'job_id': {'key': 'jobId', 'type': 'str'}, - 'operation_type': {'key': 'operationType', 'type': 'str'}, - 'resources': {'key': 'resources', 'type': '[AssignmentReportResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(AssignmentReportDetails, self).__init__(**kwargs) - self.compliance_status = None - self.start_time = None - self.end_time = None - self.job_id = None - self.operation_type = None - self.resources = kwargs.get('resources', None) - - -class AssignmentReportResource(msrest.serialization.Model): - """The guest configuration assignment resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar compliance_status: A value indicating compliance status of the machine for the assigned - guest configuration. Possible values include: "Compliant", "NonCompliant", "Pending". - :vartype compliance_status: str or ~azure.mgmt.guestconfig.models.ComplianceStatus - :ivar resource_id: Name of the guest configuration assignment resource setting. - :vartype resource_id: str - :param reasons: Compliance reason and reason code for a resource. - :type reasons: list[~azure.mgmt.guestconfig.models.AssignmentReportResourceComplianceReason] - :ivar properties: Properties of a guest configuration assignment resource. - :vartype properties: any - """ - - _validation = { - 'compliance_status': {'readonly': True}, - 'resource_id': {'readonly': True}, - 'properties': {'readonly': True}, - } - - _attribute_map = { - 'compliance_status': {'key': 'complianceStatus', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'reasons': {'key': 'reasons', 'type': '[AssignmentReportResourceComplianceReason]'}, - 'properties': {'key': 'properties', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(AssignmentReportResource, self).__init__(**kwargs) - self.compliance_status = None - self.resource_id = None - self.reasons = kwargs.get('reasons', None) - self.properties = None - - -class AssignmentReportResourceComplianceReason(msrest.serialization.Model): - """Reason and code for the compliance of the guest configuration assignment resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar phrase: Reason for the compliance of the guest configuration assignment resource. - :vartype phrase: str - :ivar code: Code for the compliance of the guest configuration assignment resource. - :vartype code: str - """ - - _validation = { - 'phrase': {'readonly': True}, - 'code': {'readonly': True}, - } - - _attribute_map = { - 'phrase': {'key': 'phrase', 'type': 'str'}, - 'code': {'key': 'code', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AssignmentReportResourceComplianceReason, self).__init__(**kwargs) - self.phrase = None - self.code = None - - -class ConfigurationInfo(msrest.serialization.Model): - """Information about the configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name of the configuration. - :vartype name: str - :ivar version: Version of the configuration. - :vartype version: str - """ - - _validation = { - 'name': {'readonly': True}, - 'version': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfigurationInfo, self).__init__(**kwargs) - self.name = None - self.version = None - - -class ConfigurationParameter(msrest.serialization.Model): - """Represents a configuration parameter. - - :param name: Name of the configuration parameter. - :type name: str - :param value: Value of the configuration parameter. - :type value: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfigurationParameter, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.value = kwargs.get('value', None) - - -class ConfigurationSetting(msrest.serialization.Model): - """Configuration setting of LCM (Local Configuration Manager). - - :param configuration_mode: Specifies how the LCM(Local Configuration Manager) actually applies - the configuration to the target nodes. Possible values are ApplyOnly, ApplyAndMonitor, and - ApplyAndAutoCorrect. Possible values include: "ApplyOnly", "ApplyAndMonitor", - "ApplyAndAutoCorrect". - :type configuration_mode: str or ~azure.mgmt.guestconfig.models.ConfigurationMode - :param allow_module_overwrite: If true - new configurations downloaded from the pull service - are allowed to overwrite the old ones on the target node. Otherwise, false. - :type allow_module_overwrite: bool - :param action_after_reboot: Specifies what happens after a reboot during the application of a - configuration. The possible values are ContinueConfiguration and StopConfiguration. Possible - values include: "ContinueConfiguration", "StopConfiguration". - :type action_after_reboot: str or ~azure.mgmt.guestconfig.models.ActionAfterReboot - :param refresh_frequency_mins: The time interval, in minutes, at which the LCM checks a pull - service to get updated configurations. This value is ignored if the LCM is not configured in - pull mode. The default value is 30. - :type refresh_frequency_mins: float - :param reboot_if_needed: Set this to true to automatically reboot the node after a - configuration that requires reboot is applied. Otherwise, you will have to manually reboot the - node for any configuration that requires it. The default value is false. To use this setting - when a reboot condition is enacted by something other than DSC (such as Windows Installer), - combine this setting with the xPendingReboot module. - :type reboot_if_needed: bool - :param configuration_mode_frequency_mins: How often, in minutes, the current configuration is - checked and applied. This property is ignored if the ConfigurationMode property is set to - ApplyOnly. The default value is 15. - :type configuration_mode_frequency_mins: float - """ - - _attribute_map = { - 'configuration_mode': {'key': 'configurationMode', 'type': 'str'}, - 'allow_module_overwrite': {'key': 'allowModuleOverwrite', 'type': 'bool'}, - 'action_after_reboot': {'key': 'actionAfterReboot', 'type': 'str'}, - 'refresh_frequency_mins': {'key': 'refreshFrequencyMins', 'type': 'float'}, - 'reboot_if_needed': {'key': 'rebootIfNeeded', 'type': 'bool'}, - 'configuration_mode_frequency_mins': {'key': 'configurationModeFrequencyMins', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfigurationSetting, self).__init__(**kwargs) - self.configuration_mode = kwargs.get('configuration_mode', None) - self.allow_module_overwrite = kwargs.get('allow_module_overwrite', None) - self.action_after_reboot = kwargs.get('action_after_reboot', None) - self.refresh_frequency_mins = kwargs.get('refresh_frequency_mins', 30) - self.reboot_if_needed = kwargs.get('reboot_if_needed', None) - self.configuration_mode_frequency_mins = kwargs.get('configuration_mode_frequency_mins', 15) - - -class ErrorResponse(msrest.serialization.Model): - """Error response of an operation failure. - - :param error: - :type error: ~azure.mgmt.guestconfig.models.ErrorResponseError - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ErrorResponseError(msrest.serialization.Model): - """ErrorResponseError. - - :param code: Error code. - :type code: str - :param message: Detail error message indicating why the operation failed. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponseError, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class Resource(msrest.serialization.Model): - """The core properties of ARM resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: ARM resource id of the guest configuration assignment. - :vartype id: str - :param name: Name of the guest configuration assignment. - :type name: str - :param location: Region where the VM is located. - :type location: str - :ivar type: The type of the resource. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = kwargs.get('name', None) - self.location = kwargs.get('location', None) - self.type = None - - -class ProxyResource(Resource): - """ARM proxy resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: ARM resource id of the guest configuration assignment. - :vartype id: str - :param name: Name of the guest configuration assignment. - :type name: str - :param location: Region where the VM is located. - :type location: str - :ivar type: The type of the resource. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProxyResource, self).__init__(**kwargs) - - -class GuestConfigurationAssignment(ProxyResource): - """Guest configuration assignment is an association between a machine and guest configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: ARM resource id of the guest configuration assignment. - :vartype id: str - :param name: Name of the guest configuration assignment. - :type name: str - :param location: Region where the VM is located. - :type location: str - :ivar type: The type of the resource. - :vartype type: str - :param properties: Properties of the Guest configuration assignment. - :type properties: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'GuestConfigurationAssignmentProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(GuestConfigurationAssignment, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class GuestConfigurationAssignmentList(msrest.serialization.Model): - """The response of the list guest configuration assignment operation. - - :param value: Result of the list guest configuration assignment operation. - :type value: list[~azure.mgmt.guestconfig.models.GuestConfigurationAssignment] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[GuestConfigurationAssignment]'}, - } - - def __init__( - self, - **kwargs - ): - super(GuestConfigurationAssignmentList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class GuestConfigurationAssignmentProperties(msrest.serialization.Model): - """Guest configuration assignment properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar target_resource_id: VM resource Id. - :vartype target_resource_id: str - :param guest_configuration: The guest configuration to assign. - :type guest_configuration: ~azure.mgmt.guestconfig.models.GuestConfigurationNavigation - :ivar compliance_status: A value indicating compliance status of the machine for the assigned - guest configuration. Possible values include: "Compliant", "NonCompliant", "Pending". - :vartype compliance_status: str or ~azure.mgmt.guestconfig.models.ComplianceStatus - :ivar last_compliance_status_checked: Date and time when last compliance status was checked. - :vartype last_compliance_status_checked: ~datetime.datetime - :ivar latest_report_id: Id of the latest report for the guest configuration assignment. - :vartype latest_report_id: str - :param latest_assignment_report: Last reported guest configuration assignment report. - :type latest_assignment_report: ~azure.mgmt.guestconfig.models.AssignmentReport - :param context: The source which initiated the guest configuration assignment. Ex: Azure - Policy. - :type context: str - :ivar assignment_hash: Combined hash of the configuration package and parameters. - :vartype assignment_hash: str - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Succeeded", "Failed", "Canceled", "Created". - :vartype provisioning_state: str or ~azure.mgmt.guestconfig.models.ProvisioningState - """ - - _validation = { - 'target_resource_id': {'readonly': True}, - 'compliance_status': {'readonly': True}, - 'last_compliance_status_checked': {'readonly': True}, - 'latest_report_id': {'readonly': True}, - 'assignment_hash': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'target_resource_id': {'key': 'targetResourceId', 'type': 'str'}, - 'guest_configuration': {'key': 'guestConfiguration', 'type': 'GuestConfigurationNavigation'}, - 'compliance_status': {'key': 'complianceStatus', 'type': 'str'}, - 'last_compliance_status_checked': {'key': 'lastComplianceStatusChecked', 'type': 'iso-8601'}, - 'latest_report_id': {'key': 'latestReportId', 'type': 'str'}, - 'latest_assignment_report': {'key': 'latestAssignmentReport', 'type': 'AssignmentReport'}, - 'context': {'key': 'context', 'type': 'str'}, - 'assignment_hash': {'key': 'assignmentHash', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GuestConfigurationAssignmentProperties, self).__init__(**kwargs) - self.target_resource_id = None - self.guest_configuration = kwargs.get('guest_configuration', None) - self.compliance_status = None - self.last_compliance_status_checked = None - self.latest_report_id = None - self.latest_assignment_report = kwargs.get('latest_assignment_report', None) - self.context = kwargs.get('context', None) - self.assignment_hash = None - self.provisioning_state = None - - -class GuestConfigurationAssignmentReport(msrest.serialization.Model): - """Report for the guest configuration assignment. Report contains information such as compliance status, reason, and more. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: ARM resource id of the report for the guest configuration assignment. - :vartype id: str - :ivar name: GUID that identifies the guest configuration assignment report under a - subscription, resource group. - :vartype name: str - :param properties: Properties of the guest configuration report. - :type properties: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentReportProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'GuestConfigurationAssignmentReportProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(GuestConfigurationAssignmentReport, self).__init__(**kwargs) - self.id = None - self.name = None - self.properties = kwargs.get('properties', None) - - -class GuestConfigurationAssignmentReportList(msrest.serialization.Model): - """List of guest configuration assignment reports. - - :param value: List of reports for the guest configuration. Report contains information such as - compliance status, reason and more. - :type value: list[~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentReport] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[GuestConfigurationAssignmentReport]'}, - } - - def __init__( - self, - **kwargs - ): - super(GuestConfigurationAssignmentReportList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class GuestConfigurationAssignmentReportProperties(msrest.serialization.Model): - """Report for the guest configuration assignment. Report contains information such as compliance status, reason, and more. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar compliance_status: A value indicating compliance status of the machine for the assigned - guest configuration. Possible values include: "Compliant", "NonCompliant", "Pending". - :vartype compliance_status: str or ~azure.mgmt.guestconfig.models.ComplianceStatus - :ivar report_id: GUID that identifies the guest configuration assignment report under a - subscription, resource group. - :vartype report_id: str - :param assignment: Configuration details of the guest configuration assignment. - :type assignment: ~azure.mgmt.guestconfig.models.AssignmentInfo - :param vm: Information about the VM. - :type vm: ~azure.mgmt.guestconfig.models.VMInfo - :ivar start_time: Start date and time of the guest configuration assignment compliance status - check. - :vartype start_time: ~datetime.datetime - :ivar end_time: End date and time of the guest configuration assignment compliance status - check. - :vartype end_time: ~datetime.datetime - :param details: Details of the assignment report. - :type details: ~azure.mgmt.guestconfig.models.AssignmentReportDetails - """ - - _validation = { - 'compliance_status': {'readonly': True}, - 'report_id': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - } - - _attribute_map = { - 'compliance_status': {'key': 'complianceStatus', 'type': 'str'}, - 'report_id': {'key': 'reportId', 'type': 'str'}, - 'assignment': {'key': 'assignment', 'type': 'AssignmentInfo'}, - 'vm': {'key': 'vm', 'type': 'VMInfo'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'details': {'key': 'details', 'type': 'AssignmentReportDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(GuestConfigurationAssignmentReportProperties, self).__init__(**kwargs) - self.compliance_status = None - self.report_id = None - self.assignment = kwargs.get('assignment', None) - self.vm = kwargs.get('vm', None) - self.start_time = None - self.end_time = None - self.details = kwargs.get('details', None) - - -class GuestConfigurationNavigation(msrest.serialization.Model): - """Guest configuration is an artifact that encapsulates DSC configuration and its dependencies. The artifact is a zip file containing DSC configuration (as MOF) and dependent resources and other dependencies like modules. - - :param kind: Kind of the guest configuration. For example:DSC. Possible values include: "DSC". - :type kind: str or ~azure.mgmt.guestconfig.models.Kind - :param name: Name of the guest configuration. - :type name: str - :param version: Version of the guest configuration. - :type version: str - :param content_uri: Uri of the storage where guest configuration package is uploaded. - :type content_uri: str - :param content_hash: Combined hash of the guest configuration package and configuration - parameters. - :type content_hash: str - :param assignment_type: Specifies the assignment type and execution of the configuration. - Possible values are Audit, DeployAndAutoCorrect, ApplyAndAutoCorrect and ApplyAndMonitor. - Possible values include: "Audit", "DeployAndAutoCorrect", "ApplyAndAutoCorrect", - "ApplyAndMonitor". - :type assignment_type: str or ~azure.mgmt.guestconfig.models.AssignmentType - :param configuration_parameter: The configuration parameters for the guest configuration. - :type configuration_parameter: list[~azure.mgmt.guestconfig.models.ConfigurationParameter] - :param configuration_setting: The configuration setting for the guest configuration. - :type configuration_setting: ~azure.mgmt.guestconfig.models.ConfigurationSetting - """ - - _attribute_map = { - 'kind': {'key': 'kind', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'content_uri': {'key': 'contentUri', 'type': 'str'}, - 'content_hash': {'key': 'contentHash', 'type': 'str'}, - 'assignment_type': {'key': 'assignmentType', 'type': 'str'}, - 'configuration_parameter': {'key': 'configurationParameter', 'type': '[ConfigurationParameter]'}, - 'configuration_setting': {'key': 'configurationSetting', 'type': 'ConfigurationSetting'}, - } - - def __init__( - self, - **kwargs - ): - super(GuestConfigurationNavigation, self).__init__(**kwargs) - self.kind = kwargs.get('kind', None) - self.name = kwargs.get('name', None) - self.version = kwargs.get('version', None) - self.content_uri = kwargs.get('content_uri', None) - self.content_hash = kwargs.get('content_hash', None) - self.assignment_type = kwargs.get('assignment_type', None) - self.configuration_parameter = kwargs.get('configuration_parameter', None) - self.configuration_setting = kwargs.get('configuration_setting', None) - - -class Operation(msrest.serialization.Model): - """GuestConfiguration REST API operation. - - :param name: Operation name: For ex. - providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/write or read. - :type name: str - :param display: Provider, Resource, Operation and description values. - :type display: ~azure.mgmt.guestconfig.models.OperationDisplay - :param status_code: Service provider: Microsoft.GuestConfiguration. - :type status_code: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'status_code': {'key': 'properties.statusCode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - self.status_code = kwargs.get('status_code', None) - - -class OperationDisplay(msrest.serialization.Model): - """Provider, Resource, Operation and description values. - - :param provider: Service provider: Microsoft.GuestConfiguration. - :type provider: str - :param resource: Resource on which the operation is performed: For ex. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description about operation. - :type description: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationList(msrest.serialization.Model): - """The response model for the list of Automation operations. - - :param value: List of Automation operations supported by the Automation resource provider. - :type value: list[~azure.mgmt.guestconfig.models.Operation] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class VMInfo(msrest.serialization.Model): - """Information about the VM. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id of the VM. - :vartype id: str - :ivar uuid: UUID(Universally Unique Identifier) of the VM. - :vartype uuid: str - """ - - _validation = { - 'id': {'readonly': True}, - 'uuid': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'uuid': {'key': 'uuid', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VMInfo, self).__init__(**kwargs) - self.id = None - self.uuid = None diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/models/_models_py3.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/models/_models_py3.py index bce6b19cdec6f..4336b1337719a 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/models/_models_py3.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/models/_models_py3.py @@ -6,12 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional, Union +import datetime +from typing import List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._guest_configuration_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AssignmentInfo(msrest.serialization.Model): @@ -21,8 +24,8 @@ class AssignmentInfo(msrest.serialization.Model): :ivar name: Name of the guest configuration assignment. :vartype name: str - :param configuration: Information about the configuration. - :type configuration: ~azure.mgmt.guestconfig.models.ConfigurationInfo + :ivar configuration: Information about the configuration. + :vartype configuration: ~azure.mgmt.guestconfig.models.ConfigurationInfo """ _validation = { @@ -37,9 +40,13 @@ class AssignmentInfo(msrest.serialization.Model): def __init__( self, *, - configuration: Optional["ConfigurationInfo"] = None, + configuration: Optional["_models.ConfigurationInfo"] = None, **kwargs ): + """ + :keyword configuration: Information about the configuration. + :paramtype configuration: ~azure.mgmt.guestconfig.models.ConfigurationInfo + """ super(AssignmentInfo, self).__init__(**kwargs) self.name = None self.configuration = configuration @@ -55,10 +62,10 @@ class AssignmentReport(msrest.serialization.Model): :ivar report_id: GUID that identifies the guest configuration assignment report under a subscription, resource group. :vartype report_id: str - :param assignment: Configuration details of the guest configuration assignment. - :type assignment: ~azure.mgmt.guestconfig.models.AssignmentInfo - :param vm: Information about the VM. - :type vm: ~azure.mgmt.guestconfig.models.VMInfo + :ivar assignment: Configuration details of the guest configuration assignment. + :vartype assignment: ~azure.mgmt.guestconfig.models.AssignmentInfo + :ivar vm: Information about the VM. + :vartype vm: ~azure.mgmt.guestconfig.models.VMInfo :ivar start_time: Start date and time of the guest configuration assignment compliance status check. :vartype start_time: ~datetime.datetime @@ -66,14 +73,14 @@ class AssignmentReport(msrest.serialization.Model): check. :vartype end_time: ~datetime.datetime :ivar compliance_status: A value indicating compliance status of the machine for the assigned - guest configuration. Possible values include: "Compliant", "NonCompliant", "Pending". + guest configuration. Known values are: "Compliant", "NonCompliant", "Pending". :vartype compliance_status: str or ~azure.mgmt.guestconfig.models.ComplianceStatus - :ivar operation_type: Type of report, Consistency or Initial. Possible values include: - "Consistency", "Initial". + :ivar operation_type: Type of report, Consistency or Initial. Known values are: "Consistency", + "Initial". :vartype operation_type: str or ~azure.mgmt.guestconfig.models.Type - :param resources: The list of resources for which guest configuration assignment compliance is + :ivar resources: The list of resources for which guest configuration assignment compliance is checked. - :type resources: list[~azure.mgmt.guestconfig.models.AssignmentReportResource] + :vartype resources: list[~azure.mgmt.guestconfig.models.AssignmentReportResource] """ _validation = { @@ -100,11 +107,20 @@ class AssignmentReport(msrest.serialization.Model): def __init__( self, *, - assignment: Optional["AssignmentInfo"] = None, - vm: Optional["VMInfo"] = None, - resources: Optional[List["AssignmentReportResource"]] = None, + assignment: Optional["_models.AssignmentInfo"] = None, + vm: Optional["_models.VMInfo"] = None, + resources: Optional[List["_models.AssignmentReportResource"]] = None, **kwargs ): + """ + :keyword assignment: Configuration details of the guest configuration assignment. + :paramtype assignment: ~azure.mgmt.guestconfig.models.AssignmentInfo + :keyword vm: Information about the VM. + :paramtype vm: ~azure.mgmt.guestconfig.models.VMInfo + :keyword resources: The list of resources for which guest configuration assignment compliance + is checked. + :paramtype resources: list[~azure.mgmt.guestconfig.models.AssignmentReportResource] + """ super(AssignmentReport, self).__init__(**kwargs) self.id = None self.report_id = None @@ -123,7 +139,7 @@ class AssignmentReportDetails(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar compliance_status: A value indicating compliance status of the machine for the assigned - guest configuration. Possible values include: "Compliant", "NonCompliant", "Pending". + guest configuration. Known values are: "Compliant", "NonCompliant", "Pending". :vartype compliance_status: str or ~azure.mgmt.guestconfig.models.ComplianceStatus :ivar start_time: Start date and time of the guest configuration assignment compliance status check. @@ -133,12 +149,12 @@ class AssignmentReportDetails(msrest.serialization.Model): :vartype end_time: ~datetime.datetime :ivar job_id: GUID of the report. :vartype job_id: str - :ivar operation_type: Type of report, Consistency or Initial. Possible values include: - "Consistency", "Initial". + :ivar operation_type: Type of report, Consistency or Initial. Known values are: "Consistency", + "Initial". :vartype operation_type: str or ~azure.mgmt.guestconfig.models.Type - :param resources: The list of resources for which guest configuration assignment compliance is + :ivar resources: The list of resources for which guest configuration assignment compliance is checked. - :type resources: list[~azure.mgmt.guestconfig.models.AssignmentReportResource] + :vartype resources: list[~azure.mgmt.guestconfig.models.AssignmentReportResource] """ _validation = { @@ -161,9 +177,14 @@ class AssignmentReportDetails(msrest.serialization.Model): def __init__( self, *, - resources: Optional[List["AssignmentReportResource"]] = None, + resources: Optional[List["_models.AssignmentReportResource"]] = None, **kwargs ): + """ + :keyword resources: The list of resources for which guest configuration assignment compliance + is checked. + :paramtype resources: list[~azure.mgmt.guestconfig.models.AssignmentReportResource] + """ super(AssignmentReportDetails, self).__init__(**kwargs) self.compliance_status = None self.start_time = None @@ -179,12 +200,12 @@ class AssignmentReportResource(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar compliance_status: A value indicating compliance status of the machine for the assigned - guest configuration. Possible values include: "Compliant", "NonCompliant", "Pending". + guest configuration. Known values are: "Compliant", "NonCompliant", "Pending". :vartype compliance_status: str or ~azure.mgmt.guestconfig.models.ComplianceStatus :ivar resource_id: Name of the guest configuration assignment resource setting. :vartype resource_id: str - :param reasons: Compliance reason and reason code for a resource. - :type reasons: list[~azure.mgmt.guestconfig.models.AssignmentReportResourceComplianceReason] + :ivar reasons: Compliance reason and reason code for a resource. + :vartype reasons: list[~azure.mgmt.guestconfig.models.AssignmentReportResourceComplianceReason] :ivar properties: Properties of a guest configuration assignment resource. :vartype properties: any """ @@ -205,9 +226,14 @@ class AssignmentReportResource(msrest.serialization.Model): def __init__( self, *, - reasons: Optional[List["AssignmentReportResourceComplianceReason"]] = None, + reasons: Optional[List["_models.AssignmentReportResourceComplianceReason"]] = None, **kwargs ): + """ + :keyword reasons: Compliance reason and reason code for a resource. + :paramtype reasons: + list[~azure.mgmt.guestconfig.models.AssignmentReportResourceComplianceReason] + """ super(AssignmentReportResource, self).__init__(**kwargs) self.compliance_status = None self.resource_id = None @@ -240,6 +266,8 @@ def __init__( self, **kwargs ): + """ + """ super(AssignmentReportResourceComplianceReason, self).__init__(**kwargs) self.phrase = None self.code = None @@ -270,6 +298,8 @@ def __init__( self, **kwargs ): + """ + """ super(ConfigurationInfo, self).__init__(**kwargs) self.name = None self.version = None @@ -278,10 +308,10 @@ def __init__( class ConfigurationParameter(msrest.serialization.Model): """Represents a configuration parameter. - :param name: Name of the configuration parameter. - :type name: str - :param value: Value of the configuration parameter. - :type value: str + :ivar name: Name of the configuration parameter. + :vartype name: str + :ivar value: Value of the configuration parameter. + :vartype value: str """ _attribute_map = { @@ -296,6 +326,12 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword name: Name of the configuration parameter. + :paramtype name: str + :keyword value: Value of the configuration parameter. + :paramtype value: str + """ super(ConfigurationParameter, self).__init__(**kwargs) self.name = name self.value = value @@ -304,34 +340,44 @@ def __init__( class ConfigurationSetting(msrest.serialization.Model): """Configuration setting of LCM (Local Configuration Manager). - :param configuration_mode: Specifies how the LCM(Local Configuration Manager) actually applies + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar configuration_mode: Specifies how the LCM(Local Configuration Manager) actually applies the configuration to the target nodes. Possible values are ApplyOnly, ApplyAndMonitor, and - ApplyAndAutoCorrect. Possible values include: "ApplyOnly", "ApplyAndMonitor", - "ApplyAndAutoCorrect". - :type configuration_mode: str or ~azure.mgmt.guestconfig.models.ConfigurationMode - :param allow_module_overwrite: If true - new configurations downloaded from the pull service - are allowed to overwrite the old ones on the target node. Otherwise, false. - :type allow_module_overwrite: bool - :param action_after_reboot: Specifies what happens after a reboot during the application of a - configuration. The possible values are ContinueConfiguration and StopConfiguration. Possible - values include: "ContinueConfiguration", "StopConfiguration". - :type action_after_reboot: str or ~azure.mgmt.guestconfig.models.ActionAfterReboot - :param refresh_frequency_mins: The time interval, in minutes, at which the LCM checks a pull + ApplyAndAutoCorrect. Known values are: "ApplyOnly", "ApplyAndMonitor", "ApplyAndAutoCorrect". + :vartype configuration_mode: str or ~azure.mgmt.guestconfig.models.ConfigurationMode + :ivar allow_module_overwrite: If true - new configurations downloaded from the pull service are + allowed to overwrite the old ones on the target node. Otherwise, false. + :vartype allow_module_overwrite: bool + :ivar action_after_reboot: Specifies what happens after a reboot during the application of a + configuration. The possible values are ContinueConfiguration and StopConfiguration. Known + values are: "ContinueConfiguration", "StopConfiguration". + :vartype action_after_reboot: str or ~azure.mgmt.guestconfig.models.ActionAfterReboot + :ivar refresh_frequency_mins: The time interval, in minutes, at which the LCM checks a pull service to get updated configurations. This value is ignored if the LCM is not configured in pull mode. The default value is 30. - :type refresh_frequency_mins: float - :param reboot_if_needed: Set this to true to automatically reboot the node after a - configuration that requires reboot is applied. Otherwise, you will have to manually reboot the - node for any configuration that requires it. The default value is false. To use this setting - when a reboot condition is enacted by something other than DSC (such as Windows Installer), - combine this setting with the xPendingReboot module. - :type reboot_if_needed: bool - :param configuration_mode_frequency_mins: How often, in minutes, the current configuration is + :vartype refresh_frequency_mins: float + :ivar reboot_if_needed: Set this to true to automatically reboot the node after a configuration + that requires reboot is applied. Otherwise, you will have to manually reboot the node for any + configuration that requires it. The default value is false. To use this setting when a reboot + condition is enacted by something other than DSC (such as Windows Installer), combine this + setting with the xPendingReboot module. + :vartype reboot_if_needed: bool + :ivar configuration_mode_frequency_mins: How often, in minutes, the current configuration is checked and applied. This property is ignored if the ConfigurationMode property is set to ApplyOnly. The default value is 15. - :type configuration_mode_frequency_mins: float + :vartype configuration_mode_frequency_mins: float """ + _validation = { + 'configuration_mode': {'readonly': True}, + 'allow_module_overwrite': {'readonly': True}, + 'action_after_reboot': {'readonly': True}, + 'refresh_frequency_mins': {'readonly': True}, + 'reboot_if_needed': {'readonly': True}, + 'configuration_mode_frequency_mins': {'readonly': True}, + } + _attribute_map = { 'configuration_mode': {'key': 'configurationMode', 'type': 'str'}, 'allow_module_overwrite': {'key': 'allowModuleOverwrite', 'type': 'bool'}, @@ -343,29 +389,24 @@ class ConfigurationSetting(msrest.serialization.Model): def __init__( self, - *, - configuration_mode: Optional[Union[str, "ConfigurationMode"]] = None, - allow_module_overwrite: Optional[bool] = None, - action_after_reboot: Optional[Union[str, "ActionAfterReboot"]] = None, - refresh_frequency_mins: Optional[float] = 30, - reboot_if_needed: Optional[bool] = None, - configuration_mode_frequency_mins: Optional[float] = 15, **kwargs ): + """ + """ super(ConfigurationSetting, self).__init__(**kwargs) - self.configuration_mode = configuration_mode - self.allow_module_overwrite = allow_module_overwrite - self.action_after_reboot = action_after_reboot - self.refresh_frequency_mins = refresh_frequency_mins - self.reboot_if_needed = reboot_if_needed - self.configuration_mode_frequency_mins = configuration_mode_frequency_mins + self.configuration_mode = None + self.allow_module_overwrite = None + self.action_after_reboot = None + self.refresh_frequency_mins = None + self.reboot_if_needed = None + self.configuration_mode_frequency_mins = None class ErrorResponse(msrest.serialization.Model): """Error response of an operation failure. - :param error: - :type error: ~azure.mgmt.guestconfig.models.ErrorResponseError + :ivar error: + :vartype error: ~azure.mgmt.guestconfig.models.ErrorResponseError """ _attribute_map = { @@ -375,9 +416,13 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorResponseError"] = None, + error: Optional["_models.ErrorResponseError"] = None, **kwargs ): + """ + :keyword error: + :paramtype error: ~azure.mgmt.guestconfig.models.ErrorResponseError + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -385,10 +430,10 @@ def __init__( class ErrorResponseError(msrest.serialization.Model): """ErrorResponseError. - :param code: Error code. - :type code: str - :param message: Detail error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Detail error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -403,6 +448,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Detail error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponseError, self).__init__(**kwargs) self.code = code self.message = message @@ -415,10 +466,10 @@ class Resource(msrest.serialization.Model): :ivar id: ARM resource id of the guest configuration assignment. :vartype id: str - :param name: Name of the guest configuration assignment. - :type name: str - :param location: Region where the VM is located. - :type location: str + :ivar name: Name of the guest configuration assignment. + :vartype name: str + :ivar location: Region where the VM is located. + :vartype location: str :ivar type: The type of the resource. :vartype type: str """ @@ -442,6 +493,12 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword name: Name of the guest configuration assignment. + :paramtype name: str + :keyword location: Region where the VM is located. + :paramtype location: str + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = name @@ -456,10 +513,10 @@ class ProxyResource(Resource): :ivar id: ARM resource id of the guest configuration assignment. :vartype id: str - :param name: Name of the guest configuration assignment. - :type name: str - :param location: Region where the VM is located. - :type location: str + :ivar name: Name of the guest configuration assignment. + :vartype name: str + :ivar location: Region where the VM is located. + :vartype location: str :ivar type: The type of the resource. :vartype type: str """ @@ -483,6 +540,12 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword name: Name of the guest configuration assignment. + :paramtype name: str + :keyword location: Region where the VM is located. + :paramtype location: str + """ super(ProxyResource, self).__init__(name=name, location=location, **kwargs) @@ -493,19 +556,23 @@ class GuestConfigurationAssignment(ProxyResource): :ivar id: ARM resource id of the guest configuration assignment. :vartype id: str - :param name: Name of the guest configuration assignment. - :type name: str - :param location: Region where the VM is located. - :type location: str + :ivar name: Name of the guest configuration assignment. + :vartype name: str + :ivar location: Region where the VM is located. + :vartype location: str :ivar type: The type of the resource. :vartype type: str - :param properties: Properties of the Guest configuration assignment. - :type properties: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentProperties + :ivar properties: Properties of the Guest configuration assignment. + :vartype properties: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentProperties + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.guestconfig.models.SystemData """ _validation = { 'id': {'readonly': True}, 'type': {'readonly': True}, + 'system_data': {'readonly': True}, } _attribute_map = { @@ -514,6 +581,7 @@ class GuestConfigurationAssignment(ProxyResource): 'location': {'key': 'location', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'properties': {'key': 'properties', 'type': 'GuestConfigurationAssignmentProperties'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__( @@ -521,18 +589,27 @@ def __init__( *, name: Optional[str] = None, location: Optional[str] = None, - properties: Optional["GuestConfigurationAssignmentProperties"] = None, + properties: Optional["_models.GuestConfigurationAssignmentProperties"] = None, **kwargs ): + """ + :keyword name: Name of the guest configuration assignment. + :paramtype name: str + :keyword location: Region where the VM is located. + :paramtype location: str + :keyword properties: Properties of the Guest configuration assignment. + :paramtype properties: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentProperties + """ super(GuestConfigurationAssignment, self).__init__(name=name, location=location, **kwargs) self.properties = properties + self.system_data = None class GuestConfigurationAssignmentList(msrest.serialization.Model): """The response of the list guest configuration assignment operation. - :param value: Result of the list guest configuration assignment operation. - :type value: list[~azure.mgmt.guestconfig.models.GuestConfigurationAssignment] + :ivar value: Result of the list guest configuration assignment operation. + :vartype value: list[~azure.mgmt.guestconfig.models.GuestConfigurationAssignment] """ _attribute_map = { @@ -542,9 +619,13 @@ class GuestConfigurationAssignmentList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["GuestConfigurationAssignment"]] = None, + value: Optional[List["_models.GuestConfigurationAssignment"]] = None, **kwargs ): + """ + :keyword value: Result of the list guest configuration assignment operation. + :paramtype value: list[~azure.mgmt.guestconfig.models.GuestConfigurationAssignment] + """ super(GuestConfigurationAssignmentList, self).__init__(**kwargs) self.value = value @@ -556,25 +637,30 @@ class GuestConfigurationAssignmentProperties(msrest.serialization.Model): :ivar target_resource_id: VM resource Id. :vartype target_resource_id: str - :param guest_configuration: The guest configuration to assign. - :type guest_configuration: ~azure.mgmt.guestconfig.models.GuestConfigurationNavigation + :ivar guest_configuration: The guest configuration to assign. + :vartype guest_configuration: ~azure.mgmt.guestconfig.models.GuestConfigurationNavigation :ivar compliance_status: A value indicating compliance status of the machine for the assigned - guest configuration. Possible values include: "Compliant", "NonCompliant", "Pending". + guest configuration. Known values are: "Compliant", "NonCompliant", "Pending". :vartype compliance_status: str or ~azure.mgmt.guestconfig.models.ComplianceStatus :ivar last_compliance_status_checked: Date and time when last compliance status was checked. :vartype last_compliance_status_checked: ~datetime.datetime :ivar latest_report_id: Id of the latest report for the guest configuration assignment. :vartype latest_report_id: str - :param latest_assignment_report: Last reported guest configuration assignment report. - :type latest_assignment_report: ~azure.mgmt.guestconfig.models.AssignmentReport - :param context: The source which initiated the guest configuration assignment. Ex: Azure - Policy. - :type context: str + :ivar parameter_hash: parameter hash for the guest configuration assignment. + :vartype parameter_hash: str + :ivar latest_assignment_report: Last reported guest configuration assignment report. + :vartype latest_assignment_report: ~azure.mgmt.guestconfig.models.AssignmentReport + :ivar context: The source which initiated the guest configuration assignment. Ex: Azure Policy. + :vartype context: str :ivar assignment_hash: Combined hash of the configuration package and parameters. :vartype assignment_hash: str - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Succeeded", "Failed", "Canceled", "Created". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Succeeded", "Failed", "Canceled", "Created". :vartype provisioning_state: str or ~azure.mgmt.guestconfig.models.ProvisioningState + :ivar resource_type: Type of the resource - VMSS / VM. + :vartype resource_type: str + :ivar vmss_vm_list: The list of VM Compliance data for VMSS. + :vartype vmss_vm_list: list[~azure.mgmt.guestconfig.models.VMSSVMInfo] """ _validation = { @@ -582,8 +668,10 @@ class GuestConfigurationAssignmentProperties(msrest.serialization.Model): 'compliance_status': {'readonly': True}, 'last_compliance_status_checked': {'readonly': True}, 'latest_report_id': {'readonly': True}, + 'parameter_hash': {'readonly': True}, 'assignment_hash': {'readonly': True}, 'provisioning_state': {'readonly': True}, + 'resource_type': {'readonly': True}, } _attribute_map = { @@ -592,30 +680,48 @@ class GuestConfigurationAssignmentProperties(msrest.serialization.Model): 'compliance_status': {'key': 'complianceStatus', 'type': 'str'}, 'last_compliance_status_checked': {'key': 'lastComplianceStatusChecked', 'type': 'iso-8601'}, 'latest_report_id': {'key': 'latestReportId', 'type': 'str'}, + 'parameter_hash': {'key': 'parameterHash', 'type': 'str'}, 'latest_assignment_report': {'key': 'latestAssignmentReport', 'type': 'AssignmentReport'}, 'context': {'key': 'context', 'type': 'str'}, 'assignment_hash': {'key': 'assignmentHash', 'type': 'str'}, 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'vmss_vm_list': {'key': 'vmssVMList', 'type': '[VMSSVMInfo]'}, } def __init__( self, *, - guest_configuration: Optional["GuestConfigurationNavigation"] = None, - latest_assignment_report: Optional["AssignmentReport"] = None, + guest_configuration: Optional["_models.GuestConfigurationNavigation"] = None, + latest_assignment_report: Optional["_models.AssignmentReport"] = None, context: Optional[str] = None, + vmss_vm_list: Optional[List["_models.VMSSVMInfo"]] = None, **kwargs ): + """ + :keyword guest_configuration: The guest configuration to assign. + :paramtype guest_configuration: ~azure.mgmt.guestconfig.models.GuestConfigurationNavigation + :keyword latest_assignment_report: Last reported guest configuration assignment report. + :paramtype latest_assignment_report: ~azure.mgmt.guestconfig.models.AssignmentReport + :keyword context: The source which initiated the guest configuration assignment. Ex: Azure + Policy. + :paramtype context: str + :keyword vmss_vm_list: The list of VM Compliance data for VMSS. + :paramtype vmss_vm_list: list[~azure.mgmt.guestconfig.models.VMSSVMInfo] + """ super(GuestConfigurationAssignmentProperties, self).__init__(**kwargs) self.target_resource_id = None self.guest_configuration = guest_configuration self.compliance_status = None self.last_compliance_status_checked = None self.latest_report_id = None + self.parameter_hash = None self.latest_assignment_report = latest_assignment_report self.context = context self.assignment_hash = None self.provisioning_state = None + self.resource_type = None + self.vmss_vm_list = vmss_vm_list class GuestConfigurationAssignmentReport(msrest.serialization.Model): @@ -628,8 +734,9 @@ class GuestConfigurationAssignmentReport(msrest.serialization.Model): :ivar name: GUID that identifies the guest configuration assignment report under a subscription, resource group. :vartype name: str - :param properties: Properties of the guest configuration report. - :type properties: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentReportProperties + :ivar properties: Properties of the guest configuration report. + :vartype properties: + ~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentReportProperties """ _validation = { @@ -646,9 +753,14 @@ class GuestConfigurationAssignmentReport(msrest.serialization.Model): def __init__( self, *, - properties: Optional["GuestConfigurationAssignmentReportProperties"] = None, + properties: Optional["_models.GuestConfigurationAssignmentReportProperties"] = None, **kwargs ): + """ + :keyword properties: Properties of the guest configuration report. + :paramtype properties: + ~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentReportProperties + """ super(GuestConfigurationAssignmentReport, self).__init__(**kwargs) self.id = None self.name = None @@ -658,9 +770,9 @@ def __init__( class GuestConfigurationAssignmentReportList(msrest.serialization.Model): """List of guest configuration assignment reports. - :param value: List of reports for the guest configuration. Report contains information such as + :ivar value: List of reports for the guest configuration. Report contains information such as compliance status, reason and more. - :type value: list[~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentReport] + :vartype value: list[~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentReport] """ _attribute_map = { @@ -670,9 +782,14 @@ class GuestConfigurationAssignmentReportList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["GuestConfigurationAssignmentReport"]] = None, + value: Optional[List["_models.GuestConfigurationAssignmentReport"]] = None, **kwargs ): + """ + :keyword value: List of reports for the guest configuration. Report contains information such + as compliance status, reason and more. + :paramtype value: list[~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentReport] + """ super(GuestConfigurationAssignmentReportList, self).__init__(**kwargs) self.value = value @@ -683,23 +800,25 @@ class GuestConfigurationAssignmentReportProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar compliance_status: A value indicating compliance status of the machine for the assigned - guest configuration. Possible values include: "Compliant", "NonCompliant", "Pending". + guest configuration. Known values are: "Compliant", "NonCompliant", "Pending". :vartype compliance_status: str or ~azure.mgmt.guestconfig.models.ComplianceStatus :ivar report_id: GUID that identifies the guest configuration assignment report under a subscription, resource group. :vartype report_id: str - :param assignment: Configuration details of the guest configuration assignment. - :type assignment: ~azure.mgmt.guestconfig.models.AssignmentInfo - :param vm: Information about the VM. - :type vm: ~azure.mgmt.guestconfig.models.VMInfo + :ivar assignment: Configuration details of the guest configuration assignment. + :vartype assignment: ~azure.mgmt.guestconfig.models.AssignmentInfo + :ivar vm: Information about the VM. + :vartype vm: ~azure.mgmt.guestconfig.models.VMInfo :ivar start_time: Start date and time of the guest configuration assignment compliance status check. :vartype start_time: ~datetime.datetime :ivar end_time: End date and time of the guest configuration assignment compliance status check. :vartype end_time: ~datetime.datetime - :param details: Details of the assignment report. - :type details: ~azure.mgmt.guestconfig.models.AssignmentReportDetails + :ivar details: Details of the assignment report. + :vartype details: ~azure.mgmt.guestconfig.models.AssignmentReportDetails + :ivar vmss_resource_id: Azure resource Id of the VMSS. + :vartype vmss_resource_id: str """ _validation = { @@ -707,6 +826,7 @@ class GuestConfigurationAssignmentReportProperties(msrest.serialization.Model): 'report_id': {'readonly': True}, 'start_time': {'readonly': True}, 'end_time': {'readonly': True}, + 'vmss_resource_id': {'readonly': True}, } _attribute_map = { @@ -717,16 +837,25 @@ class GuestConfigurationAssignmentReportProperties(msrest.serialization.Model): 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, 'details': {'key': 'details', 'type': 'AssignmentReportDetails'}, + 'vmss_resource_id': {'key': 'vmssResourceId', 'type': 'str'}, } def __init__( self, *, - assignment: Optional["AssignmentInfo"] = None, - vm: Optional["VMInfo"] = None, - details: Optional["AssignmentReportDetails"] = None, + assignment: Optional["_models.AssignmentInfo"] = None, + vm: Optional["_models.VMInfo"] = None, + details: Optional["_models.AssignmentReportDetails"] = None, **kwargs ): + """ + :keyword assignment: Configuration details of the guest configuration assignment. + :paramtype assignment: ~azure.mgmt.guestconfig.models.AssignmentInfo + :keyword vm: Information about the VM. + :paramtype vm: ~azure.mgmt.guestconfig.models.VMInfo + :keyword details: Details of the assignment report. + :paramtype details: ~azure.mgmt.guestconfig.models.AssignmentReportDetails + """ super(GuestConfigurationAssignmentReportProperties, self).__init__(**kwargs) self.compliance_status = None self.report_id = None @@ -735,33 +864,50 @@ def __init__( self.start_time = None self.end_time = None self.details = details + self.vmss_resource_id = None class GuestConfigurationNavigation(msrest.serialization.Model): """Guest configuration is an artifact that encapsulates DSC configuration and its dependencies. The artifact is a zip file containing DSC configuration (as MOF) and dependent resources and other dependencies like modules. - :param kind: Kind of the guest configuration. For example:DSC. Possible values include: "DSC". - :type kind: str or ~azure.mgmt.guestconfig.models.Kind - :param name: Name of the guest configuration. - :type name: str - :param version: Version of the guest configuration. - :type version: str - :param content_uri: Uri of the storage where guest configuration package is uploaded. - :type content_uri: str - :param content_hash: Combined hash of the guest configuration package and configuration + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar kind: Kind of the guest configuration. For example:DSC. Known values are: "DSC". + :vartype kind: str or ~azure.mgmt.guestconfig.models.Kind + :ivar name: Name of the guest configuration. + :vartype name: str + :ivar version: Version of the guest configuration. + :vartype version: str + :ivar content_uri: Uri of the storage where guest configuration package is uploaded. + :vartype content_uri: str + :ivar content_hash: Combined hash of the guest configuration package and configuration parameters. - :type content_hash: str - :param assignment_type: Specifies the assignment type and execution of the configuration. - Possible values are Audit, DeployAndAutoCorrect, ApplyAndAutoCorrect and ApplyAndMonitor. - Possible values include: "Audit", "DeployAndAutoCorrect", "ApplyAndAutoCorrect", - "ApplyAndMonitor". - :type assignment_type: str or ~azure.mgmt.guestconfig.models.AssignmentType - :param configuration_parameter: The configuration parameters for the guest configuration. - :type configuration_parameter: list[~azure.mgmt.guestconfig.models.ConfigurationParameter] - :param configuration_setting: The configuration setting for the guest configuration. - :type configuration_setting: ~azure.mgmt.guestconfig.models.ConfigurationSetting + :vartype content_hash: str + :ivar assignment_type: Specifies the assignment type and execution of the configuration. + Possible values are Audit, DeployAndAutoCorrect, ApplyAndAutoCorrect and ApplyAndMonitor. Known + values are: "Audit", "DeployAndAutoCorrect", "ApplyAndAutoCorrect", "ApplyAndMonitor". + :vartype assignment_type: str or ~azure.mgmt.guestconfig.models.AssignmentType + :ivar assignment_source: Specifies the origin of the configuration. + :vartype assignment_source: str + :ivar content_type: Specifies the content type of the configuration. Possible values could be + Builtin or Custom. + :vartype content_type: str + :ivar configuration_parameter: The configuration parameters for the guest configuration. + :vartype configuration_parameter: list[~azure.mgmt.guestconfig.models.ConfigurationParameter] + :ivar configuration_protected_parameter: The protected configuration parameters for the guest + configuration. + :vartype configuration_protected_parameter: + list[~azure.mgmt.guestconfig.models.ConfigurationParameter] + :ivar configuration_setting: The configuration setting for the guest configuration. + :vartype configuration_setting: ~azure.mgmt.guestconfig.models.ConfigurationSetting """ + _validation = { + 'assignment_source': {'readonly': True}, + 'content_type': {'readonly': True}, + 'configuration_setting': {'readonly': True}, + } + _attribute_map = { 'kind': {'key': 'kind', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, @@ -769,23 +915,49 @@ class GuestConfigurationNavigation(msrest.serialization.Model): 'content_uri': {'key': 'contentUri', 'type': 'str'}, 'content_hash': {'key': 'contentHash', 'type': 'str'}, 'assignment_type': {'key': 'assignmentType', 'type': 'str'}, + 'assignment_source': {'key': 'assignmentSource', 'type': 'str'}, + 'content_type': {'key': 'contentType', 'type': 'str'}, 'configuration_parameter': {'key': 'configurationParameter', 'type': '[ConfigurationParameter]'}, + 'configuration_protected_parameter': {'key': 'configurationProtectedParameter', 'type': '[ConfigurationParameter]'}, 'configuration_setting': {'key': 'configurationSetting', 'type': 'ConfigurationSetting'}, } def __init__( self, *, - kind: Optional[Union[str, "Kind"]] = None, + kind: Optional[Union[str, "_models.Kind"]] = None, name: Optional[str] = None, version: Optional[str] = None, content_uri: Optional[str] = None, content_hash: Optional[str] = None, - assignment_type: Optional[Union[str, "AssignmentType"]] = None, - configuration_parameter: Optional[List["ConfigurationParameter"]] = None, - configuration_setting: Optional["ConfigurationSetting"] = None, + assignment_type: Optional[Union[str, "_models.AssignmentType"]] = None, + configuration_parameter: Optional[List["_models.ConfigurationParameter"]] = None, + configuration_protected_parameter: Optional[List["_models.ConfigurationParameter"]] = None, **kwargs ): + """ + :keyword kind: Kind of the guest configuration. For example:DSC. Known values are: "DSC". + :paramtype kind: str or ~azure.mgmt.guestconfig.models.Kind + :keyword name: Name of the guest configuration. + :paramtype name: str + :keyword version: Version of the guest configuration. + :paramtype version: str + :keyword content_uri: Uri of the storage where guest configuration package is uploaded. + :paramtype content_uri: str + :keyword content_hash: Combined hash of the guest configuration package and configuration + parameters. + :paramtype content_hash: str + :keyword assignment_type: Specifies the assignment type and execution of the configuration. + Possible values are Audit, DeployAndAutoCorrect, ApplyAndAutoCorrect and ApplyAndMonitor. Known + values are: "Audit", "DeployAndAutoCorrect", "ApplyAndAutoCorrect", "ApplyAndMonitor". + :paramtype assignment_type: str or ~azure.mgmt.guestconfig.models.AssignmentType + :keyword configuration_parameter: The configuration parameters for the guest configuration. + :paramtype configuration_parameter: list[~azure.mgmt.guestconfig.models.ConfigurationParameter] + :keyword configuration_protected_parameter: The protected configuration parameters for the + guest configuration. + :paramtype configuration_protected_parameter: + list[~azure.mgmt.guestconfig.models.ConfigurationParameter] + """ super(GuestConfigurationNavigation, self).__init__(**kwargs) self.kind = kind self.name = name @@ -793,20 +965,23 @@ def __init__( self.content_uri = content_uri self.content_hash = content_hash self.assignment_type = assignment_type + self.assignment_source = None + self.content_type = None self.configuration_parameter = configuration_parameter - self.configuration_setting = configuration_setting + self.configuration_protected_parameter = configuration_protected_parameter + self.configuration_setting = None class Operation(msrest.serialization.Model): """GuestConfiguration REST API operation. - :param name: Operation name: For ex. + :ivar name: Operation name: For ex. providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/write or read. - :type name: str - :param display: Provider, Resource, Operation and description values. - :type display: ~azure.mgmt.guestconfig.models.OperationDisplay - :param status_code: Service provider: Microsoft.GuestConfiguration. - :type status_code: str + :vartype name: str + :ivar display: Provider, Resource, Operation and description values. + :vartype display: ~azure.mgmt.guestconfig.models.OperationDisplay + :ivar status_code: Service provider: Microsoft.GuestConfiguration. + :vartype status_code: str """ _attribute_map = { @@ -819,10 +994,19 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, status_code: Optional[str] = None, **kwargs ): + """ + :keyword name: Operation name: For ex. + providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/write or read. + :paramtype name: str + :keyword display: Provider, Resource, Operation and description values. + :paramtype display: ~azure.mgmt.guestconfig.models.OperationDisplay + :keyword status_code: Service provider: Microsoft.GuestConfiguration. + :paramtype status_code: str + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -832,14 +1016,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """Provider, Resource, Operation and description values. - :param provider: Service provider: Microsoft.GuestConfiguration. - :type provider: str - :param resource: Resource on which the operation is performed: For ex. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description about operation. - :type description: str + :ivar provider: Service provider: Microsoft.GuestConfiguration. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: For ex. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description about operation. + :vartype description: str """ _attribute_map = { @@ -858,6 +1042,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.GuestConfiguration. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: For ex. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description about operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -868,8 +1062,8 @@ def __init__( class OperationList(msrest.serialization.Model): """The response model for the list of Automation operations. - :param value: List of Automation operations supported by the Automation resource provider. - :type value: list[~azure.mgmt.guestconfig.models.Operation] + :ivar value: List of Automation operations supported by the Automation resource provider. + :vartype value: list[~azure.mgmt.guestconfig.models.Operation] """ _attribute_map = { @@ -879,13 +1073,81 @@ class OperationList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, **kwargs ): + """ + :keyword value: List of Automation operations supported by the Automation resource provider. + :paramtype value: list[~azure.mgmt.guestconfig.models.Operation] + """ super(OperationList, self).__init__(**kwargs) self.value = value +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.guestconfig.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.guestconfig.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.guestconfig.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.guestconfig.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + class VMInfo(msrest.serialization.Model): """Information about the VM. @@ -911,6 +1173,56 @@ def __init__( self, **kwargs ): + """ + """ super(VMInfo, self).__init__(**kwargs) self.id = None self.uuid = None + + +class VMSSVMInfo(msrest.serialization.Model): + """Information about VMSS VM. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar vm_id: UUID of the VM. + :vartype vm_id: str + :ivar vm_resource_id: Azure resource Id of the VM. + :vartype vm_resource_id: str + :ivar compliance_status: A value indicating compliance status of the machine for the assigned + guest configuration. Known values are: "Compliant", "NonCompliant", "Pending". + :vartype compliance_status: str or ~azure.mgmt.guestconfig.models.ComplianceStatus + :ivar latest_report_id: Id of the latest report for the guest configuration assignment. + :vartype latest_report_id: str + :ivar last_compliance_checked: Date and time when last compliance status was checked. + :vartype last_compliance_checked: ~datetime.datetime + """ + + _validation = { + 'vm_id': {'readonly': True}, + 'vm_resource_id': {'readonly': True}, + 'compliance_status': {'readonly': True}, + 'latest_report_id': {'readonly': True}, + 'last_compliance_checked': {'readonly': True}, + } + + _attribute_map = { + 'vm_id': {'key': 'vmId', 'type': 'str'}, + 'vm_resource_id': {'key': 'vmResourceId', 'type': 'str'}, + 'compliance_status': {'key': 'complianceStatus', 'type': 'str'}, + 'latest_report_id': {'key': 'latestReportId', 'type': 'str'}, + 'last_compliance_checked': {'key': 'lastComplianceChecked', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(VMSSVMInfo, self).__init__(**kwargs) + self.vm_id = None + self.vm_resource_id = None + self.compliance_status = None + self.latest_report_id = None + self.last_compliance_checked = None diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/models/_patch.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/models/_patch.py new file mode 100644 index 0000000000000..0ad201a8c586e --- /dev/null +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/__init__.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/__init__.py index 9ec9e96e98e59..8e546ba6ff4e0 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/__init__.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/__init__.py @@ -10,12 +10,21 @@ from ._guest_configuration_assignment_reports_operations import GuestConfigurationAssignmentReportsOperations from ._guest_configuration_hcrp_assignments_operations import GuestConfigurationHCRPAssignmentsOperations from ._guest_configuration_hcrp_assignment_reports_operations import GuestConfigurationHCRPAssignmentReportsOperations +from ._guest_configuration_assignments_vmss_operations import GuestConfigurationAssignmentsVMSSOperations +from ._guest_configuration_assignment_reports_vmss_operations import GuestConfigurationAssignmentReportsVMSSOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'GuestConfigurationAssignmentsOperations', 'GuestConfigurationAssignmentReportsOperations', 'GuestConfigurationHCRPAssignmentsOperations', 'GuestConfigurationHCRPAssignmentReportsOperations', + 'GuestConfigurationAssignmentsVMSSOperations', + 'GuestConfigurationAssignmentReportsVMSSOperations', 'Operations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_guest_configuration_assignment_reports_operations.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_guest_configuration_assignment_reports_operations.py index fcd6da97a0c61..9dc1f674b24bf 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_guest_configuration_assignment_reports_operations.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_guest_configuration_assignment_reports_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,133 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._vendor import _convert_request, _format_url_section +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( + resource_group_name: str, + guest_configuration_assignment_name: str, + subscription_id: str, + vm_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), + "guestConfigurationAssignmentName": _SERIALIZER.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "vmName": _SERIALIZER.url("vm_name", vm_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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( + resource_group_name: str, + guest_configuration_assignment_name: str, + report_id: str, + subscription_id: str, + vm_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + accept = _headers.pop('Accept', "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports/{reportId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), + "guestConfigurationAssignmentName": _SERIALIZER.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), + "reportId": _SERIALIZER.url("report_id", report_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "vmName": _SERIALIZER.url("vm_name", vm_name, 'str'), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url = _format_url_section(_url, **path_format_arguments) -class GuestConfigurationAssignmentReportsOperations(object): - """GuestConfigurationAssignmentReportsOperations operations. + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.guestconfig.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class GuestConfigurationAssignmentReportsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.guestconfig.GuestConfigurationClient`'s + :attr:`guest_configuration_assignment_reports` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, - resource_group_name, # type: str - guest_configuration_assignment_name, # type: str - vm_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GuestConfigurationAssignmentReportList" + resource_group_name: str, + guest_configuration_assignment_name: str, + vm_name: str, + **kwargs: Any + ) -> _models.GuestConfigurationAssignmentReportList: """List all reports for the guest configuration assignment, latest report first. :param resource_group_name: The resource group name. @@ -65,39 +146,41 @@ def list( :rtype: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentReportList :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignmentReportList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'guestConfigurationAssignmentName': self._serialize.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'vmName': self._serialize.url("vm_name", vm_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignmentReportList] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + resource_group_name=resource_group_name, + guest_configuration_assignment_name=guest_configuration_assignment_name, + subscription_id=self._config.subscription_id, + vm_name=vm_name, + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GuestConfigurationAssignmentReportList', pipeline_response) @@ -106,17 +189,19 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports"} # type: ignore + + + @distributed_trace def get( self, - resource_group_name, # type: str - guest_configuration_assignment_name, # type: str - report_id, # type: str - vm_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GuestConfigurationAssignmentReport" + resource_group_name: str, + guest_configuration_assignment_name: str, + report_id: str, + vm_name: str, + **kwargs: Any + ) -> _models.GuestConfigurationAssignmentReport: """Get a report for the guest configuration assignment, by reportId. :param resource_group_name: The resource group name. @@ -132,40 +217,42 @@ def get( :rtype: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentReport :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignmentReport"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'guestConfigurationAssignmentName': self._serialize.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), - 'reportId': self._serialize.url("report_id", report_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'vmName': self._serialize.url("vm_name", vm_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignmentReport] - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_get_request( + resource_group_name=resource_group_name, + guest_configuration_assignment_name=guest_configuration_assignment_name, + report_id=report_id, + subscription_id=self._config.subscription_id, + vm_name=vm_name, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GuestConfigurationAssignmentReport', pipeline_response) @@ -174,4 +261,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports/{reportId}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports/{reportId}"} # type: ignore + diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_guest_configuration_assignment_reports_vmss_operations.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_guest_configuration_assignment_reports_vmss_operations.py new file mode 100644 index 0000000000000..297c5309e54be --- /dev/null +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_guest_configuration_assignment_reports_vmss_operations.py @@ -0,0 +1,295 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._vendor import _convert_request, _format_url_section +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( + subscription_id: str, + resource_group_name: str, + vmss_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{name}/reports") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), + "vmssName": _SERIALIZER.url("vmss_name", vmss_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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( + subscription_id: str, + resource_group_name: str, + vmss_name: str, + name: str, + id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{name}/reports/{id}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), + "vmssName": _SERIALIZER.url("vmss_name", vmss_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 GuestConfigurationAssignmentReportsVMSSOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.guestconfig.GuestConfigurationClient`'s + :attr:`guest_configuration_assignment_reports_vmss` 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, + resource_group_name: str, + vmss_name: str, + name: str, + **kwargs: Any + ) -> Iterable[_models.GuestConfigurationAssignmentReportList]: + """List all reports for the VMSS guest configuration assignment, latest report first. + + :param resource_group_name: The resource group name. + :type resource_group_name: str + :param vmss_name: The name of the virtual machine scale set. + :type vmss_name: str + :param name: The guest configuration assignment name. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GuestConfigurationAssignmentReportList or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentReportList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignmentReportList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmss_name=vmss_name, + name=name, + 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) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmss_name=vmss_name, + name=name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GuestConfigurationAssignmentReportList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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.Compute/virtualMachineScaleSets/{vmssName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{name}/reports"} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + vmss_name: str, + name: str, + id: str, + **kwargs: Any + ) -> _models.GuestConfigurationAssignmentReport: + """Get a report for the VMSS guest configuration assignment, by reportId. + + :param resource_group_name: The resource group name. + :type resource_group_name: str + :param vmss_name: The name of the virtual machine scale set. + :type vmss_name: str + :param name: The guest configuration assignment name. + :type name: str + :param id: The GUID for the guest configuration assignment report. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GuestConfigurationAssignmentReport, or the result of cls(response) + :rtype: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentReport + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignmentReport] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmss_name=vmss_name, + name=name, + id=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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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('GuestConfigurationAssignmentReport', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{name}/reports/{id}"} # type: ignore + diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_guest_configuration_assignments_operations.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_guest_configuration_assignments_operations.py index f518307777cdf..af0deaccce58a 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_guest_configuration_assignments_operations.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_guest_configuration_assignments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,55 +6,285 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._vendor import _convert_request, _format_url_section +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( + guest_configuration_assignment_name: str, + subscription_id: str, + resource_group_name: str, + vm_name: str, + *, + json: Optional[_models.GuestConfigurationAssignment] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}") # pylint: disable=line-too-long + path_format_arguments = { + "guestConfigurationAssignmentName": _SERIALIZER.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), + "vmName": _SERIALIZER.url("vm_name", vm_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + guest_configuration_assignment_name: str, + subscription_id: str, + vm_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), + "guestConfigurationAssignmentName": _SERIALIZER.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "vmName": _SERIALIZER.url("vm_name", vm_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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, + guest_configuration_assignment_name: str, + subscription_id: str, + vm_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), + "guestConfigurationAssignmentName": _SERIALIZER.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "vmName": _SERIALIZER.url("vm_name", vm_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_subscription_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_rg_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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, + subscription_id: str, + vm_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "vmName": _SERIALIZER.url("vm_name", vm_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 GuestConfigurationAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class GuestConfigurationAssignmentsOperations(object): - """GuestConfigurationAssignmentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.guestconfig.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.guestconfig.GuestConfigurationClient`'s + :attr:`guest_configuration_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def create_or_update( self, - guest_configuration_assignment_name, # type: str - resource_group_name, # type: str - vm_name, # type: str - parameters, # type: "_models.GuestConfigurationAssignment" - **kwargs # type: Any - ): - # type: (...) -> "_models.GuestConfigurationAssignment" + guest_configuration_assignment_name: str, + resource_group_name: str, + vm_name: str, + parameters: _models.GuestConfigurationAssignment, + **kwargs: Any + ) -> _models.GuestConfigurationAssignment: """Creates an association between a VM and guest configuration. :param guest_configuration_assignment_name: Name of the guest configuration assignment. @@ -69,44 +300,45 @@ def create_or_update( :rtype: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'guestConfigurationAssignmentName': self._serialize.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'vmName': self._serialize.url("vm_name", vm_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GuestConfigurationAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignment] + + _json = self._serialize.body(parameters, 'GuestConfigurationAssignment') + + request = build_create_or_update_request( + guest_configuration_assignment_name=guest_configuration_assignment_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vm_name=vm_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -119,16 +351,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}"} # type: ignore + + + @distributed_trace def get( self, - resource_group_name, # type: str - guest_configuration_assignment_name, # type: str - vm_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GuestConfigurationAssignment" + resource_group_name: str, + guest_configuration_assignment_name: str, + vm_name: str, + **kwargs: Any + ) -> _models.GuestConfigurationAssignment: """Get information about a guest configuration assignment. :param resource_group_name: The resource group name. @@ -142,39 +376,41 @@ def get( :rtype: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'guestConfigurationAssignmentName': self._serialize.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'vmName': self._serialize.url("vm_name", vm_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignment] + + + request = build_get_request( + resource_group_name=resource_group_name, + guest_configuration_assignment_name=guest_configuration_assignment_name, + subscription_id=self._config.subscription_id, + vm_name=vm_name, + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GuestConfigurationAssignment', pipeline_response) @@ -183,16 +419,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}'} # type: ignore - def delete( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - guest_configuration_assignment_name, # type: str - vm_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + guest_configuration_assignment_name: str, + vm_name: str, + **kwargs: Any + ) -> None: """Delete a guest configuration assignment. :param resource_group_name: The resource group name. @@ -206,53 +444,223 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'guestConfigurationAssignmentName': self._serialize.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'vmName': self._serialize.url("vm_name", vm_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + guest_configuration_assignment_name=guest_configuration_assignment_name, + subscription_id=self._config.subscription_id, + vm_name=vm_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + 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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}"} # type: ignore + + @distributed_trace + def subscription_list( + self, + **kwargs: Any + ) -> Iterable[_models.GuestConfigurationAssignmentList]: + """List all guest configuration assignments for a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GuestConfigurationAssignmentList or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_subscription_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.subscription_list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_subscription_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GuestConfigurationAssignmentList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 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) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + subscription_list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments"} # type: ignore + + @distributed_trace + def rg_list( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.GuestConfigurationAssignmentList]: + """List all guest configuration assignments for a resource group. + + :param resource_group_name: The resource group name. + :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 GuestConfigurationAssignmentList or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_rg_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.rg_list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_rg_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GuestConfigurationAssignmentList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 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) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + rg_list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments"} # type: ignore + + @distributed_trace def list( self, - resource_group_name, # type: str - vm_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.GuestConfigurationAssignmentList"] + resource_group_name: str, + vm_name: str, + **kwargs: Any + ) -> Iterable[_models.GuestConfigurationAssignmentList]: """List all guest configuration assignments for a virtual machine. :param resource_group_name: The resource group name. @@ -260,45 +668,55 @@ def list( :param vm_name: The name of the virtual machine. :type vm_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GuestConfigurationAssignmentList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentList] + :return: An iterator like instance of either GuestConfigurationAssignmentList or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignmentList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignmentList] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'vmName': self._serialize.url("vm_name", vm_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + vm_name=vm_name, + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + vm_name=vm_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('GuestConfigurationAssignmentList', pipeline_response) + deserialized = self._deserialize("GuestConfigurationAssignmentList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -307,17 +725,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments"} # type: ignore diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_guest_configuration_assignments_vmss_operations.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_guest_configuration_assignments_vmss_operations.py new file mode 100644 index 0000000000000..5318dbf29dea7 --- /dev/null +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_guest_configuration_assignments_vmss_operations.py @@ -0,0 +1,391 @@ +# 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 + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 .._vendor import _convert_request, _format_url_section +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( + subscription_id: str, + resource_group_name: str, + vmss_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{name}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), + "vmssName": _SERIALIZER.url("vmss_name", vmss_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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( + subscription_id: str, + resource_group_name: str, + vmss_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{name}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), + "vmssName": _SERIALIZER.url("vmss_name", vmss_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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, + subscription_id: str, + vmss_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "vmssName": _SERIALIZER.url("vmss_name", vmss_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 GuestConfigurationAssignmentsVMSSOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.guestconfig.GuestConfigurationClient`'s + :attr:`guest_configuration_assignments_vmss` 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, + vmss_name: str, + name: str, + **kwargs: Any + ) -> _models.GuestConfigurationAssignment: + """Get information about a guest configuration assignment for VMSS. + + :param resource_group_name: The resource group name. + :type resource_group_name: str + :param vmss_name: The name of the virtual machine scale set. + :type vmss_name: str + :param name: The guest configuration assignment name. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GuestConfigurationAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignment] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmss_name=vmss_name, + name=name, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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('GuestConfigurationAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{name}"} # type: ignore + + + @distributed_trace + def delete( + self, + resource_group_name: str, + vmss_name: str, + name: str, + **kwargs: Any + ) -> Optional[_models.GuestConfigurationAssignment]: + """Delete a guest configuration assignment for VMSS. + + :param resource_group_name: The resource group name. + :type resource_group_name: str + :param vmss_name: The name of the virtual machine scale set. + :type vmss_name: str + :param name: The guest configuration assignment name. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GuestConfigurationAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.GuestConfigurationAssignment]] + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vmss_name=vmss_name, + name=name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 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) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GuestConfigurationAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{name}"} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + vmss_name: str, + **kwargs: Any + ) -> Iterable[_models.GuestConfigurationAssignmentList]: + """List all guest configuration assignments for VMSS. + + :param resource_group_name: The resource group name. + :type resource_group_name: str + :param vmss_name: The name of the virtual machine scale set. + :type vmss_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GuestConfigurationAssignmentList or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + vmss_name=vmss_name, + 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) # type: ignore + + else: + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + vmss_name=vmss_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GuestConfigurationAssignmentList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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.Compute/virtualMachineScaleSets/{vmssName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments"} # type: ignore diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_guest_configuration_hcrp_assignment_reports_operations.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_guest_configuration_hcrp_assignment_reports_operations.py index 0a6ae622a3b62..ac2209663a535 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_guest_configuration_hcrp_assignment_reports_operations.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_guest_configuration_hcrp_assignment_reports_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,133 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._vendor import _convert_request, _format_url_section +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( + resource_group_name: str, + guest_configuration_assignment_name: str, + subscription_id: str, + machine_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), + "guestConfigurationAssignmentName": _SERIALIZER.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "machineName": _SERIALIZER.url("machine_name", machine_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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( + resource_group_name: str, + guest_configuration_assignment_name: str, + report_id: str, + subscription_id: str, + machine_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + accept = _headers.pop('Accept', "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports/{reportId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), + "guestConfigurationAssignmentName": _SERIALIZER.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), + "reportId": _SERIALIZER.url("report_id", report_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "machineName": _SERIALIZER.url("machine_name", machine_name, 'str'), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url = _format_url_section(_url, **path_format_arguments) -class GuestConfigurationHCRPAssignmentReportsOperations(object): - """GuestConfigurationHCRPAssignmentReportsOperations operations. + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.guestconfig.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class GuestConfigurationHCRPAssignmentReportsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.guestconfig.GuestConfigurationClient`'s + :attr:`guest_configuration_hcrp_assignment_reports` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, - resource_group_name, # type: str - guest_configuration_assignment_name, # type: str - machine_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GuestConfigurationAssignmentReportList" + resource_group_name: str, + guest_configuration_assignment_name: str, + machine_name: str, + **kwargs: Any + ) -> _models.GuestConfigurationAssignmentReportList: """List all reports for the guest configuration assignment, latest report first. :param resource_group_name: The resource group name. @@ -65,39 +146,41 @@ def list( :rtype: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentReportList :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignmentReportList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'guestConfigurationAssignmentName': self._serialize.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'machineName': self._serialize.url("machine_name", machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignmentReportList] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + resource_group_name=resource_group_name, + guest_configuration_assignment_name=guest_configuration_assignment_name, + subscription_id=self._config.subscription_id, + machine_name=machine_name, + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GuestConfigurationAssignmentReportList', pipeline_response) @@ -106,17 +189,19 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports"} # type: ignore + + + @distributed_trace def get( self, - resource_group_name, # type: str - guest_configuration_assignment_name, # type: str - report_id, # type: str - machine_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GuestConfigurationAssignmentReport" + resource_group_name: str, + guest_configuration_assignment_name: str, + report_id: str, + machine_name: str, + **kwargs: Any + ) -> _models.GuestConfigurationAssignmentReport: """Get a report for the guest configuration assignment, by reportId. :param resource_group_name: The resource group name. @@ -132,40 +217,42 @@ def get( :rtype: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentReport :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignmentReport"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'guestConfigurationAssignmentName': self._serialize.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), - 'reportId': self._serialize.url("report_id", report_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'machineName': self._serialize.url("machine_name", machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignmentReport] - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_get_request( + resource_group_name=resource_group_name, + guest_configuration_assignment_name=guest_configuration_assignment_name, + report_id=report_id, + subscription_id=self._config.subscription_id, + machine_name=machine_name, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GuestConfigurationAssignmentReport', pipeline_response) @@ -174,4 +261,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports/{reportId}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports/{reportId}"} # type: ignore + diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_guest_configuration_hcrp_assignments_operations.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_guest_configuration_hcrp_assignments_operations.py index a50b5cd21b177..a08f113ad73ba 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_guest_configuration_hcrp_assignments_operations.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_guest_configuration_hcrp_assignments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,55 +6,217 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._vendor import _convert_request, _format_url_section +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( + guest_configuration_assignment_name: str, + subscription_id: str, + resource_group_name: str, + machine_name: str, + *, + json: Optional[_models.GuestConfigurationAssignment] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}") # pylint: disable=line-too-long + path_format_arguments = { + "guestConfigurationAssignmentName": _SERIALIZER.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), + "machineName": _SERIALIZER.url("machine_name", machine_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + guest_configuration_assignment_name: str, + subscription_id: str, + machine_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), + "guestConfigurationAssignmentName": _SERIALIZER.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "machineName": _SERIALIZER.url("machine_name", machine_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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, + guest_configuration_assignment_name: str, + subscription_id: str, + machine_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), + "guestConfigurationAssignmentName": _SERIALIZER.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "machineName": _SERIALIZER.url("machine_name", machine_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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, + subscription_id: str, + machine_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "machineName": _SERIALIZER.url("machine_name", machine_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 GuestConfigurationHCRPAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class GuestConfigurationHCRPAssignmentsOperations(object): - """GuestConfigurationHCRPAssignmentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.guestconfig.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.guestconfig.GuestConfigurationClient`'s + :attr:`guest_configuration_hcrp_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def create_or_update( self, - guest_configuration_assignment_name, # type: str - resource_group_name, # type: str - machine_name, # type: str - parameters, # type: "_models.GuestConfigurationAssignment" - **kwargs # type: Any - ): - # type: (...) -> "_models.GuestConfigurationAssignment" + guest_configuration_assignment_name: str, + resource_group_name: str, + machine_name: str, + parameters: _models.GuestConfigurationAssignment, + **kwargs: Any + ) -> _models.GuestConfigurationAssignment: """Creates an association between a ARC machine and guest configuration. :param guest_configuration_assignment_name: Name of the guest configuration assignment. @@ -69,44 +232,45 @@ def create_or_update( :rtype: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'guestConfigurationAssignmentName': self._serialize.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'machineName': self._serialize.url("machine_name", machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GuestConfigurationAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignment] + + _json = self._serialize.body(parameters, 'GuestConfigurationAssignment') + + request = build_create_or_update_request( + guest_configuration_assignment_name=guest_configuration_assignment_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + machine_name=machine_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -119,16 +283,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}"} # type: ignore + + + @distributed_trace def get( self, - resource_group_name, # type: str - guest_configuration_assignment_name, # type: str - machine_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GuestConfigurationAssignment" + resource_group_name: str, + guest_configuration_assignment_name: str, + machine_name: str, + **kwargs: Any + ) -> _models.GuestConfigurationAssignment: """Get information about a guest configuration assignment. :param resource_group_name: The resource group name. @@ -142,39 +308,41 @@ def get( :rtype: ~azure.mgmt.guestconfig.models.GuestConfigurationAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'guestConfigurationAssignmentName': self._serialize.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'machineName': self._serialize.url("machine_name", machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignment] + + + request = build_get_request( + resource_group_name=resource_group_name, + guest_configuration_assignment_name=guest_configuration_assignment_name, + subscription_id=self._config.subscription_id, + machine_name=machine_name, + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GuestConfigurationAssignment', pipeline_response) @@ -183,16 +351,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}'} # type: ignore - def delete( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - guest_configuration_assignment_name, # type: str - machine_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + guest_configuration_assignment_name: str, + machine_name: str, + **kwargs: Any + ) -> None: """Delete a guest configuration assignment. :param resource_group_name: The resource group name. @@ -206,53 +376,56 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'guestConfigurationAssignmentName': self._serialize.url("guest_configuration_assignment_name", guest_configuration_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'machineName': self._serialize.url("machine_name", machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + guest_configuration_assignment_name=guest_configuration_assignment_name, + subscription_id=self._config.subscription_id, + machine_name=machine_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + 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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}"} # type: ignore + + @distributed_trace def list( self, - resource_group_name, # type: str - machine_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.GuestConfigurationAssignmentList"] + resource_group_name: str, + machine_name: str, + **kwargs: Any + ) -> Iterable[_models.GuestConfigurationAssignmentList]: """List all guest configuration assignments for an ARC machine. :param resource_group_name: The resource group name. @@ -260,45 +433,55 @@ def list( :param machine_name: The name of the ARC machine. :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 GuestConfigurationAssignmentList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentList] + :return: An iterator like instance of either GuestConfigurationAssignmentList or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.guestconfig.models.GuestConfigurationAssignmentList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignmentList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestConfigurationAssignmentList] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[-\w\._]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'machineName': self._serialize.url("machine_name", machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + machine_name=machine_name, + 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) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + machine_name=machine_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('GuestConfigurationAssignmentList', pipeline_response) + deserialized = self._deserialize("GuestConfigurationAssignmentList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -307,17 +490,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments"} # type: ignore diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_operations.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_operations.py index 13554fcf07369..323e466ca81b5 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_operations.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,51 +6,78 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .._vendor import _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( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + accept = _headers.pop('Accept', "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.GuestConfiguration/operations") -class Operations(object): - """Operations operations. + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.guestconfig.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.guestconfig.GuestConfigurationClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationList"] + **kwargs: Any + ) -> Iterable[_models.OperationList]: """Lists all of the available GuestConfiguration REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -57,35 +85,43 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.guestconfig.models.OperationList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationList] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + 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) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationList', pipeline_response) + deserialized = self._deserialize("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,17 +130,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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': '/providers/Microsoft.GuestConfiguration/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.GuestConfiguration/operations"} # type: ignore diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_patch.py b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_patch.py new file mode 100644 index 0000000000000..0ad201a8c586e --- /dev/null +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """