diff --git a/sdk/machinelearning/azure-mgmt-guestconfig/_meta.json b/sdk/machinelearning/azure-mgmt-guestconfig/_meta.json index acfcecc0577c0..4ead1a4b1cac9 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.12.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "33b8d6f7bf2eb081fe134333b0fc445777e488d6", + "commit": "cea6492a1e41b3f3b4f8b4f69bdcc10431e79c0e", "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 --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.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..5a1f8a26a15b5 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/__init__.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['GuestConfigurationClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() 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..f21cccd3abaf9 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/_configuration.py +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/_configuration.py @@ -6,18 +6,16 @@ # 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 @@ -35,16 +33,15 @@ class GuestConfigurationClientConfiguration(Configuration): 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) 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 @@ -68,4 +65,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..944ac8f909b38 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,96 @@ # 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, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import GuestConfigurationClientConfiguration +from .operations import GuestConfigurationAssignmentReportsOperations, GuestConfigurationAssignmentsOperations, GuestConfigurationHCRPAssignmentReportsOperations, GuestConfigurationHCRPAssignmentsOperations, Operations + 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 ._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 - -class GuestConfigurationClient(object): +class GuestConfigurationClient: """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 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 """ 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.guest_configuration_assignment_reports = GuestConfigurationAssignmentReportsOperations(self._client, self._config, self._serialize, self._deserialize) + self.guest_configuration_hcrp_assignments = GuestConfigurationHCRPAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.guest_configuration_hcrp_assignment_reports = GuestConfigurationHCRPAssignmentReportsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.guest_configuration_assignments = GuestConfigurationAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.guest_configuration_assignment_reports = GuestConfigurationAssignmentReportsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.guest_configuration_hcrp_assignments = GuestConfigurationHCRPAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.guest_configuration_hcrp_assignment_reports = GuestConfigurationHCRPAssignmentReportsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + + def _send_request( + self, + request, # type: 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 index 8b0f39452c809..8ab8598473a78 100644 --- a/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/_metadata.json +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/_metadata.json @@ -5,13 +5,13 @@ "name": "GuestConfigurationClient", "filename": "_guest_configuration_client", "description": "Guest Configuration Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": 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\"]}}}" + "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\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"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\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "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\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"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\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "guest_configuration_assignments": "GuestConfigurationAssignmentsOperations", 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..74e48ecd07cf3 --- /dev/null +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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..d4ac83dd94547 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 @@ -8,3 +8,8 @@ from ._guest_configuration_client import GuestConfigurationClient __all__ = ['GuestConfigurationClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() 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..15e6c3467f249 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 @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(GuestConfigurationClientConfiguration, self).__init__(**kwargs) 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 @@ -64,4 +64,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..7c636cf4ed94e 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,96 @@ # 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, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import GuestConfigurationClientConfiguration +from .operations import GuestConfigurationAssignmentReportsOperations, GuestConfigurationAssignmentsOperations, GuestConfigurationHCRPAssignmentReportsOperations, GuestConfigurationHCRPAssignmentsOperations, Operations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -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 - - -class GuestConfigurationClient(object): +class GuestConfigurationClient: """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 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 """ 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.guest_configuration_assignment_reports = GuestConfigurationAssignmentReportsOperations(self._client, self._config, self._serialize, self._deserialize) + self.guest_configuration_hcrp_assignments = GuestConfigurationHCRPAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.guest_configuration_hcrp_assignment_reports = GuestConfigurationHCRPAssignmentReportsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + - self.guest_configuration_assignments = GuestConfigurationAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.guest_configuration_assignment_reports = GuestConfigurationAssignmentReportsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.guest_configuration_hcrp_assignments = GuestConfigurationHCRPAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.guest_configuration_hcrp_assignment_reports = GuestConfigurationHCRPAssignmentReportsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - 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..74e48ecd07cf3 --- /dev/null +++ b/sdk/machinelearning/azure-mgmt-guestconfig/azure/mgmt/guestconfig/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ 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..8fdc0e20a8a51 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_group_name: str, @@ -65,34 +70,24 @@ async def list( 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 = 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +96,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 + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -131,35 +129,25 @@ async def get( 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 = 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +156,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 + 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..e8a4377205715 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, guest_configuration_assignment_name: str, @@ -69,39 +75,29 @@ async def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,8 +110,11 @@ 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 + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -141,34 +140,24 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +166,11 @@ 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -204,34 +196,24 @@ async def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -239,6 +221,145 @@ async def delete( 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignmentList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_subscription_list_request( + subscription_id=self._config.subscription_id, + template_url=self.subscription_list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_subscription_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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(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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignmentList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.rg_list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_rg_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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(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, @@ -252,8 +373,10 @@ 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"] @@ -261,36 +384,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('GuestConfigurationAssignmentList', pipeline_response) + deserialized = self._deserialize("GuestConfigurationAssignmentList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -303,12 +423,13 @@ async def get_next(next_link=None): 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 ) 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..7fdc7b9ac625a 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_group_name: str, @@ -65,34 +70,24 @@ async def list( 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 = 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +96,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 + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -131,35 +129,25 @@ async def get( 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 = 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +156,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 + 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..6b5cc14c03f60 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, guest_configuration_assignment_name: str, @@ -69,39 +75,29 @@ async def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,8 +110,11 @@ 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 + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -141,34 +140,24 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +166,11 @@ 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -204,34 +196,24 @@ async def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -239,6 +221,8 @@ async def delete( 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, @@ -252,8 +236,10 @@ 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"] @@ -261,36 +247,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('GuestConfigurationAssignmentList', pipeline_response) + deserialized = self._deserialize("GuestConfigurationAssignmentList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -303,12 +286,13 @@ async def get_next(next_link=None): 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 ) 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..67780c0e187aa 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -57,30 +63,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - 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( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationList', pipeline_response) + deserialized = self._deserialize("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +96,13 @@ async def get_next(next_link=None): 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 ) 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..30e46367cbf24 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,54 +6,31 @@ # 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 VMInfo +from ._models_py3 import VMSSVMInfo + from ._guest_configuration_client_enums import ( ActionAfterReboot, @@ -89,6 +66,7 @@ 'ProxyResource', 'Resource', 'VMInfo', + 'VMSSVMInfo', 'ActionAfterReboot', 'AssignmentType', 'ComplianceStatus', 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..837da56bb6260 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,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -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)): +class ActionAfterReboot(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies what happens after a reboot during the application of a configuration. The possible values are ContinueConfiguration and StopConfiguration """ @@ -34,7 +19,7 @@ class ActionAfterReboot(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CONTINUE_CONFIGURATION = "ContinueConfiguration" STOP_CONFIGURATION = "StopConfiguration" -class AssignmentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AssignmentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies the assignment type and execution of the configuration. Possible values are Audit, DeployAndAutoCorrect, ApplyAndAutoCorrect and ApplyAndMonitor. """ @@ -44,7 +29,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(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """A value indicating compliance status of the machine for the assigned guest configuration. """ @@ -52,7 +37,7 @@ class ComplianceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): NON_COMPLIANT = "NonCompliant" PENDING = "Pending" -class ConfigurationMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ConfigurationMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies how the LCM(Local Configuration Manager) actually applies the configuration to the target nodes. Possible values are ApplyOnly, ApplyAndMonitor, and ApplyAndAutoCorrect. """ @@ -61,13 +46,13 @@ class ConfigurationMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): APPLY_AND_MONITOR = "ApplyAndMonitor" APPLY_AND_AUTO_CORRECT = "ApplyAndAutoCorrect" -class Kind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Kind of the guest configuration. For example:DSC """ DSC = "DSC" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The provisioning state, which only appears in the response. """ @@ -76,7 +61,7 @@ class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CANCELED = "Canceled" CREATED = "Created" -class Type(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Type(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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..bc669313b06ae 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 @@ -21,8 +21,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 = { @@ -40,6 +40,10 @@ def __init__( configuration: Optional["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 +59,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 @@ -71,9 +75,9 @@ class AssignmentReport(msrest.serialization.Model): :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 + :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 = { @@ -105,6 +109,15 @@ def __init__( resources: Optional[List["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 @@ -136,9 +149,9 @@ class AssignmentReportDetails(msrest.serialization.Model): :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 + :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 = { @@ -164,6 +177,11 @@ def __init__( resources: Optional[List["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 @@ -183,8 +201,8 @@ class AssignmentReportResource(msrest.serialization.Model): :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 """ @@ -208,6 +226,11 @@ def __init__( reasons: Optional[List["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 +263,8 @@ def __init__( self, **kwargs ): + """ + """ super(AssignmentReportResourceComplianceReason, self).__init__(**kwargs) self.phrase = None self.code = None @@ -270,6 +295,8 @@ def __init__( self, **kwargs ): + """ + """ super(ConfigurationInfo, self).__init__(**kwargs) self.name = None self.version = None @@ -278,10 +305,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 +323,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,32 +337,32 @@ 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 + :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 + :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. 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 + :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 """ _attribute_map = { @@ -352,6 +385,34 @@ def __init__( configuration_mode_frequency_mins: Optional[float] = 15, **kwargs ): + """ + :keyword 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". + :paramtype configuration_mode: str or ~azure.mgmt.guestconfig.models.ConfigurationMode + :keyword 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. + :paramtype allow_module_overwrite: bool + :keyword 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". + :paramtype action_after_reboot: str or ~azure.mgmt.guestconfig.models.ActionAfterReboot + :keyword 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. + :paramtype refresh_frequency_mins: float + :keyword 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. + :paramtype reboot_if_needed: bool + :keyword 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. + :paramtype configuration_mode_frequency_mins: float + """ super(ConfigurationSetting, self).__init__(**kwargs) self.configuration_mode = configuration_mode self.allow_module_overwrite = allow_module_overwrite @@ -364,8 +425,8 @@ def __init__( 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 = { @@ -378,6 +439,10 @@ def __init__( error: Optional["ErrorResponseError"] = None, **kwargs ): + """ + :keyword error: + :paramtype error: ~azure.mgmt.guestconfig.models.ErrorResponseError + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -385,10 +450,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 +468,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 +486,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 +513,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 +533,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 +560,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,14 +576,14 @@ 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 """ _validation = { @@ -524,6 +607,14 @@ def __init__( properties: Optional["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 @@ -531,8 +622,8 @@ def __init__( 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 = { @@ -545,6 +636,10 @@ def __init__( value: Optional[List["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,8 +651,8 @@ 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". :vartype compliance_status: str or ~azure.mgmt.guestconfig.models.ComplianceStatus @@ -565,11 +660,16 @@ class GuestConfigurationAssignmentProperties(msrest.serialization.Model): :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 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] + :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 @@ -582,6 +682,8 @@ class GuestConfigurationAssignmentProperties(msrest.serialization.Model): 'compliance_status': {'readonly': True}, 'last_compliance_status_checked': {'readonly': True}, 'latest_report_id': {'readonly': True}, + 'parameter_hash': {'readonly': True}, + 'resource_type': {'readonly': True}, 'assignment_hash': {'readonly': True}, 'provisioning_state': {'readonly': True}, } @@ -592,6 +694,9 @@ 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'}, + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'vmss_vm_list': {'key': 'vmssVMList', 'type': '[VMSSVMInfo]'}, 'latest_assignment_report': {'key': 'latestAssignmentReport', 'type': 'AssignmentReport'}, 'context': {'key': 'context', 'type': 'str'}, 'assignment_hash': {'key': 'assignmentHash', 'type': 'str'}, @@ -602,16 +707,31 @@ def __init__( self, *, guest_configuration: Optional["GuestConfigurationNavigation"] = None, + vmss_vm_list: Optional[List["VMSSVMInfo"]] = None, latest_assignment_report: Optional["AssignmentReport"] = None, context: Optional[str] = None, **kwargs ): + """ + :keyword guest_configuration: The guest configuration to assign. + :paramtype guest_configuration: ~azure.mgmt.guestconfig.models.GuestConfigurationNavigation + :keyword vmss_vm_list: The list of VM Compliance data for VMSS. + :paramtype vmss_vm_list: list[~azure.mgmt.guestconfig.models.VMSSVMInfo] + :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 + """ 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.resource_type = None + self.vmss_vm_list = vmss_vm_list self.latest_assignment_report = latest_assignment_report self.context = context self.assignment_hash = None @@ -628,8 +748,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 = { @@ -649,6 +770,11 @@ def __init__( properties: Optional["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 +784,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 = { @@ -673,6 +799,11 @@ def __init__( value: Optional[List["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 @@ -688,18 +819,20 @@ class GuestConfigurationAssignmentReportProperties(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 :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 +840,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,6 +851,7 @@ 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__( @@ -727,6 +862,14 @@ def __init__( details: Optional["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 +878,47 @@ 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. Possible values include: "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. + :vartype content_hash: str + :ivar 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 assignment_type: str or ~azure.mgmt.guestconfig.models.AssignmentType + :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 = { + 'content_type': {'readonly': True}, + } + _attribute_map = { 'kind': {'key': 'kind', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, @@ -769,7 +926,9 @@ class GuestConfigurationNavigation(msrest.serialization.Model): 'content_uri': {'key': 'contentUri', 'type': 'str'}, 'content_hash': {'key': 'contentHash', 'type': 'str'}, 'assignment_type': {'key': 'assignmentType', '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'}, } @@ -783,9 +942,37 @@ def __init__( content_hash: Optional[str] = None, assignment_type: Optional[Union[str, "AssignmentType"]] = None, configuration_parameter: Optional[List["ConfigurationParameter"]] = None, + configuration_protected_parameter: Optional[List["ConfigurationParameter"]] = None, configuration_setting: Optional["ConfigurationSetting"] = None, **kwargs ): + """ + :keyword kind: Kind of the guest configuration. For example:DSC. Possible values include: + "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. + Possible values include: "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] + :keyword configuration_setting: The configuration setting for the guest configuration. + :paramtype configuration_setting: ~azure.mgmt.guestconfig.models.ConfigurationSetting + """ super(GuestConfigurationNavigation, self).__init__(**kwargs) self.kind = kind self.name = name @@ -793,20 +980,22 @@ def __init__( self.content_uri = content_uri self.content_hash = content_hash self.assignment_type = assignment_type + self.content_type = None self.configuration_parameter = configuration_parameter + self.configuration_protected_parameter = configuration_protected_parameter self.configuration_setting = configuration_setting 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 = { @@ -823,6 +1012,15 @@ def __init__( 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 +1030,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 +1056,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 +1076,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 = { @@ -882,6 +1090,10 @@ def __init__( value: Optional[List["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 @@ -911,6 +1123,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. Possible values include: "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/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..d95e4b7e966ca 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 @@ -5,22 +5,100 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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: + api_version = "2020-06-25" + 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') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2020-06-25" + 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/{reportId}') + 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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class GuestConfigurationAssignmentReportsOperations(object): """GuestConfigurationAssignmentReportsOperations operations. @@ -44,14 +122,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -70,34 +148,24 @@ def list( 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') + + 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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 = self._client._pipeline.run(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 +174,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 + + @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. @@ -137,35 +207,25 @@ def get( 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 = 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +234,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 + 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..bd281d5216d60 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 @@ -5,23 +5,245 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-25" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2020-06-25" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + guest_configuration_assignment_name: str, + subscription_id: str, + vm_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-06-25" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_subscription_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-06-25" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_rg_list_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-06-25" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + resource_group_name: str, + subscription_id: str, + vm_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-06-25" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class GuestConfigurationAssignmentsOperations(object): """GuestConfigurationAssignmentsOperations operations. @@ -45,15 +267,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -74,39 +296,29 @@ def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +331,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 + + @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. @@ -147,34 +361,24 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +387,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 + + @distributed_trace def delete( 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. @@ -211,34 +417,24 @@ def delete( 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) - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -246,13 +442,151 @@ def delete( 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignmentList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_subscription_list_request( + subscription_id=self._config.subscription_id, + template_url=self.subscription_list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_subscription_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("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(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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestConfigurationAssignmentList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.rg_list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_rg_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("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(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,8 +594,10 @@ 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"] @@ -269,36 +605,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('GuestConfigurationAssignmentList', pipeline_response) + deserialized = self._deserialize("GuestConfigurationAssignmentList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -311,12 +644,13 @@ def get_next(next_link=None): 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 ) 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..4ec5c1f5f51aa 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 @@ -5,22 +5,100 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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: + api_version = "2020-06-25" + 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') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2020-06-25" + 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/{reportId}') + 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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class GuestConfigurationHCRPAssignmentReportsOperations(object): """GuestConfigurationHCRPAssignmentReportsOperations operations. @@ -44,14 +122,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -70,34 +148,24 @@ def list( 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') + + 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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 = self._client._pipeline.run(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 +174,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 + + @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. @@ -137,35 +207,25 @@ def get( 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 = 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +234,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 + 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..b9895625f52a9 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 @@ -5,23 +5,181 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-25" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2020-06-25" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + guest_configuration_assignment_name: str, + subscription_id: str, + machine_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-06-25" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + resource_group_name: str, + subscription_id: str, + machine_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-06-25" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class GuestConfigurationHCRPAssignmentsOperations(object): """GuestConfigurationHCRPAssignmentsOperations operations. @@ -45,15 +203,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -74,39 +232,29 @@ def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +267,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 + + @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. @@ -147,34 +297,24 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +323,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 + + @distributed_trace def delete( 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. @@ -211,34 +353,24 @@ def delete( 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) - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -246,13 +378,14 @@ def delete( 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,8 +393,10 @@ 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"] @@ -269,36 +404,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('GuestConfigurationAssignmentList', pipeline_response) + deserialized = self._deserialize("GuestConfigurationAssignmentList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -311,12 +443,13 @@ def get_next(next_link=None): 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 ) 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..95606227860a0 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 @@ -5,23 +5,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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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: + api_version = "2020-06-25" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.GuestConfiguration/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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 @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-25" - accept = "application/json" - 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( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationList', pipeline_response) + deserialized = self._deserialize("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +122,13 @@ def get_next(next_link=None): 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 )