From 39c8143b7ae3af774d93ee1b80ac5810703197e3 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 13 Dec 2021 09:18:07 +0000 Subject: [PATCH] CodeGen from PR 17054 in Azure/azure-rest-api-specs config readme.python (#17054) --- .../azure-mgmt-automanage/_meta.json | 11 + .../azure/mgmt/automanage/__init__.py | 9 +- .../mgmt/automanage/_automanage_client.py | 85 +- .../azure/mgmt/automanage/_configuration.py | 11 +- .../azure/mgmt/automanage/_metadata.json | 90 +- .../azure/mgmt/automanage/_patch.py | 31 + .../azure/mgmt/automanage/_vendor.py | 27 + .../azure/mgmt/automanage/_version.py | 2 +- .../azure/mgmt/automanage/aio/__init__.py | 7 +- .../mgmt/automanage/aio/_automanage_client.py | 110 ++ .../aio/_automanage_client_async.py | 78 -- ...nfiguration_async.py => _configuration.py} | 11 +- .../azure/mgmt/automanage/aio/_patch.py | 31 + .../automanage/aio/operations/__init__.py | 25 + .../operations/_best_practices_operations.py | 156 +++ .../_best_practices_versions_operations.py | 165 +++ ...guration_profile_assignments_operations.py | 362 +++++++ .../_configuration_profiles_operations.py | 408 +++++++ ...figuration_profiles_versions_operations.py | 363 +++++++ .../_operations.py} | 63 +- .../aio/operations/_reports_operations.py | 186 ++++ .../aio/operations_async/__init__.py | 19 - .../_accounts_operations_async.py | 416 -------- ...on_profile_assignments_operations_async.py | 421 -------- ...on_profile_preferences_operations_async.py | 416 -------- .../azure/mgmt/automanage/models/__init__.py | 95 +- .../models/_automanage_client_enums.py | 59 +- .../azure/mgmt/automanage/models/_models.py | 919 +++++++++------- .../mgmt/automanage/models/_models_py3.py | 994 +++++++++++------- .../mgmt/automanage/operations/__init__.py | 14 +- .../operations/_accounts_operations.py | 426 -------- .../operations/_best_practices_operations.py | 223 ++++ .../_best_practices_versions_operations.py | 240 +++++ ...guration_profile_assignments_operations.py | 537 ++++++---- ...guration_profile_preferences_operations.py | 426 -------- .../_configuration_profiles_operations.py | 637 +++++++++++ ...figuration_profiles_versions_operations.py | 570 ++++++++++ .../mgmt/automanage/operations/_operations.py | 90 +- .../operations/_reports_operations.py | 273 +++++ 39 files changed, 5610 insertions(+), 3396 deletions(-) create mode 100644 sdk/automanage/azure-mgmt-automanage/_meta.json create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_patch.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_vendor.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_automanage_client.py delete mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_automanage_client_async.py rename sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/{_configuration_async.py => _configuration.py} (84%) create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_patch.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/__init__.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_best_practices_operations.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_best_practices_versions_operations.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_assignments_operations.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profiles_operations.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profiles_versions_operations.py rename sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/{operations_async/_operations_async.py => operations/_operations.py} (65%) create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_reports_operations.py delete mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/__init__.py delete mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_accounts_operations_async.py delete mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_configuration_profile_assignments_operations_async.py delete mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_configuration_profile_preferences_operations_async.py delete mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_accounts_operations.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_best_practices_operations.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_best_practices_versions_operations.py delete mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_preferences_operations.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profiles_operations.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profiles_versions_operations.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_reports_operations.py diff --git a/sdk/automanage/azure-mgmt-automanage/_meta.json b/sdk/automanage/azure-mgmt-automanage/_meta.json new file mode 100644 index 000000000000..15a831deb7b0 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "39a4d73a0c560c65357c0541803a82daa79b2e88", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/automanage/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.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/automanage/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/__init__.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/__init__.py index e9400926d2ea..0e852bdc349c 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/__init__.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AutomanageClient'] -try: - from ._patch import patch_sdk - 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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_automanage_client.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_automanage_client.py index a35de5853806..ab7979b0ad7f 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_automanage_client.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_automanage_client.py @@ -6,69 +6,100 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import AutomanageClientConfiguration +from .operations import BestPracticesOperations, BestPracticesVersionsOperations, ConfigurationProfileAssignmentsOperations, ConfigurationProfilesOperations, ConfigurationProfilesVersionsOperations, Operations, ReportsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - -from ._configuration import AutomanageClientConfiguration -from .operations import AccountsOperations -from .operations import ConfigurationProfileAssignmentsOperations -from .operations import ConfigurationProfilePreferencesOperations -from .operations import Operations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class AutomanageClient(object): """Automanage Client. - :ivar accounts: AccountsOperations operations - :vartype accounts: automanage_client.operations.AccountsOperations + :ivar best_practices: BestPracticesOperations operations + :vartype best_practices: automanage_client.operations.BestPracticesOperations + :ivar best_practices_versions: BestPracticesVersionsOperations operations + :vartype best_practices_versions: automanage_client.operations.BestPracticesVersionsOperations + :ivar configuration_profiles: ConfigurationProfilesOperations operations + :vartype configuration_profiles: automanage_client.operations.ConfigurationProfilesOperations + :ivar configuration_profiles_versions: ConfigurationProfilesVersionsOperations operations + :vartype configuration_profiles_versions: + automanage_client.operations.ConfigurationProfilesVersionsOperations :ivar configuration_profile_assignments: ConfigurationProfileAssignmentsOperations operations - :vartype configuration_profile_assignments: automanage_client.operations.ConfigurationProfileAssignmentsOperations - :ivar configuration_profile_preferences: ConfigurationProfilePreferencesOperations operations - :vartype configuration_profile_preferences: automanage_client.operations.ConfigurationProfilePreferencesOperations + :vartype configuration_profile_assignments: + automanage_client.operations.ConfigurationProfileAssignmentsOperations :ivar operations: Operations operations :vartype operations: automanage_client.operations.Operations + :ivar reports: ReportsOperations operations + :vartype reports: automanage_client.operations.ReportsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AutomanageClientConfiguration(credential, subscription_id, **kwargs) + self._config = AutomanageClientConfiguration(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._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.best_practices = BestPracticesOperations(self._client, self._config, self._serialize, self._deserialize) + self.best_practices_versions = BestPracticesVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_profiles = ConfigurationProfilesOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_profiles_versions = ConfigurationProfilesVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_profile_assignments = ConfigurationProfileAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.reports = ReportsOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/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.rest.HttpResponse + """ - self.accounts = AccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.configuration_profile_assignments = ConfigurationProfileAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.configuration_profile_preferences = ConfigurationProfilePreferencesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + 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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_configuration.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_configuration.py index 1c10217f4124..b4d4c522b6b3 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_configuration.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_configuration.py @@ -10,6 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -39,17 +40,16 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(AutomanageClientConfiguration, 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(AutomanageClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-06-30-preview" - self.credential_scopes = ['https://management.azure.com/.default'] - self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + self.api_version = "2021-04-30-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-automanage/{}'.format(VERSION)) self._configure(**kwargs) @@ -62,9 +62,10 @@ def _configure( self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) 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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_metadata.json b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_metadata.json index 3ce69338c090..29fc286f2b5c 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_metadata.json +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_metadata.json @@ -1,35 +1,42 @@ { - "chosen_version": "2020-06-30-preview", - "total_api_version_list": ["2020-06-30-preview"], + "chosen_version": "2021-04-30-preview", + "total_api_version_list": ["2021-04-30-preview"], "client": { "name": "AutomanageClient", "filename": "_automanage_client", - "description": "Automanage Client." + "description": "Automanage Client.", + "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\": [\"AutomanageClientConfiguration\"]}}, \"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\": [\"AutomanageClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { - "sync_method": { + "sync": { "credential": { - "method_signature": "credential, # type: \"TokenCredential\"", + "signature": "credential, # type: \"TokenCredential\"", "description": "Credential needed for the client to connect to Azure.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "method_signature": "subscription_id, # type: str", + "signature": "subscription_id, # type: str", "description": "The ID of the target subscription.", "docstring_type": "str", "required": true } }, - "async_method": { + "async": { "credential": { - "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "signature": "credential: \"AsyncTokenCredential\",", "description": "Credential needed for the client to connect to Azure.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { - "method_signature": "subscription_id, # type: str", + "signature": "subscription_id: str,", "description": "The ID of the target subscription.", "docstring_type": "str", "required": true @@ -37,20 +44,65 @@ }, "constant": { }, - "call": "credential, subscription_id" + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } }, "config": { "credential": true, - "credential_scopes": ["https://management.azure.com/.default"] + "credential_scopes": ["https://management.azure.com/.default"], + "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": { - "accounts": "AccountsOperations", + "best_practices": "BestPracticesOperations", + "best_practices_versions": "BestPracticesVersionsOperations", + "configuration_profiles": "ConfigurationProfilesOperations", + "configuration_profiles_versions": "ConfigurationProfilesVersionsOperations", "configuration_profile_assignments": "ConfigurationProfileAssignmentsOperations", - "configuration_profile_preferences": "ConfigurationProfilePreferencesOperations", - "operations": "Operations" - }, - "operation_mixins": { - }, - "sync_imports": "None", - "async_imports": "None" + "operations": "Operations", + "reports": "ReportsOperations" + } } \ No newline at end of file diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_patch.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_vendor.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_version.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_version.py index dfa6ee022f15..e5754a47ce68 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_version.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b2" +VERSION = "1.0.0b1" diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/__init__.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/__init__.py index a724e312f9bb..897a50997673 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/__init__.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/__init__.py @@ -6,5 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._automanage_client_async import AutomanageClient +from ._automanage_client import AutomanageClient __all__ = ['AutomanageClient'] + +# `._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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_automanage_client.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_automanage_client.py new file mode 100644 index 000000000000..f71bb30646e6 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_automanage_client.py @@ -0,0 +1,110 @@ +# 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 copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import AutomanageClientConfiguration +from .operations import BestPracticesOperations, BestPracticesVersionsOperations, ConfigurationProfileAssignmentsOperations, ConfigurationProfilesOperations, ConfigurationProfilesVersionsOperations, Operations, ReportsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class AutomanageClient: + """Automanage Client. + + :ivar best_practices: BestPracticesOperations operations + :vartype best_practices: automanage_client.aio.operations.BestPracticesOperations + :ivar best_practices_versions: BestPracticesVersionsOperations operations + :vartype best_practices_versions: + automanage_client.aio.operations.BestPracticesVersionsOperations + :ivar configuration_profiles: ConfigurationProfilesOperations operations + :vartype configuration_profiles: + automanage_client.aio.operations.ConfigurationProfilesOperations + :ivar configuration_profiles_versions: ConfigurationProfilesVersionsOperations operations + :vartype configuration_profiles_versions: + automanage_client.aio.operations.ConfigurationProfilesVersionsOperations + :ivar configuration_profile_assignments: ConfigurationProfileAssignmentsOperations operations + :vartype configuration_profile_assignments: + automanage_client.aio.operations.ConfigurationProfileAssignmentsOperations + :ivar operations: Operations operations + :vartype operations: automanage_client.aio.operations.Operations + :ivar reports: ReportsOperations operations + :vartype reports: automanage_client.aio.operations.ReportsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :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: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AutomanageClientConfiguration(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._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.best_practices = BestPracticesOperations(self._client, self._config, self._serialize, self._deserialize) + self.best_practices_versions = BestPracticesVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_profiles = ConfigurationProfilesOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_profiles_versions = ConfigurationProfilesVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_profile_assignments = ConfigurationProfileAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.reports = ReportsOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/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.rest.AsyncHttpResponse + """ + + 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() + + async def __aenter__(self) -> "AutomanageClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_automanage_client_async.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_automanage_client_async.py deleted file mode 100644 index e8d0de459d55..000000000000 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_automanage_client_async.py +++ /dev/null @@ -1,78 +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 typing import Any, Optional, TYPE_CHECKING - -from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - -from ._configuration_async import AutomanageClientConfiguration -from .operations_async import AccountsOperations -from .operations_async import ConfigurationProfileAssignmentsOperations -from .operations_async import ConfigurationProfilePreferencesOperations -from .operations_async import Operations -from .. import models - - -class AutomanageClient(object): - """Automanage Client. - - :ivar accounts: AccountsOperations operations - :vartype accounts: automanage_client.aio.operations_async.AccountsOperations - :ivar configuration_profile_assignments: ConfigurationProfileAssignmentsOperations operations - :vartype configuration_profile_assignments: automanage_client.aio.operations_async.ConfigurationProfileAssignmentsOperations - :ivar configuration_profile_preferences: ConfigurationProfilePreferencesOperations operations - :vartype configuration_profile_preferences: automanage_client.aio.operations_async.ConfigurationProfilePreferencesOperations - :ivar operations: Operations operations - :vartype operations: automanage_client.aio.operations_async.Operations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. - :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: Optional[str] = None, - **kwargs: Any - ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AutomanageClientConfiguration(credential, 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._deserialize = Deserializer(client_models) - - self.accounts = AccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.configuration_profile_assignments = ConfigurationProfileAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.configuration_profile_preferences = ConfigurationProfilePreferencesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutomanageClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_configuration_async.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_configuration.py similarity index 84% rename from sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_configuration_async.py rename to sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_configuration.py index 7c433b80ceb5..77958d36f016 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_configuration_async.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_configuration.py @@ -10,6 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -36,17 +37,16 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AutomanageClientConfiguration, 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(AutomanageClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-06-30-preview" - self.credential_scopes = ['https://management.azure.com/.default'] - self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + self.api_version = "2021-04-30-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-automanage/{}'.format(VERSION)) self._configure(**kwargs) @@ -58,9 +58,10 @@ def _configure( self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) 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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_patch.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/__init__.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/__init__.py new file mode 100644 index 000000000000..d889ce914774 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/__init__.py @@ -0,0 +1,25 @@ +# 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 ._best_practices_operations import BestPracticesOperations +from ._best_practices_versions_operations import BestPracticesVersionsOperations +from ._configuration_profiles_operations import ConfigurationProfilesOperations +from ._configuration_profiles_versions_operations import ConfigurationProfilesVersionsOperations +from ._configuration_profile_assignments_operations import ConfigurationProfileAssignmentsOperations +from ._operations import Operations +from ._reports_operations import ReportsOperations + +__all__ = [ + 'BestPracticesOperations', + 'BestPracticesVersionsOperations', + 'ConfigurationProfilesOperations', + 'ConfigurationProfilesVersionsOperations', + 'ConfigurationProfileAssignmentsOperations', + 'Operations', + 'ReportsOperations', +] diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_best_practices_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_best_practices_operations.py new file mode 100644 index 000000000000..38ce1a3e63b5 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_best_practices_operations.py @@ -0,0 +1,156 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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 +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._best_practices_operations import build_get_request, build_list_by_tenant_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class BestPracticesOperations: + """BestPracticesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~automanage_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get( + self, + best_practice_name: str, + **kwargs: Any + ) -> "_models.BestPractice": + """Get information about a Automanage best practice. + + :param best_practice_name: The Automanage best practice name. + :type best_practice_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BestPractice, or the result of cls(response) + :rtype: ~automanage_client.models.BestPractice + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BestPractice"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + best_practice_name=best_practice_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BestPractice', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/providers/Microsoft.Automanage/bestPractices/{bestPracticeName}'} # type: ignore + + + @distributed_trace + def list_by_tenant( + self, + **kwargs: Any + ) -> AsyncIterable["_models.BestPracticeList"]: + """Retrieve a list of Automanage best practices. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BestPracticeList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.BestPracticeList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BestPracticeList"] + 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_list_by_tenant_request( + template_url=self.list_by_tenant.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_tenant_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("BestPracticeList", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_tenant.metadata = {'url': '/providers/Microsoft.Automanage/bestPractices'} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_best_practices_versions_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_best_practices_versions_operations.py new file mode 100644 index 000000000000..1eae9ddc5aea --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_best_practices_versions_operations.py @@ -0,0 +1,165 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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 +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._best_practices_versions_operations import build_get_request, build_list_by_tenant_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class BestPracticesVersionsOperations: + """BestPracticesVersionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~automanage_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get( + self, + best_practice_name: str, + version_name: str, + **kwargs: Any + ) -> "_models.BestPractice": + """Get information about a Automanage best practice version. + + :param best_practice_name: The Automanage best practice name. + :type best_practice_name: str + :param version_name: The Automanage best practice version name. + :type version_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BestPractice, or the result of cls(response) + :rtype: ~automanage_client.models.BestPractice + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BestPractice"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + best_practice_name=best_practice_name, + version_name=version_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BestPractice', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/providers/Microsoft.Automanage/bestPractices/{bestPracticeName}/versions/{versionName}'} # type: ignore + + + @distributed_trace + def list_by_tenant( + self, + best_practice_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.BestPracticeList"]: + """Retrieve a list of Automanage best practices versions. + + :param best_practice_name: The Automanage best practice name. + :type best_practice_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BestPracticeList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.BestPracticeList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BestPracticeList"] + 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_list_by_tenant_request( + best_practice_name=best_practice_name, + template_url=self.list_by_tenant.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_tenant_request( + best_practice_name=best_practice_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("BestPracticeList", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_tenant.metadata = {'url': '/providers/Microsoft.Automanage/bestPractices/{bestPracticeName}/versions'} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_assignments_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_assignments_operations.py new file mode 100644 index 000000000000..971ebf23ddbd --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_assignments_operations.py @@ -0,0 +1,362 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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 +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._configuration_profile_assignments_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_subscription_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ConfigurationProfileAssignmentsOperations: + """ConfigurationProfileAssignmentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~automanage_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def create_or_update( + self, + configuration_profile_assignment_name: str, + resource_group_name: str, + vm_name: str, + parameters: "_models.ConfigurationProfileAssignment", + **kwargs: Any + ) -> "_models.ConfigurationProfileAssignment": + """Creates an association between a VM and Automanage configuration profile. + + :param configuration_profile_assignment_name: Name of the configuration profile assignment. + Only default is supported. + :type configuration_profile_assignment_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. + :type vm_name: str + :param parameters: Parameters supplied to the create or update configuration profile + assignment. + :type parameters: ~automanage_client.models.ConfigurationProfileAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationProfileAssignment, or the result of cls(response) + :rtype: ~automanage_client.models.ConfigurationProfileAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ConfigurationProfileAssignment') + + request = build_create_or_update_request( + configuration_profile_assignment_name=configuration_profile_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) + + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + configuration_profile_assignment_name: str, + vm_name: str, + **kwargs: Any + ) -> "_models.ConfigurationProfileAssignment": + """Get information about a configuration profile assignment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param configuration_profile_assignment_name: The configuration profile assignment name. + :type configuration_profile_assignment_name: str + :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: ConfigurationProfileAssignment, or the result of cls(response) + :rtype: ~automanage_client.models.ConfigurationProfileAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_group_name=resource_group_name, + configuration_profile_assignment_name=configuration_profile_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) + + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore + + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + configuration_profile_assignment_name: str, + vm_name: str, + **kwargs: Any + ) -> None: + """Delete a configuration profile assignment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param configuration_profile_assignment_name: Name of the configuration profile assignment. + :type configuration_profile_assignment_name: str + :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: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + resource_group_name=resource_group_name, + configuration_profile_assignment_name=configuration_profile_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) + + 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) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.ConfigurationProfileAssignmentList"]: + """Get list of configuration profile assignments. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :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 ConfigurationProfileAssignmentList or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.ConfigurationProfileAssignmentList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignmentList"] + 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_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_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("ConfigurationProfileAssignmentList", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfileAssignments'} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable["_models.ConfigurationProfileAssignmentList"]: + """Get list of configuration profile assignments under a given subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConfigurationProfileAssignmentList or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.ConfigurationProfileAssignmentList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignmentList"] + 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_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_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("ConfigurationProfileAssignmentList", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/configurationProfileAssignments'} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profiles_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profiles_operations.py new file mode 100644 index 000000000000..812c52ab9471 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profiles_operations.py @@ -0,0 +1,408 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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 +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._configuration_profiles_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ConfigurationProfilesOperations: + """ConfigurationProfilesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~automanage_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def create_or_update( + self, + configuration_profile_name: str, + resource_group_name: str, + parameters: "_models.ConfigurationProfile", + **kwargs: Any + ) -> "_models.ConfigurationProfile": + """Creates a configuration profile. + + :param configuration_profile_name: Name of the configuration profile. + :type configuration_profile_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to create or update configuration profile. + :type parameters: ~automanage_client.models.ConfigurationProfile + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationProfile, or the result of cls(response) + :rtype: ~automanage_client.models.ConfigurationProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfile"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ConfigurationProfile') + + request = build_create_or_update_request( + configuration_profile_name=configuration_profile_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_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) + + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ConfigurationProfile', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ConfigurationProfile', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}'} # type: ignore + + + @distributed_trace_async + async def get( + self, + configuration_profile_name: str, + resource_group_name: str, + **kwargs: Any + ) -> "_models.ConfigurationProfile": + """Get information about a configuration profile. + + :param configuration_profile_name: The configuration profile name. + :type configuration_profile_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationProfile, or the result of cls(response) + :rtype: ~automanage_client.models.ConfigurationProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfile"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + configuration_profile_name=configuration_profile_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConfigurationProfile', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}'} # type: ignore + + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + configuration_profile_name: str, + **kwargs: Any + ) -> None: + """Delete a configuration profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param configuration_profile_name: Name of the configuration profile. + :type configuration_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + resource_group_name=resource_group_name, + configuration_profile_name=configuration_profile_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}'} # type: ignore + + + @distributed_trace_async + async def update( + self, + configuration_profile_name: str, + resource_group_name: str, + parameters: "_models.ConfigurationProfileUpdate", + **kwargs: Any + ) -> "_models.ConfigurationProfile": + """Updates a configuration profile. + + :param configuration_profile_name: Name of the configuration profile. + :type configuration_profile_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to update configuration profile. + :type parameters: ~automanage_client.models.ConfigurationProfileUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationProfile, or the result of cls(response) + :rtype: ~automanage_client.models.ConfigurationProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfile"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ConfigurationProfileUpdate') + + request = build_update_request( + configuration_profile_name=configuration_profile_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConfigurationProfile', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}'} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.ConfigurationProfileList"]: + """Retrieve a list of configuration profile within a given resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :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 ConfigurationProfileList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.ConfigurationProfileList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileList"] + 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_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_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("ConfigurationProfileList", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles'} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable["_models.ConfigurationProfileList"]: + """Retrieve a list of configuration profile within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConfigurationProfileList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.ConfigurationProfileList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileList"] + 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_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_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("ConfigurationProfileList", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/configurationProfiles'} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profiles_versions_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profiles_versions_operations.py new file mode 100644 index 000000000000..aa3f287c7281 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profiles_versions_operations.py @@ -0,0 +1,363 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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 +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._configuration_profiles_versions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_child_resources_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ConfigurationProfilesVersionsOperations: + """ConfigurationProfilesVersionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~automanage_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def create_or_update( + self, + configuration_profile_name: str, + version_name: str, + resource_group_name: str, + parameters: "_models.ConfigurationProfile", + **kwargs: Any + ) -> "_models.ConfigurationProfile": + """Creates a configuration profile version. + + :param configuration_profile_name: Name of the configuration profile. + :type configuration_profile_name: str + :param version_name: The configuration profile version name. + :type version_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to create or update configuration profile. + :type parameters: ~automanage_client.models.ConfigurationProfile + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationProfile, or the result of cls(response) + :rtype: ~automanage_client.models.ConfigurationProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfile"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ConfigurationProfile') + + request = build_create_or_update_request( + configuration_profile_name=configuration_profile_name, + version_name=version_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_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) + + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ConfigurationProfile', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ConfigurationProfile', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions/{versionName}'} # type: ignore + + + @distributed_trace_async + async def get( + self, + configuration_profile_name: str, + version_name: str, + resource_group_name: str, + **kwargs: Any + ) -> "_models.ConfigurationProfile": + """Get information about a configuration profile version. + + :param configuration_profile_name: The configuration profile name. + :type configuration_profile_name: str + :param version_name: The configuration profile version name. + :type version_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationProfile, or the result of cls(response) + :rtype: ~automanage_client.models.ConfigurationProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfile"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + configuration_profile_name=configuration_profile_name, + version_name=version_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConfigurationProfile', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions/{versionName}'} # type: ignore + + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + configuration_profile_name: str, + version_name: str, + **kwargs: Any + ) -> None: + """Delete a configuration profile version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param configuration_profile_name: Name of the configuration profile. + :type configuration_profile_name: str + :param version_name: The configuration profile version name. + :type version_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + resource_group_name=resource_group_name, + configuration_profile_name=configuration_profile_name, + version_name=version_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions/{versionName}'} # type: ignore + + + @distributed_trace_async + async def update( + self, + configuration_profile_name: str, + version_name: str, + resource_group_name: str, + parameters: "_models.ConfigurationProfileUpdate", + **kwargs: Any + ) -> "_models.ConfigurationProfile": + """Updates a configuration profile version. + + :param configuration_profile_name: Name of the configuration profile. + :type configuration_profile_name: str + :param version_name: The configuration profile version name. + :type version_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to update configuration profile. + :type parameters: ~automanage_client.models.ConfigurationProfileUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationProfile, or the result of cls(response) + :rtype: ~automanage_client.models.ConfigurationProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfile"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ConfigurationProfileUpdate') + + request = build_update_request( + configuration_profile_name=configuration_profile_name, + version_name=version_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConfigurationProfile', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions/{versionName}'} # type: ignore + + + @distributed_trace + def list_child_resources( + self, + configuration_profile_name: str, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.ConfigurationProfileList"]: + """Retrieve a list of configuration profile version for a configuration profile. + + :param configuration_profile_name: Name of the configuration profile. + :type configuration_profile_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :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 ConfigurationProfileList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.ConfigurationProfileList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileList"] + 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_list_child_resources_request( + configuration_profile_name=configuration_profile_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_child_resources.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_child_resources_request( + configuration_profile_name=configuration_profile_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_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("ConfigurationProfileList", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_child_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions'} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_operations_async.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_operations.py similarity index 65% rename from sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_operations_async.py rename to sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_operations.py index a584b47e9553..e87fae2c2daa 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_operations_async.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/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 HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 - +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]] @@ -33,7 +38,7 @@ class Operations: :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer) -> None: self._client = client @@ -41,43 +46,44 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs - ) -> AsyncIterable["models.OperationList"]: + **kwargs: Any + ) -> AsyncIterable["_models.OperationListResult"]: """Lists all of the available Automanage REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.OperationList] + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.OperationList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - 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("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -90,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(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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_reports_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_reports_operations.py new file mode 100644 index 000000000000..c8f0fda9fb88 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_reports_operations.py @@ -0,0 +1,186 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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 +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._reports_operations import build_get_request, build_list_by_configuration_profile_assignments_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ReportsOperations: + """ReportsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~automanage_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + configuration_profile_assignment_name: str, + report_name: str, + vm_name: str, + **kwargs: Any + ) -> "_models.Report": + """Get information about a report associated with a configuration profile assignment run. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param configuration_profile_assignment_name: The configuration profile assignment name. + :type configuration_profile_assignment_name: str + :param report_name: The report name. + :type report_name: str + :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: Report, or the result of cls(response) + :rtype: ~automanage_client.models.Report + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Report"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_group_name=resource_group_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + report_name=report_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) + + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Report', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports/{reportName}'} # type: ignore + + + @distributed_trace + def list_by_configuration_profile_assignments( + self, + resource_group_name: str, + configuration_profile_assignment_name: str, + vm_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.ReportList"]: + """Retrieve a list of reports within a given configuration profile assignment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param configuration_profile_assignment_name: The configuration profile assignment name. + :type configuration_profile_assignment_name: str + :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 ReportList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.ReportList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportList"] + 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_list_by_configuration_profile_assignments_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + vm_name=vm_name, + template_url=self.list_by_configuration_profile_assignments.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_configuration_profile_assignments_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + 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("ReportList", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_configuration_profile_assignments.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports'} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/__init__.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/__init__.py deleted file mode 100644 index 6f24ade3b739..000000000000 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/__init__.py +++ /dev/null @@ -1,19 +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 ._accounts_operations_async import AccountsOperations -from ._configuration_profile_assignments_operations_async import ConfigurationProfileAssignmentsOperations -from ._configuration_profile_preferences_operations_async import ConfigurationProfilePreferencesOperations -from ._operations_async import Operations - -__all__ = [ - 'AccountsOperations', - 'ConfigurationProfileAssignmentsOperations', - 'ConfigurationProfilePreferencesOperations', - 'Operations', -] diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_accounts_operations_async.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_accounts_operations_async.py deleted file mode 100644 index f589ce7b5e54..000000000000 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_accounts_operations_async.py +++ /dev/null @@ -1,416 +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 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 HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class AccountsOperations: - """AccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~automanage_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def create_or_update( - self, - account_name: str, - resource_group_name: str, - parameters: "models.Account", - **kwargs - ) -> "models.Account": - """Creates an Automanage Account. - - :param account_name: Name of the Automanage account. - :type account_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param parameters: Parameters supplied to create or update Automanage account. - :type parameters: ~automanage_client.models.Account - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Account, or the result of cls(response) - :rtype: ~automanage_client.models.Account - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Account"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Account') - 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(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('Account', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('Account', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}'} # type: ignore - - async def get( - self, - account_name: str, - resource_group_name: str, - **kwargs - ) -> "models.Account": - """Get information about a Automanage account. - - :param account_name: The Automanage account name. - :type account_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Account, or the result of cls(response) - :rtype: ~automanage_client.models.Account - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Account"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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'] = 'application/json' - - 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(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Account', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}'} # type: ignore - - async def delete( - self, - resource_group_name: str, - account_name: str, - **kwargs - ) -> None: - """Delete a Automanage account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param account_name: Name of the Automanage account. - :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - 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] - - 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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}'} # type: ignore - - async def update( - self, - account_name: str, - resource_group_name: str, - parameters: "models.AccountUpdate", - **kwargs - ) -> "models.Account": - """Updates an Automanage Account. - - :param account_name: Name of the Automanage account. - :type account_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param parameters: Parameters supplied to update Automanage account. - :type parameters: ~automanage_client.models.AccountUpdate - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Account, or the result of cls(response) - :rtype: ~automanage_client.models.Account - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Account"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AccountUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Account', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}'} # type: ignore - - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["models.AccountList"]: - """Retrieve a list of Automanage accounts within a given resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :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 AccountList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.AccountList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.AccountList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('AccountList', 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]: - error = self._deserialize(models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts'} # type: ignore - - def list_by_subscription( - self, - **kwargs - ) -> AsyncIterable["models.AccountList"]: - """Retrieve a list of Automanage accounts within a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccountList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.AccountList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.AccountList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - 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) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('AccountList', 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]: - error = self._deserialize(models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/accounts'} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_configuration_profile_assignments_operations_async.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_configuration_profile_assignments_operations_async.py deleted file mode 100644 index 407543075917..000000000000 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_configuration_profile_assignments_operations_async.py +++ /dev/null @@ -1,421 +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 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 HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class ConfigurationProfileAssignmentsOperations: - """ConfigurationProfileAssignmentsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~automanage_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def _create_or_update_initial( - self, - configuration_profile_assignment_name: str, - resource_group_name: str, - vm_name: str, - parameters: "models.ConfigurationProfileAssignment", - **kwargs - ) -> "models.ConfigurationProfileAssignment": - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignment"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'configurationProfileAssignmentName': self._serialize.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'vmName': self._serialize.url("vm_name", vm_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConfigurationProfileAssignment') - 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(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore - - async def begin_create_or_update( - self, - configuration_profile_assignment_name: str, - resource_group_name: str, - vm_name: str, - parameters: "models.ConfigurationProfileAssignment", - **kwargs - ) -> AsyncLROPoller["models.ConfigurationProfileAssignment"]: - """Creates an association between a VM and Automanage configuration profile. - - :param configuration_profile_assignment_name: Name of the configuration profile assignment. - Only default is supported. - :type configuration_profile_assignment_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. - :type vm_name: str - :param parameters: Parameters supplied to the create or update configuration profile - assignment. - :type parameters: ~automanage_client.models.ConfigurationProfileAssignment - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ConfigurationProfileAssignment or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~automanage_client.models.ConfigurationProfileAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignment"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._create_or_update_initial( - configuration_profile_assignment_name=configuration_profile_assignment_name, - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore - - async def get( - self, - resource_group_name: str, - configuration_profile_assignment_name: str, - vm_name: str, - **kwargs - ) -> "models.ConfigurationProfileAssignment": - """Get information about a configuration profile assignment. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param configuration_profile_assignment_name: The configuration profile assignment name. - :type configuration_profile_assignment_name: str - :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: ConfigurationProfileAssignment, or the result of cls(response) - :rtype: ~automanage_client.models.ConfigurationProfileAssignment - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignment"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'configurationProfileAssignmentName': self._serialize.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - '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'] = 'application/json' - - 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(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore - - async def delete( - self, - resource_group_name: str, - configuration_profile_assignment_name: str, - vm_name: str, - **kwargs - ) -> None: - """Delete a configuration profile assignment. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param configuration_profile_assignment_name: Name of the configuration profile assignment. - :type configuration_profile_assignment_name: str - :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: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'configurationProfileAssignmentName': self._serialize.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - '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] - - 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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore - - def list( - self, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["models.ConfigurationProfileAssignmentList"]: - """Get list of configuration profile assignments. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :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 ConfigurationProfileAssignmentList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.ConfigurationProfileAssignmentList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignmentList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - 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', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - 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) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ConfigurationProfileAssignmentList', 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]: - error = self._deserialize(models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfileAssignments'} # type: ignore - - def list_by_subscription( - self, - **kwargs - ) -> AsyncIterable["models.ConfigurationProfileAssignmentList"]: - """Get list of configuration profile assignments under a given subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfigurationProfileAssignmentList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.ConfigurationProfileAssignmentList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignmentList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - 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) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ConfigurationProfileAssignmentList', 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]: - error = self._deserialize(models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/configurationProfileAssignments'} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_configuration_profile_preferences_operations_async.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_configuration_profile_preferences_operations_async.py deleted file mode 100644 index f4e7c2bf76db..000000000000 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_configuration_profile_preferences_operations_async.py +++ /dev/null @@ -1,416 +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 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 HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class ConfigurationProfilePreferencesOperations: - """ConfigurationProfilePreferencesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~automanage_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def create_or_update( - self, - configuration_profile_preference_name: str, - resource_group_name: str, - parameters: "models.ConfigurationProfilePreference", - **kwargs - ) -> "models.ConfigurationProfilePreference": - """Creates a configuration profile preference. - - :param configuration_profile_preference_name: Name of the configuration profile preference. - :type configuration_profile_preference_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param parameters: Parameters supplied to create or update configuration profile preference. - :type parameters: ~automanage_client.models.ConfigurationProfilePreference - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigurationProfilePreference, or the result of cls(response) - :rtype: ~automanage_client.models.ConfigurationProfilePreference - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreference"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'configurationProfilePreferenceName': self._serialize.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConfigurationProfilePreference') - 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(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('ConfigurationProfilePreference', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('ConfigurationProfilePreference', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}'} # type: ignore - - async def get( - self, - configuration_profile_preference_name: str, - resource_group_name: str, - **kwargs - ) -> "models.ConfigurationProfilePreference": - """Get information about a configuration profile preference. - - :param configuration_profile_preference_name: The configuration profile preference name. - :type configuration_profile_preference_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigurationProfilePreference, or the result of cls(response) - :rtype: ~automanage_client.models.ConfigurationProfilePreference - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreference"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'configurationProfilePreferenceName': self._serialize.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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'] = 'application/json' - - 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(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('ConfigurationProfilePreference', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}'} # type: ignore - - async def delete( - self, - resource_group_name: str, - configuration_profile_preference_name: str, - **kwargs - ) -> None: - """Delete a configuration profile preference. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param configuration_profile_preference_name: Name of the configuration profile preference. - :type configuration_profile_preference_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'configurationProfilePreferenceName': self._serialize.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - 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] - - 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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}'} # type: ignore - - async def update( - self, - configuration_profile_preference_name: str, - resource_group_name: str, - parameters: "models.ConfigurationProfilePreferenceUpdate", - **kwargs - ) -> "models.ConfigurationProfilePreference": - """Updates a configuration profile preference. - - :param configuration_profile_preference_name: Name of the configuration profile preference. - :type configuration_profile_preference_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param parameters: Parameters supplied to create or update configuration profile preference. - :type parameters: ~automanage_client.models.ConfigurationProfilePreferenceUpdate - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigurationProfilePreference, or the result of cls(response) - :rtype: ~automanage_client.models.ConfigurationProfilePreference - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreference"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'configurationProfilePreferenceName': self._serialize.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConfigurationProfilePreferenceUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('ConfigurationProfilePreference', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}'} # type: ignore - - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["models.ConfigurationProfilePreferenceList"]: - """Retrieve a list of configuration profile preferences within a given resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :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 ConfigurationProfilePreferenceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.ConfigurationProfilePreferenceList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreferenceList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ConfigurationProfilePreferenceList', 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]: - error = self._deserialize(models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences'} # type: ignore - - def list_by_subscription( - self, - **kwargs - ) -> AsyncIterable["models.ConfigurationProfilePreferenceList"]: - """Retrieve a list of configuration profile preferences within a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfigurationProfilePreferenceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.ConfigurationProfilePreferenceList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreferenceList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - 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) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ConfigurationProfilePreferenceList', 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]: - error = self._deserialize(models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/configurationProfilePreferences'} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/__init__.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/__init__.py index 1bce4240a948..966e3ae20ca5 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/__init__.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/__init__.py @@ -7,96 +7,85 @@ # -------------------------------------------------------------------------- try: - from ._models_py3 import Account - from ._models_py3 import AccountIdentity - from ._models_py3 import AccountList - from ._models_py3 import AccountUpdate + from ._models_py3 import BestPractice + from ._models_py3 import BestPracticeList + from ._models_py3 import ConfigurationProfile from ._models_py3 import ConfigurationProfileAssignment - from ._models_py3 import ConfigurationProfileAssignmentCompliance from ._models_py3 import ConfigurationProfileAssignmentList from ._models_py3 import ConfigurationProfileAssignmentProperties - from ._models_py3 import ConfigurationProfilePreference - from ._models_py3 import ConfigurationProfilePreferenceAntiMalware - from ._models_py3 import ConfigurationProfilePreferenceList - from ._models_py3 import ConfigurationProfilePreferenceProperties - from ._models_py3 import ConfigurationProfilePreferenceUpdate - from ._models_py3 import ConfigurationProfilePreferenceVmBackup + from ._models_py3 import ConfigurationProfileList + from ._models_py3 import ConfigurationProfileProperties + from ._models_py3 import ConfigurationProfileUpdate from ._models_py3 import ErrorAdditionalInfo + from ._models_py3 import ErrorDetail from ._models_py3 import ErrorResponse - from ._models_py3 import ErrorResponseError from ._models_py3 import Operation from ._models_py3 import OperationDisplay - from ._models_py3 import OperationList + from ._models_py3 import OperationListResult from ._models_py3 import ProxyResource + from ._models_py3 import Report + from ._models_py3 import ReportList + from ._models_py3 import ReportResource from ._models_py3 import Resource + from ._models_py3 import SystemData from ._models_py3 import TrackedResource from ._models_py3 import UpdateResource except (SyntaxError, ImportError): - from ._models import Account # type: ignore - from ._models import AccountIdentity # type: ignore - from ._models import AccountList # type: ignore - from ._models import AccountUpdate # type: ignore + from ._models import BestPractice # type: ignore + from ._models import BestPracticeList # type: ignore + from ._models import ConfigurationProfile # type: ignore from ._models import ConfigurationProfileAssignment # type: ignore - from ._models import ConfigurationProfileAssignmentCompliance # type: ignore from ._models import ConfigurationProfileAssignmentList # type: ignore from ._models import ConfigurationProfileAssignmentProperties # type: ignore - from ._models import ConfigurationProfilePreference # type: ignore - from ._models import ConfigurationProfilePreferenceAntiMalware # type: ignore - from ._models import ConfigurationProfilePreferenceList # type: ignore - from ._models import ConfigurationProfilePreferenceProperties # type: ignore - from ._models import ConfigurationProfilePreferenceUpdate # type: ignore - from ._models import ConfigurationProfilePreferenceVmBackup # type: ignore + from ._models import ConfigurationProfileList # type: ignore + from ._models import ConfigurationProfileProperties # type: ignore + from ._models import ConfigurationProfileUpdate # type: ignore from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorDetail # type: ignore from ._models import ErrorResponse # type: ignore - from ._models import ErrorResponseError # type: ignore from ._models import Operation # type: ignore from ._models import OperationDisplay # type: ignore - from ._models import OperationList # type: ignore + from ._models import OperationListResult # type: ignore from ._models import ProxyResource # type: ignore + from ._models import Report # type: ignore + from ._models import ReportList # type: ignore + from ._models import ReportResource # type: ignore from ._models import Resource # type: ignore + from ._models import SystemData # type: ignore from ._models import TrackedResource # type: ignore from ._models import UpdateResource # type: ignore from ._automanage_client_enums import ( - ConfigurationProfile, - EnableRealTimeProtection, - ProvisioningStatus, - ResourceIdentityType, - RunScheduledScan, - ScanType, - UpdateStatus, + ActionType, + CreatedByType, + Origin, ) __all__ = [ - 'Account', - 'AccountIdentity', - 'AccountList', - 'AccountUpdate', + 'BestPractice', + 'BestPracticeList', + 'ConfigurationProfile', 'ConfigurationProfileAssignment', - 'ConfigurationProfileAssignmentCompliance', 'ConfigurationProfileAssignmentList', 'ConfigurationProfileAssignmentProperties', - 'ConfigurationProfilePreference', - 'ConfigurationProfilePreferenceAntiMalware', - 'ConfigurationProfilePreferenceList', - 'ConfigurationProfilePreferenceProperties', - 'ConfigurationProfilePreferenceUpdate', - 'ConfigurationProfilePreferenceVmBackup', + 'ConfigurationProfileList', + 'ConfigurationProfileProperties', + 'ConfigurationProfileUpdate', 'ErrorAdditionalInfo', + 'ErrorDetail', 'ErrorResponse', - 'ErrorResponseError', 'Operation', 'OperationDisplay', - 'OperationList', + 'OperationListResult', 'ProxyResource', + 'Report', + 'ReportList', + 'ReportResource', 'Resource', + 'SystemData', 'TrackedResource', 'UpdateResource', - 'ConfigurationProfile', - 'EnableRealTimeProtection', - 'ProvisioningStatus', - 'ResourceIdentityType', - 'RunScheduledScan', - 'ScanType', - 'UpdateStatus', + 'ActionType', + 'CreatedByType', + 'Origin', ] diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_automanage_client_enums.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_automanage_client_enums.py index 79304db864cd..36b4245e5f98 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_automanage_client_enums.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_automanage_client_enums.py @@ -7,55 +7,30 @@ # -------------------------------------------------------------------------- from enum import Enum +from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class ConfigurationProfile(str, Enum): - """A value indicating configuration profile. - """ - - azure_virtual_machine_best_practices_dev_test = "Azure virtual machine best practices – Dev/Test" - azure_virtual_machine_best_practices_production = "Azure virtual machine best practices – Production" - -class EnableRealTimeProtection(str, Enum): - """Enables or disables Real Time Protection - """ - - true = "True" - false = "False" - -class ProvisioningStatus(str, Enum): - """The state of onboarding, which only appears in the response. - """ - - succeeded = "Succeeded" - failed = "Failed" - created = "Created" - -class ResourceIdentityType(str, Enum): - """The type of identity used for the Automanage account. Currently, the only supported type is - 'SystemAssigned', which implicitly creates an identity. - """ - - system_assigned = "SystemAssigned" - none = "None" -class RunScheduledScan(str, Enum): - """Enables or disables a periodic scan for antimalware +class ActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. """ - true = "True" - false = "False" + INTERNAL = "Internal" -class ScanType(str, Enum): - """Type of scheduled scan +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. """ - quick = "Quick" - full = "Full" + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" -class UpdateStatus(str, Enum): - """The state of compliance, which only appears in the response. +class Origin(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system" """ - succeeded = "Succeeded" - failed = "Failed" - created = "Created" + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models.py index 4a02132654d4..19ca41d2349a 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models.py @@ -10,18 +10,97 @@ import msrest.serialization +class BestPractice(msrest.serialization.Model): + """Definition of the Automanage best practice. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The fully qualified ID for the best practice. For example, + /providers/Microsoft.Automanage/bestPractices/azureBestPracticesProduction. + :vartype id: str + :ivar type: The type of the resource. For example, Microsoft.Automanage/bestPractices. + :vartype type: str + :ivar name: The name of the best practice. For example, azureBestPracticesProduction. + :vartype name: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~automanage_client.models.SystemData + :ivar configuration: configuration dictionary of the configuration profile. + :vartype configuration: any + :ivar overrides: overrides of the configuration profile. + :vartype overrides: list[any] + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'configuration': {'key': 'properties.configuration', 'type': 'object'}, + 'overrides': {'key': 'properties.overrides', 'type': '[object]'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword configuration: configuration dictionary of the configuration profile. + :paramtype configuration: any + :keyword overrides: overrides of the configuration profile. + :paramtype overrides: list[any] + """ + super(BestPractice, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.system_data = None + self.configuration = kwargs.get('configuration', None) + self.overrides = kwargs.get('overrides', None) + + +class BestPracticeList(msrest.serialization.Model): + """The response of the list best practice operation. + + :ivar value: Result of the list best practice operation. + :vartype value: list[~automanage_client.models.BestPractice] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[BestPractice]'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword value: Result of the list best practice operation. + :paramtype value: list[~automanage_client.models.BestPractice] + """ + super(BestPracticeList, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + + class Resource(msrest.serialization.Model): - """Resource. + """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str """ @@ -41,6 +120,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -48,24 +129,24 @@ def __init__( class TrackedResource(Resource): - """The resource model definition for a ARM tracked top level resource. + """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str """ _validation = { @@ -87,32 +168,41 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + """ super(TrackedResource, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.location = kwargs['location'] -class Account(TrackedResource): - """Definition of the Automanage account. +class ConfigurationProfile(TrackedResource): + """Definition of the configuration profile. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param identity: The identity of the Automanage account. - :type identity: ~automanage_client.models.AccountIdentity + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar properties: Properties of the configuration profile. + :vartype properties: ~automanage_client.models.ConfigurationProfileProperties + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~automanage_client.models.SystemData """ _validation = { @@ -120,6 +210,7 @@ class Account(TrackedResource): 'name': {'readonly': True}, 'type': {'readonly': True}, 'location': {'required': True}, + 'system_data': {'readonly': True}, } _attribute_map = { @@ -128,40 +219,51 @@ class Account(TrackedResource): 'type': {'key': 'type', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'AccountIdentity'}, + 'properties': {'key': 'properties', 'type': 'ConfigurationProfileProperties'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__( self, **kwargs ): - super(Account, self).__init__(**kwargs) - self.identity = kwargs.get('identity', None) + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword properties: Properties of the configuration profile. + :paramtype properties: ~automanage_client.models.ConfigurationProfileProperties + """ + super(ConfigurationProfile, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) + self.system_data = None -class AccountIdentity(msrest.serialization.Model): - """Identity for the Automanage account. +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. Variables are only populated by the server, and will be ignored when sending a request. - :ivar principal_id: The principal id of Automanage account identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id associated with the Automanage account. - :vartype tenant_id: str - :param type: The type of identity used for the Automanage account. Currently, the only - supported type is 'SystemAssigned', which implicitly creates an identity. Possible values - include: "SystemAssigned", "None". - :type type: str or ~automanage_client.models.ResourceIdentityType + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, } @@ -169,93 +271,36 @@ def __init__( self, **kwargs ): - super(AccountIdentity, self).__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = kwargs.get('type', None) - - -class AccountList(msrest.serialization.Model): - """The response of the list Account operation. - - :param value: Result of the list Account operation. - :type value: list[~automanage_client.models.Account] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Account]'}, - } - - def __init__( - self, - **kwargs - ): - super(AccountList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class UpdateResource(msrest.serialization.Model): - """Represents an update resource. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class AccountUpdate(UpdateResource): - """Definition of the Automanage account. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param identity: The identity of the Automanage account. - :type identity: ~automanage_client.models.AccountIdentity - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'AccountIdentity'}, - } - - def __init__( - self, - **kwargs - ): - super(AccountUpdate, self).__init__(**kwargs) - self.identity = kwargs.get('identity', None) + """ + """ + super(ProxyResource, self).__init__(**kwargs) -class ConfigurationProfileAssignment(Resource): +class ConfigurationProfileAssignment(ProxyResource): """Configuration profile assignment is an association between a VM and automanage profile configuration. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param properties: Properties of the configuration profile assignment. - :type properties: ~automanage_client.models.ConfigurationProfileAssignmentProperties + :ivar properties: Properties of the configuration profile assignment. + :vartype properties: ~automanage_client.models.ConfigurationProfileAssignmentProperties + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~automanage_client.models.SystemData """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'system_data': {'readonly': True}, } _attribute_map = { @@ -263,47 +308,27 @@ class ConfigurationProfileAssignment(Resource): 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'properties': {'key': 'properties', 'type': 'ConfigurationProfileAssignmentProperties'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__( self, **kwargs ): + """ + :keyword properties: Properties of the configuration profile assignment. + :paramtype properties: ~automanage_client.models.ConfigurationProfileAssignmentProperties + """ super(ConfigurationProfileAssignment, self).__init__(**kwargs) self.properties = kwargs.get('properties', None) - - -class ConfigurationProfileAssignmentCompliance(msrest.serialization.Model): - """The compliance status for the configuration profile assignment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar update_status: The state of compliance, which only appears in the response. Possible - values include: "Succeeded", "Failed", "Created". - :vartype update_status: str or ~automanage_client.models.UpdateStatus - """ - - _validation = { - 'update_status': {'readonly': True}, - } - - _attribute_map = { - 'update_status': {'key': 'updateStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfigurationProfileAssignmentCompliance, self).__init__(**kwargs) - self.update_status = None + self.system_data = None class ConfigurationProfileAssignmentList(msrest.serialization.Model): """The response of the list configuration profile assignment operation. - :param value: Result of the list configuration profile assignment operation. - :type value: list[~automanage_client.models.ConfigurationProfileAssignment] + :ivar value: Result of the list configuration profile assignment operation. + :vartype value: list[~automanage_client.models.ConfigurationProfileAssignment] """ _attribute_map = { @@ -314,6 +339,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: Result of the list configuration profile assignment operation. + :paramtype value: list[~automanage_client.models.ConfigurationProfileAssignment] + """ super(ConfigurationProfileAssignmentList, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -323,231 +352,148 @@ class ConfigurationProfileAssignmentProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param configuration_profile: A value indicating configuration profile. Possible values - include: "Azure virtual machine best practices – Dev/Test", "Azure virtual machine best - practices – Production". - :type configuration_profile: str or ~automanage_client.models.ConfigurationProfile - :param target_id: The target VM resource URI. - :type target_id: str - :param account_id: The Automanage account ARM Resource URI. - :type account_id: str - :param configuration_profile_preference_id: The configuration profile custom preferences ARM - resource URI. - :type configuration_profile_preference_id: str - :ivar provisioning_status: The state of onboarding, which only appears in the response. - Possible values include: "Succeeded", "Failed", "Created". - :vartype provisioning_status: str or ~automanage_client.models.ProvisioningStatus - :param compliance: The configuration setting for the configuration profile. - :type compliance: ~automanage_client.models.ConfigurationProfileAssignmentCompliance + :ivar configuration_profile: The Automanage configurationProfile ARM Resource URI. + :vartype configuration_profile: str + :ivar target_id: The target VM resource URI. + :vartype target_id: str + :ivar status: The status of onboarding, which only appears in the response. + :vartype status: str + :ivar profile_overrides: The profileOverrides setting for the configuration profile assignment. + :vartype profile_overrides: dict[str, any] """ _validation = { - 'provisioning_status': {'readonly': True}, + 'status': {'readonly': True}, } _attribute_map = { 'configuration_profile': {'key': 'configurationProfile', 'type': 'str'}, 'target_id': {'key': 'targetId', 'type': 'str'}, - 'account_id': {'key': 'accountId', 'type': 'str'}, - 'configuration_profile_preference_id': {'key': 'configurationProfilePreferenceId', 'type': 'str'}, - 'provisioning_status': {'key': 'provisioningStatus', 'type': 'str'}, - 'compliance': {'key': 'compliance', 'type': 'ConfigurationProfileAssignmentCompliance'}, + 'status': {'key': 'status', 'type': 'str'}, + 'profile_overrides': {'key': 'profileOverrides', 'type': '{object}'}, } def __init__( self, **kwargs ): + """ + :keyword configuration_profile: The Automanage configurationProfile ARM Resource URI. + :paramtype configuration_profile: str + :keyword target_id: The target VM resource URI. + :paramtype target_id: str + :keyword profile_overrides: The profileOverrides setting for the configuration profile + assignment. + :paramtype profile_overrides: dict[str, any] + """ super(ConfigurationProfileAssignmentProperties, self).__init__(**kwargs) self.configuration_profile = kwargs.get('configuration_profile', None) self.target_id = kwargs.get('target_id', None) - self.account_id = kwargs.get('account_id', None) - self.configuration_profile_preference_id = kwargs.get('configuration_profile_preference_id', None) - self.provisioning_status = None - self.compliance = kwargs.get('compliance', None) - - -class ConfigurationProfilePreference(TrackedResource): - """Definition of the configuration profile preference. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource Id for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param properties: Properties of the configuration profile preference. - :type properties: ~automanage_client.models.ConfigurationProfilePreferenceProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ConfigurationProfilePreferenceProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfigurationProfilePreference, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class ConfigurationProfilePreferenceAntiMalware(msrest.serialization.Model): - """Automanage configuration profile Antimalware preferences. - - :param enable_real_time_protection: Enables or disables Real Time Protection. Possible values - include: "True", "False". - :type enable_real_time_protection: str or ~automanage_client.models.EnableRealTimeProtection - :param exclusions: Extensions, Paths and Processes that must be excluded from scan. - :type exclusions: object - :param run_scheduled_scan: Enables or disables a periodic scan for antimalware. Possible values - include: "True", "False". - :type run_scheduled_scan: str or ~automanage_client.models.RunScheduledScan - :param scan_type: Type of scheduled scan. Possible values include: "Quick", "Full". - :type scan_type: str or ~automanage_client.models.ScanType - :param scan_day: Schedule scan settings day. - :type scan_day: str - :param scan_time_in_minutes: Schedule scan settings time. - :type scan_time_in_minutes: str - """ - - _attribute_map = { - 'enable_real_time_protection': {'key': 'enableRealTimeProtection', 'type': 'str'}, - 'exclusions': {'key': 'exclusions', 'type': 'object'}, - 'run_scheduled_scan': {'key': 'runScheduledScan', 'type': 'str'}, - 'scan_type': {'key': 'scanType', 'type': 'str'}, - 'scan_day': {'key': 'scanDay', 'type': 'str'}, - 'scan_time_in_minutes': {'key': 'scanTimeInMinutes', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfigurationProfilePreferenceAntiMalware, self).__init__(**kwargs) - self.enable_real_time_protection = kwargs.get('enable_real_time_protection', None) - self.exclusions = kwargs.get('exclusions', None) - self.run_scheduled_scan = kwargs.get('run_scheduled_scan', None) - self.scan_type = kwargs.get('scan_type', None) - self.scan_day = kwargs.get('scan_day', None) - self.scan_time_in_minutes = kwargs.get('scan_time_in_minutes', None) + self.status = None + self.profile_overrides = kwargs.get('profile_overrides', None) -class ConfigurationProfilePreferenceList(msrest.serialization.Model): - """The response of the list ConfigurationProfilePreference operation. +class ConfigurationProfileList(msrest.serialization.Model): + """The response of the list configuration profile operation. - :param value: Result of the list ConfigurationProfilePreference operation. - :type value: list[~automanage_client.models.ConfigurationProfilePreference] + :ivar value: Result of the list ConfigurationProfile operation. + :vartype value: list[~automanage_client.models.ConfigurationProfile] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ConfigurationProfilePreference]'}, + 'value': {'key': 'value', 'type': '[ConfigurationProfile]'}, } def __init__( self, **kwargs ): - super(ConfigurationProfilePreferenceList, self).__init__(**kwargs) + """ + :keyword value: Result of the list ConfigurationProfile operation. + :paramtype value: list[~automanage_client.models.ConfigurationProfile] + """ + super(ConfigurationProfileList, self).__init__(**kwargs) self.value = kwargs.get('value', None) -class ConfigurationProfilePreferenceProperties(msrest.serialization.Model): - """Automanage configuration profile preference properties. +class ConfigurationProfileProperties(msrest.serialization.Model): + """Automanage configuration profile properties. - :param vm_backup: The custom preferences for Azure VM Backup. - :type vm_backup: ~automanage_client.models.ConfigurationProfilePreferenceVmBackup - :param anti_malware: The custom preferences for Azure Antimalware. - :type anti_malware: ~automanage_client.models.ConfigurationProfilePreferenceAntiMalware + :ivar configuration: configuration dictionary of the configuration profile. + :vartype configuration: any + :ivar overrides: overrides of the configuration profile. + :vartype overrides: list[any] """ _attribute_map = { - 'vm_backup': {'key': 'vmBackup', 'type': 'ConfigurationProfilePreferenceVmBackup'}, - 'anti_malware': {'key': 'antiMalware', 'type': 'ConfigurationProfilePreferenceAntiMalware'}, + 'configuration': {'key': 'configuration', 'type': 'object'}, + 'overrides': {'key': 'overrides', 'type': '[object]'}, } def __init__( self, **kwargs ): - super(ConfigurationProfilePreferenceProperties, self).__init__(**kwargs) - self.vm_backup = kwargs.get('vm_backup', None) - self.anti_malware = kwargs.get('anti_malware', None) + """ + :keyword configuration: configuration dictionary of the configuration profile. + :paramtype configuration: any + :keyword overrides: overrides of the configuration profile. + :paramtype overrides: list[any] + """ + super(ConfigurationProfileProperties, self).__init__(**kwargs) + self.configuration = kwargs.get('configuration', None) + self.overrides = kwargs.get('overrides', None) -class ConfigurationProfilePreferenceUpdate(UpdateResource): - """Definition of the configuration profile preference. +class UpdateResource(msrest.serialization.Model): + """Represents an update resource. - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param properties: Properties of the configuration profile preference. - :type properties: ~automanage_client.models.ConfigurationProfilePreferenceProperties + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] """ _attribute_map = { 'tags': {'key': 'tags', 'type': '{str}'}, - 'properties': {'key': 'properties', 'type': 'ConfigurationProfilePreferenceProperties'}, } def __init__( self, **kwargs ): - super(ConfigurationProfilePreferenceUpdate, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ + super(UpdateResource, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) -class ConfigurationProfilePreferenceVmBackup(msrest.serialization.Model): - """Automanage configuration profile VM Backup preferences. +class ConfigurationProfileUpdate(UpdateResource): + """Definition of the configuration profile. - :param time_zone: TimeZone optional input as string. For example: Pacific Standard Time. - :type time_zone: str - :param instant_rp_retention_range_in_days: Instant RP retention policy range in days. - :type instant_rp_retention_range_in_days: int - :param retention_policy: Retention policy with the details on backup copy retention ranges. - :type retention_policy: str - :param schedule_policy: Backup schedule specified as part of backup policy. - :type schedule_policy: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar properties: Properties of the configuration profile. + :vartype properties: ~automanage_client.models.ConfigurationProfileProperties """ _attribute_map = { - 'time_zone': {'key': 'timeZone', 'type': 'str'}, - 'instant_rp_retention_range_in_days': {'key': 'instantRpRetentionRangeInDays', 'type': 'int'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'str'}, - 'schedule_policy': {'key': 'schedulePolicy', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'properties': {'key': 'properties', 'type': 'ConfigurationProfileProperties'}, } def __init__( self, **kwargs ): - super(ConfigurationProfilePreferenceVmBackup, self).__init__(**kwargs) - self.time_zone = kwargs.get('time_zone', None) - self.instant_rp_retention_range_in_days = kwargs.get('instant_rp_retention_range_in_days', None) - self.retention_policy = kwargs.get('retention_policy', None) - self.schedule_policy = kwargs.get('schedule_policy', None) + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword properties: Properties of the configuration profile. + :paramtype properties: ~automanage_client.models.ConfigurationProfileProperties + """ + super(ConfigurationProfileUpdate, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) class ErrorAdditionalInfo(msrest.serialization.Model): @@ -558,7 +504,7 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: object + :vartype info: any """ _validation = { @@ -575,32 +521,15 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): - """The resource management error response. - - :param error: The error object. - :type error: ~automanage_client.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): - """The error object. +class ErrorDetail(msrest.serialization.Model): + """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -611,7 +540,7 @@ class ErrorResponseError(msrest.serialization.Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: list[~automanage_client.models.ErrorResponse] + :vartype details: list[~automanage_client.models.ErrorDetail] :ivar additional_info: The error additional info. :vartype additional_info: list[~automanage_client.models.ErrorAdditionalInfo] """ @@ -628,7 +557,7 @@ class ErrorResponseError(msrest.serialization.Model): 'code': {'key': 'code', 'type': 'str'}, 'message': {'key': 'message', 'type': 'str'}, 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, + 'details': {'key': 'details', 'type': '[ErrorDetail]'}, 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } @@ -636,7 +565,9 @@ def __init__( self, **kwargs ): - super(ErrorResponseError, self).__init__(**kwargs) + """ + """ + super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None self.target = None @@ -644,51 +575,108 @@ def __init__( self.additional_info = None +class ErrorResponse(msrest.serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~automanage_client.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword error: The error object. + :paramtype error: ~automanage_client.models.ErrorDetail + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + class Operation(msrest.serialization.Model): - """Automanage REST API operation. - - :param name: Operation name: For ex. - providers/Microsoft.Automanage/configurationProfileAssignments/write or read. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: str - :param display: Provider, Resource, Operation and description values. - :type display: ~automanage_client.models.OperationDisplay - :param status_code: Service provider: Microsoft.Automanage. - :type status_code: str + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~automanage_client.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Possible values include: "user", + "system", "user,system". + :vartype origin: str or ~automanage_client.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Possible values include: "Internal". + :vartype action_type: str or ~automanage_client.models.ActionType """ + _validation = { + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, + } + _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'status_code': {'key': 'properties.statusCode', 'type': 'str'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, } def __init__( self, **kwargs ): + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~automanage_client.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.is_data_action = kwargs.get('is_data_action', None) + self.name = None + self.is_data_action = None self.display = kwargs.get('display', None) - self.status_code = kwargs.get('status_code', None) + self.origin = None + self.action_type = None class OperationDisplay(msrest.serialization.Model): - """Provider, Resource, Operation and description values. - - :param provider: Service provider: Microsoft.Automanage. - :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 + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str """ + _validation = { + 'provider': {'readonly': True}, + 'resource': {'readonly': True}, + 'operation': {'readonly': True}, + 'description': {'readonly': True}, + } + _attribute_map = { 'provider': {'key': 'provider', 'type': 'str'}, 'resource': {'key': 'resource', 'type': 'str'}, @@ -700,61 +688,266 @@ 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) + self.provider = None + self.resource = None + self.operation = None + self.description = None -class OperationList(msrest.serialization.Model): - """The response model for the list of Automanage operations. +class OperationListResult(msrest.serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of Automanage operations supported by the Automanage resource provider. - :type value: list[~automanage_client.models.Operation] + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~automanage_client.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str """ + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + _attribute_map = { 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__( self, **kwargs ): - super(OperationList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) + """ + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None -class ProxyResource(Resource): - """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. +class Report(ProxyResource): + """Definition of the report. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~automanage_client.models.SystemData + :ivar start_time: Start time of the configuration profile assignment processing. + :vartype start_time: str + :ivar end_time: End time of the configuration profile assignment processing. + :vartype end_time: str + :ivar last_modified_time: Last modified time of the configuration profile assignment + processing. + :vartype last_modified_time: str + :ivar duration: Duration of the configuration profile assignment processing. + :vartype duration: str + :ivar type_properties_type: Type of the configuration profile assignment processing + (Initial/Consistency). + :vartype type_properties_type: str + :ivar status: The status of the configuration profile assignment. + :vartype status: str + :ivar configuration_profile: The configurationProfile linked to the assignment. + :vartype configuration_profile: str + :ivar resources: List of resources processed by the configuration profile assignment. + :vartype resources: list[~automanage_client.models.ReportResource] + :ivar error: Error message, if any, returned by the configuration profile assignment + processing. + :vartype error: ~automanage_client.models.ErrorDetail + :ivar report_format_version: Version of the report format. + :vartype report_format_version: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'last_modified_time': {'readonly': True}, + 'duration': {'readonly': True}, + 'type_properties_type': {'readonly': True}, + 'status': {'readonly': True}, + 'configuration_profile': {'readonly': True}, + 'resources': {'readonly': True}, + 'error': {'readonly': True}, + 'report_format_version': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'start_time': {'key': 'properties.startTime', 'type': 'str'}, + 'end_time': {'key': 'properties.endTime', 'type': 'str'}, + 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'str'}, + 'duration': {'key': 'properties.duration', 'type': 'str'}, + 'type_properties_type': {'key': 'properties.type', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'configuration_profile': {'key': 'properties.configurationProfile', 'type': 'str'}, + 'resources': {'key': 'properties.resources', 'type': '[ReportResource]'}, + 'error': {'key': 'properties.error', 'type': 'ErrorDetail'}, + 'report_format_version': {'key': 'properties.reportFormatVersion', 'type': 'str'}, } def __init__( self, **kwargs ): - super(ProxyResource, self).__init__(**kwargs) + """ + :keyword start_time: Start time of the configuration profile assignment processing. + :paramtype start_time: str + :keyword end_time: End time of the configuration profile assignment processing. + :paramtype end_time: str + """ + super(Report, self).__init__(**kwargs) + self.system_data = None + self.start_time = kwargs.get('start_time', None) + self.end_time = kwargs.get('end_time', None) + self.last_modified_time = None + self.duration = None + self.type_properties_type = None + self.status = None + self.configuration_profile = None + self.resources = None + self.error = None + self.report_format_version = None + + +class ReportList(msrest.serialization.Model): + """The response of the list report operation. + + :ivar value: Result of the list report operation. + :vartype value: list[~automanage_client.models.Report] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Report]'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword value: Result of the list report operation. + :paramtype value: list[~automanage_client.models.Report] + """ + super(ReportList, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + + +class ReportResource(msrest.serialization.Model): + """Details about the resource processed by the configuration profile assignment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the resource. + :vartype name: str + :ivar id: ARM id of the resource. + :vartype id: str + :ivar type: Type of the resource. + :vartype type: str + :ivar status: Status of the resource. + :vartype status: str + :ivar error: Error message, if any, returned when deploying the resource. + :vartype error: ~automanage_client.models.ErrorDetail + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'status': {'readonly': True}, + 'error': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ReportResource, self).__init__(**kwargs) + self.name = None + self.id = None + self.type = None + self.status = None + self.error = None + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~automanage_client.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~automanage_client.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~automanage_client.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~automanage_client.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super(SystemData, self).__init__(**kwargs) + self.created_by = kwargs.get('created_by', None) + self.created_by_type = kwargs.get('created_by_type', None) + self.created_at = kwargs.get('created_at', None) + self.last_modified_by = kwargs.get('last_modified_by', None) + self.last_modified_by_type = kwargs.get('last_modified_by_type', None) + self.last_modified_at = kwargs.get('last_modified_at', None) diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models_py3.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models_py3.py index 733188416af6..40dfbd5f508e 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models_py3.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models_py3.py @@ -6,7 +6,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, Union +import datetime +from typing import Any, Dict, List, Optional, Union from azure.core.exceptions import HttpResponseError import msrest.serialization @@ -14,18 +15,102 @@ from ._automanage_client_enums import * +class BestPractice(msrest.serialization.Model): + """Definition of the Automanage best practice. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The fully qualified ID for the best practice. For example, + /providers/Microsoft.Automanage/bestPractices/azureBestPracticesProduction. + :vartype id: str + :ivar type: The type of the resource. For example, Microsoft.Automanage/bestPractices. + :vartype type: str + :ivar name: The name of the best practice. For example, azureBestPracticesProduction. + :vartype name: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~automanage_client.models.SystemData + :ivar configuration: configuration dictionary of the configuration profile. + :vartype configuration: any + :ivar overrides: overrides of the configuration profile. + :vartype overrides: list[any] + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'configuration': {'key': 'properties.configuration', 'type': 'object'}, + 'overrides': {'key': 'properties.overrides', 'type': '[object]'}, + } + + def __init__( + self, + *, + configuration: Optional[Any] = None, + overrides: Optional[List[Any]] = None, + **kwargs + ): + """ + :keyword configuration: configuration dictionary of the configuration profile. + :paramtype configuration: any + :keyword overrides: overrides of the configuration profile. + :paramtype overrides: list[any] + """ + super(BestPractice, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.system_data = None + self.configuration = configuration + self.overrides = overrides + + +class BestPracticeList(msrest.serialization.Model): + """The response of the list best practice operation. + + :ivar value: Result of the list best practice operation. + :vartype value: list[~automanage_client.models.BestPractice] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[BestPractice]'}, + } + + def __init__( + self, + *, + value: Optional[List["BestPractice"]] = None, + **kwargs + ): + """ + :keyword value: Result of the list best practice operation. + :paramtype value: list[~automanage_client.models.BestPractice] + """ + super(BestPracticeList, self).__init__(**kwargs) + self.value = value + + class Resource(msrest.serialization.Model): - """Resource. + """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str """ @@ -45,6 +130,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -52,24 +139,24 @@ def __init__( class TrackedResource(Resource): - """The resource model definition for a ARM tracked top level resource. + """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str """ _validation = { @@ -94,32 +181,41 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + """ super(TrackedResource, self).__init__(**kwargs) self.tags = tags self.location = location -class Account(TrackedResource): - """Definition of the Automanage account. +class ConfigurationProfile(TrackedResource): + """Definition of the configuration profile. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param identity: The identity of the Automanage account. - :type identity: ~automanage_client.models.AccountIdentity + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar properties: Properties of the configuration profile. + :vartype properties: ~automanage_client.models.ConfigurationProfileProperties + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~automanage_client.models.SystemData """ _validation = { @@ -127,6 +223,7 @@ class Account(TrackedResource): 'name': {'readonly': True}, 'type': {'readonly': True}, 'location': {'required': True}, + 'system_data': {'readonly': True}, } _attribute_map = { @@ -135,7 +232,8 @@ class Account(TrackedResource): 'type': {'key': 'type', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'AccountIdentity'}, + 'properties': {'key': 'properties', 'type': 'ConfigurationProfileProperties'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__( @@ -143,139 +241,83 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["AccountIdentity"] = None, + properties: Optional["ConfigurationProfileProperties"] = None, **kwargs ): - super(Account, self).__init__(tags=tags, location=location, **kwargs) - self.identity = identity + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword properties: Properties of the configuration profile. + :paramtype properties: ~automanage_client.models.ConfigurationProfileProperties + """ + super(ConfigurationProfile, self).__init__(tags=tags, location=location, **kwargs) + self.properties = properties + self.system_data = None -class AccountIdentity(msrest.serialization.Model): - """Identity for the Automanage account. +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. Variables are only populated by the server, and will be ignored when sending a request. - :ivar principal_id: The principal id of Automanage account identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id associated with the Automanage account. - :vartype tenant_id: str - :param type: The type of identity used for the Automanage account. Currently, the only - supported type is 'SystemAssigned', which implicitly creates an identity. Possible values - include: "SystemAssigned", "None". - :type type: str or ~automanage_client.models.ResourceIdentityType + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, } def __init__( self, - *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - **kwargs - ): - super(AccountIdentity, self).__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = type - - -class AccountList(msrest.serialization.Model): - """The response of the list Account operation. - - :param value: Result of the list Account operation. - :type value: list[~automanage_client.models.Account] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Account]'}, - } - - def __init__( - self, - *, - value: Optional[List["Account"]] = None, - **kwargs - ): - super(AccountList, self).__init__(**kwargs) - self.value = value - - -class UpdateResource(msrest.serialization.Model): - """Represents an update resource. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): - super(UpdateResource, self).__init__(**kwargs) - self.tags = tags - - -class AccountUpdate(UpdateResource): - """Definition of the Automanage account. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param identity: The identity of the Automanage account. - :type identity: ~automanage_client.models.AccountIdentity - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'AccountIdentity'}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - identity: Optional["AccountIdentity"] = None, **kwargs ): - super(AccountUpdate, self).__init__(tags=tags, **kwargs) - self.identity = identity + """ + """ + super(ProxyResource, self).__init__(**kwargs) -class ConfigurationProfileAssignment(Resource): +class ConfigurationProfileAssignment(ProxyResource): """Configuration profile assignment is an association between a VM and automanage profile configuration. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param properties: Properties of the configuration profile assignment. - :type properties: ~automanage_client.models.ConfigurationProfileAssignmentProperties + :ivar properties: Properties of the configuration profile assignment. + :vartype properties: ~automanage_client.models.ConfigurationProfileAssignmentProperties + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~automanage_client.models.SystemData """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'system_data': {'readonly': True}, } _attribute_map = { @@ -283,6 +325,7 @@ class ConfigurationProfileAssignment(Resource): 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'properties': {'key': 'properties', 'type': 'ConfigurationProfileAssignmentProperties'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__( @@ -291,41 +334,20 @@ def __init__( properties: Optional["ConfigurationProfileAssignmentProperties"] = None, **kwargs ): + """ + :keyword properties: Properties of the configuration profile assignment. + :paramtype properties: ~automanage_client.models.ConfigurationProfileAssignmentProperties + """ super(ConfigurationProfileAssignment, self).__init__(**kwargs) self.properties = properties - - -class ConfigurationProfileAssignmentCompliance(msrest.serialization.Model): - """The compliance status for the configuration profile assignment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar update_status: The state of compliance, which only appears in the response. Possible - values include: "Succeeded", "Failed", "Created". - :vartype update_status: str or ~automanage_client.models.UpdateStatus - """ - - _validation = { - 'update_status': {'readonly': True}, - } - - _attribute_map = { - 'update_status': {'key': 'updateStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfigurationProfileAssignmentCompliance, self).__init__(**kwargs) - self.update_status = None + self.system_data = None class ConfigurationProfileAssignmentList(msrest.serialization.Model): """The response of the list configuration profile assignment operation. - :param value: Result of the list configuration profile assignment operation. - :type value: list[~automanage_client.models.ConfigurationProfileAssignment] + :ivar value: Result of the list configuration profile assignment operation. + :vartype value: list[~automanage_client.models.ConfigurationProfileAssignment] """ _attribute_map = { @@ -338,6 +360,10 @@ def __init__( value: Optional[List["ConfigurationProfileAssignment"]] = None, **kwargs ): + """ + :keyword value: Result of the list configuration profile assignment operation. + :paramtype value: list[~automanage_client.models.ConfigurationProfileAssignment] + """ super(ConfigurationProfileAssignmentList, self).__init__(**kwargs) self.value = value @@ -347,261 +373,162 @@ class ConfigurationProfileAssignmentProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param configuration_profile: A value indicating configuration profile. Possible values - include: "Azure virtual machine best practices – Dev/Test", "Azure virtual machine best - practices – Production". - :type configuration_profile: str or ~automanage_client.models.ConfigurationProfile - :param target_id: The target VM resource URI. - :type target_id: str - :param account_id: The Automanage account ARM Resource URI. - :type account_id: str - :param configuration_profile_preference_id: The configuration profile custom preferences ARM - resource URI. - :type configuration_profile_preference_id: str - :ivar provisioning_status: The state of onboarding, which only appears in the response. - Possible values include: "Succeeded", "Failed", "Created". - :vartype provisioning_status: str or ~automanage_client.models.ProvisioningStatus - :param compliance: The configuration setting for the configuration profile. - :type compliance: ~automanage_client.models.ConfigurationProfileAssignmentCompliance + :ivar configuration_profile: The Automanage configurationProfile ARM Resource URI. + :vartype configuration_profile: str + :ivar target_id: The target VM resource URI. + :vartype target_id: str + :ivar status: The status of onboarding, which only appears in the response. + :vartype status: str + :ivar profile_overrides: The profileOverrides setting for the configuration profile assignment. + :vartype profile_overrides: dict[str, any] """ _validation = { - 'provisioning_status': {'readonly': True}, + 'status': {'readonly': True}, } _attribute_map = { 'configuration_profile': {'key': 'configurationProfile', 'type': 'str'}, 'target_id': {'key': 'targetId', 'type': 'str'}, - 'account_id': {'key': 'accountId', 'type': 'str'}, - 'configuration_profile_preference_id': {'key': 'configurationProfilePreferenceId', 'type': 'str'}, - 'provisioning_status': {'key': 'provisioningStatus', 'type': 'str'}, - 'compliance': {'key': 'compliance', 'type': 'ConfigurationProfileAssignmentCompliance'}, + 'status': {'key': 'status', 'type': 'str'}, + 'profile_overrides': {'key': 'profileOverrides', 'type': '{object}'}, } def __init__( self, *, - configuration_profile: Optional[Union[str, "ConfigurationProfile"]] = None, + configuration_profile: Optional[str] = None, target_id: Optional[str] = None, - account_id: Optional[str] = None, - configuration_profile_preference_id: Optional[str] = None, - compliance: Optional["ConfigurationProfileAssignmentCompliance"] = None, + profile_overrides: Optional[Dict[str, Any]] = None, **kwargs ): + """ + :keyword configuration_profile: The Automanage configurationProfile ARM Resource URI. + :paramtype configuration_profile: str + :keyword target_id: The target VM resource URI. + :paramtype target_id: str + :keyword profile_overrides: The profileOverrides setting for the configuration profile + assignment. + :paramtype profile_overrides: dict[str, any] + """ super(ConfigurationProfileAssignmentProperties, self).__init__(**kwargs) self.configuration_profile = configuration_profile self.target_id = target_id - self.account_id = account_id - self.configuration_profile_preference_id = configuration_profile_preference_id - self.provisioning_status = None - self.compliance = compliance - - -class ConfigurationProfilePreference(TrackedResource): - """Definition of the configuration profile preference. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource Id for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param properties: Properties of the configuration profile preference. - :type properties: ~automanage_client.models.ConfigurationProfilePreferenceProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ConfigurationProfilePreferenceProperties'}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - properties: Optional["ConfigurationProfilePreferenceProperties"] = None, - **kwargs - ): - super(ConfigurationProfilePreference, self).__init__(tags=tags, location=location, **kwargs) - self.properties = properties - - -class ConfigurationProfilePreferenceAntiMalware(msrest.serialization.Model): - """Automanage configuration profile Antimalware preferences. - - :param enable_real_time_protection: Enables or disables Real Time Protection. Possible values - include: "True", "False". - :type enable_real_time_protection: str or ~automanage_client.models.EnableRealTimeProtection - :param exclusions: Extensions, Paths and Processes that must be excluded from scan. - :type exclusions: object - :param run_scheduled_scan: Enables or disables a periodic scan for antimalware. Possible values - include: "True", "False". - :type run_scheduled_scan: str or ~automanage_client.models.RunScheduledScan - :param scan_type: Type of scheduled scan. Possible values include: "Quick", "Full". - :type scan_type: str or ~automanage_client.models.ScanType - :param scan_day: Schedule scan settings day. - :type scan_day: str - :param scan_time_in_minutes: Schedule scan settings time. - :type scan_time_in_minutes: str - """ - - _attribute_map = { - 'enable_real_time_protection': {'key': 'enableRealTimeProtection', 'type': 'str'}, - 'exclusions': {'key': 'exclusions', 'type': 'object'}, - 'run_scheduled_scan': {'key': 'runScheduledScan', 'type': 'str'}, - 'scan_type': {'key': 'scanType', 'type': 'str'}, - 'scan_day': {'key': 'scanDay', 'type': 'str'}, - 'scan_time_in_minutes': {'key': 'scanTimeInMinutes', 'type': 'str'}, - } - - def __init__( - self, - *, - enable_real_time_protection: Optional[Union[str, "EnableRealTimeProtection"]] = None, - exclusions: Optional[object] = None, - run_scheduled_scan: Optional[Union[str, "RunScheduledScan"]] = None, - scan_type: Optional[Union[str, "ScanType"]] = None, - scan_day: Optional[str] = None, - scan_time_in_minutes: Optional[str] = None, - **kwargs - ): - super(ConfigurationProfilePreferenceAntiMalware, self).__init__(**kwargs) - self.enable_real_time_protection = enable_real_time_protection - self.exclusions = exclusions - self.run_scheduled_scan = run_scheduled_scan - self.scan_type = scan_type - self.scan_day = scan_day - self.scan_time_in_minutes = scan_time_in_minutes + self.status = None + self.profile_overrides = profile_overrides -class ConfigurationProfilePreferenceList(msrest.serialization.Model): - """The response of the list ConfigurationProfilePreference operation. +class ConfigurationProfileList(msrest.serialization.Model): + """The response of the list configuration profile operation. - :param value: Result of the list ConfigurationProfilePreference operation. - :type value: list[~automanage_client.models.ConfigurationProfilePreference] + :ivar value: Result of the list ConfigurationProfile operation. + :vartype value: list[~automanage_client.models.ConfigurationProfile] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ConfigurationProfilePreference]'}, + 'value': {'key': 'value', 'type': '[ConfigurationProfile]'}, } def __init__( self, *, - value: Optional[List["ConfigurationProfilePreference"]] = None, + value: Optional[List["ConfigurationProfile"]] = None, **kwargs ): - super(ConfigurationProfilePreferenceList, self).__init__(**kwargs) + """ + :keyword value: Result of the list ConfigurationProfile operation. + :paramtype value: list[~automanage_client.models.ConfigurationProfile] + """ + super(ConfigurationProfileList, self).__init__(**kwargs) self.value = value -class ConfigurationProfilePreferenceProperties(msrest.serialization.Model): - """Automanage configuration profile preference properties. +class ConfigurationProfileProperties(msrest.serialization.Model): + """Automanage configuration profile properties. - :param vm_backup: The custom preferences for Azure VM Backup. - :type vm_backup: ~automanage_client.models.ConfigurationProfilePreferenceVmBackup - :param anti_malware: The custom preferences for Azure Antimalware. - :type anti_malware: ~automanage_client.models.ConfigurationProfilePreferenceAntiMalware + :ivar configuration: configuration dictionary of the configuration profile. + :vartype configuration: any + :ivar overrides: overrides of the configuration profile. + :vartype overrides: list[any] """ _attribute_map = { - 'vm_backup': {'key': 'vmBackup', 'type': 'ConfigurationProfilePreferenceVmBackup'}, - 'anti_malware': {'key': 'antiMalware', 'type': 'ConfigurationProfilePreferenceAntiMalware'}, + 'configuration': {'key': 'configuration', 'type': 'object'}, + 'overrides': {'key': 'overrides', 'type': '[object]'}, } def __init__( self, *, - vm_backup: Optional["ConfigurationProfilePreferenceVmBackup"] = None, - anti_malware: Optional["ConfigurationProfilePreferenceAntiMalware"] = None, + configuration: Optional[Any] = None, + overrides: Optional[List[Any]] = None, **kwargs ): - super(ConfigurationProfilePreferenceProperties, self).__init__(**kwargs) - self.vm_backup = vm_backup - self.anti_malware = anti_malware + """ + :keyword configuration: configuration dictionary of the configuration profile. + :paramtype configuration: any + :keyword overrides: overrides of the configuration profile. + :paramtype overrides: list[any] + """ + super(ConfigurationProfileProperties, self).__init__(**kwargs) + self.configuration = configuration + self.overrides = overrides -class ConfigurationProfilePreferenceUpdate(UpdateResource): - """Definition of the configuration profile preference. +class UpdateResource(msrest.serialization.Model): + """Represents an update resource. - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param properties: Properties of the configuration profile preference. - :type properties: ~automanage_client.models.ConfigurationProfilePreferenceProperties + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] """ _attribute_map = { 'tags': {'key': 'tags', 'type': '{str}'}, - 'properties': {'key': 'properties', 'type': 'ConfigurationProfilePreferenceProperties'}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - properties: Optional["ConfigurationProfilePreferenceProperties"] = None, **kwargs ): - super(ConfigurationProfilePreferenceUpdate, self).__init__(tags=tags, **kwargs) - self.properties = properties + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ + super(UpdateResource, self).__init__(**kwargs) + self.tags = tags -class ConfigurationProfilePreferenceVmBackup(msrest.serialization.Model): - """Automanage configuration profile VM Backup preferences. +class ConfigurationProfileUpdate(UpdateResource): + """Definition of the configuration profile. - :param time_zone: TimeZone optional input as string. For example: Pacific Standard Time. - :type time_zone: str - :param instant_rp_retention_range_in_days: Instant RP retention policy range in days. - :type instant_rp_retention_range_in_days: int - :param retention_policy: Retention policy with the details on backup copy retention ranges. - :type retention_policy: str - :param schedule_policy: Backup schedule specified as part of backup policy. - :type schedule_policy: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar properties: Properties of the configuration profile. + :vartype properties: ~automanage_client.models.ConfigurationProfileProperties """ _attribute_map = { - 'time_zone': {'key': 'timeZone', 'type': 'str'}, - 'instant_rp_retention_range_in_days': {'key': 'instantRpRetentionRangeInDays', 'type': 'int'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'str'}, - 'schedule_policy': {'key': 'schedulePolicy', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'properties': {'key': 'properties', 'type': 'ConfigurationProfileProperties'}, } def __init__( self, *, - time_zone: Optional[str] = None, - instant_rp_retention_range_in_days: Optional[int] = None, - retention_policy: Optional[str] = None, - schedule_policy: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + properties: Optional["ConfigurationProfileProperties"] = None, **kwargs ): - super(ConfigurationProfilePreferenceVmBackup, self).__init__(**kwargs) - self.time_zone = time_zone - self.instant_rp_retention_range_in_days = instant_rp_retention_range_in_days - self.retention_policy = retention_policy - self.schedule_policy = schedule_policy + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword properties: Properties of the configuration profile. + :paramtype properties: ~automanage_client.models.ConfigurationProfileProperties + """ + super(ConfigurationProfileUpdate, self).__init__(tags=tags, **kwargs) + self.properties = properties class ErrorAdditionalInfo(msrest.serialization.Model): @@ -612,7 +539,7 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: object + :vartype info: any """ _validation = { @@ -629,34 +556,15 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): - """The resource management error response. - - :param error: The error object. - :type error: ~automanage_client.models.ErrorResponseError - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, - } - - def __init__( - self, - *, - error: Optional["ErrorResponseError"] = None, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = error - - -class ErrorResponseError(msrest.serialization.Model): - """The error object. +class ErrorDetail(msrest.serialization.Model): + """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -667,7 +575,7 @@ class ErrorResponseError(msrest.serialization.Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: list[~automanage_client.models.ErrorResponse] + :vartype details: list[~automanage_client.models.ErrorDetail] :ivar additional_info: The error additional info. :vartype additional_info: list[~automanage_client.models.ErrorAdditionalInfo] """ @@ -684,7 +592,7 @@ class ErrorResponseError(msrest.serialization.Model): 'code': {'key': 'code', 'type': 'str'}, 'message': {'key': 'message', 'type': 'str'}, 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, + 'details': {'key': 'details', 'type': '[ErrorDetail]'}, 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } @@ -692,7 +600,9 @@ def __init__( self, **kwargs ): - super(ErrorResponseError, self).__init__(**kwargs) + """ + """ + super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None self.target = None @@ -700,56 +610,112 @@ def __init__( self.additional_info = None +class ErrorResponse(msrest.serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~automanage_client.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDetail"] = None, + **kwargs + ): + """ + :keyword error: The error object. + :paramtype error: ~automanage_client.models.ErrorDetail + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + class Operation(msrest.serialization.Model): - """Automanage REST API operation. - - :param name: Operation name: For ex. - providers/Microsoft.Automanage/configurationProfileAssignments/write or read. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: str - :param display: Provider, Resource, Operation and description values. - :type display: ~automanage_client.models.OperationDisplay - :param status_code: Service provider: Microsoft.Automanage. - :type status_code: str + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~automanage_client.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Possible values include: "user", + "system", "user,system". + :vartype origin: str or ~automanage_client.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Possible values include: "Internal". + :vartype action_type: str or ~automanage_client.models.ActionType """ + _validation = { + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, + } + _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'status_code': {'key': 'properties.statusCode', 'type': 'str'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, } def __init__( self, *, - name: Optional[str] = None, - is_data_action: Optional[str] = None, display: Optional["OperationDisplay"] = None, - status_code: Optional[str] = None, **kwargs ): + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~automanage_client.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) - self.name = name - self.is_data_action = is_data_action + self.name = None + self.is_data_action = None self.display = display - self.status_code = status_code + self.origin = None + self.action_type = None class OperationDisplay(msrest.serialization.Model): - """Provider, Resource, Operation and description values. - - :param provider: Service provider: Microsoft.Automanage. - :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 + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str """ + _validation = { + 'provider': {'readonly': True}, + 'resource': {'readonly': True}, + 'operation': {'readonly': True}, + 'description': {'readonly': True}, + } + _attribute_map = { 'provider': {'key': 'provider', 'type': 'str'}, 'resource': {'key': 'resource', 'type': 'str'}, @@ -759,70 +725,280 @@ class OperationDisplay(msrest.serialization.Model): def __init__( self, - *, - provider: Optional[str] = None, - resource: Optional[str] = None, - operation: Optional[str] = None, - description: Optional[str] = None, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) - self.provider = provider - self.resource = resource - self.operation = operation - self.description = description + self.provider = None + self.resource = None + self.operation = None + self.description = None -class OperationList(msrest.serialization.Model): - """The response model for the list of Automanage operations. +class OperationListResult(msrest.serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of Automanage operations supported by the Automanage resource provider. - :type value: list[~automanage_client.models.Operation] + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~automanage_client.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str """ + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + _attribute_map = { 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__( self, - *, - value: Optional[List["Operation"]] = None, **kwargs ): - super(OperationList, self).__init__(**kwargs) - self.value = value + """ + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None -class ProxyResource(Resource): - """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. +class Report(ProxyResource): + """Definition of the report. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~automanage_client.models.SystemData + :ivar start_time: Start time of the configuration profile assignment processing. + :vartype start_time: str + :ivar end_time: End time of the configuration profile assignment processing. + :vartype end_time: str + :ivar last_modified_time: Last modified time of the configuration profile assignment + processing. + :vartype last_modified_time: str + :ivar duration: Duration of the configuration profile assignment processing. + :vartype duration: str + :ivar type_properties_type: Type of the configuration profile assignment processing + (Initial/Consistency). + :vartype type_properties_type: str + :ivar status: The status of the configuration profile assignment. + :vartype status: str + :ivar configuration_profile: The configurationProfile linked to the assignment. + :vartype configuration_profile: str + :ivar resources: List of resources processed by the configuration profile assignment. + :vartype resources: list[~automanage_client.models.ReportResource] + :ivar error: Error message, if any, returned by the configuration profile assignment + processing. + :vartype error: ~automanage_client.models.ErrorDetail + :ivar report_format_version: Version of the report format. + :vartype report_format_version: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'last_modified_time': {'readonly': True}, + 'duration': {'readonly': True}, + 'type_properties_type': {'readonly': True}, + 'status': {'readonly': True}, + 'configuration_profile': {'readonly': True}, + 'resources': {'readonly': True}, + 'error': {'readonly': True}, + 'report_format_version': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'start_time': {'key': 'properties.startTime', 'type': 'str'}, + 'end_time': {'key': 'properties.endTime', 'type': 'str'}, + 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'str'}, + 'duration': {'key': 'properties.duration', 'type': 'str'}, + 'type_properties_type': {'key': 'properties.type', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'configuration_profile': {'key': 'properties.configurationProfile', 'type': 'str'}, + 'resources': {'key': 'properties.resources', 'type': '[ReportResource]'}, + 'error': {'key': 'properties.error', 'type': 'ErrorDetail'}, + 'report_format_version': {'key': 'properties.reportFormatVersion', 'type': 'str'}, } def __init__( self, + *, + start_time: Optional[str] = None, + end_time: Optional[str] = None, **kwargs ): - super(ProxyResource, self).__init__(**kwargs) + """ + :keyword start_time: Start time of the configuration profile assignment processing. + :paramtype start_time: str + :keyword end_time: End time of the configuration profile assignment processing. + :paramtype end_time: str + """ + super(Report, self).__init__(**kwargs) + self.system_data = None + self.start_time = start_time + self.end_time = end_time + self.last_modified_time = None + self.duration = None + self.type_properties_type = None + self.status = None + self.configuration_profile = None + self.resources = None + self.error = None + self.report_format_version = None + + +class ReportList(msrest.serialization.Model): + """The response of the list report operation. + + :ivar value: Result of the list report operation. + :vartype value: list[~automanage_client.models.Report] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Report]'}, + } + + def __init__( + self, + *, + value: Optional[List["Report"]] = None, + **kwargs + ): + """ + :keyword value: Result of the list report operation. + :paramtype value: list[~automanage_client.models.Report] + """ + super(ReportList, self).__init__(**kwargs) + self.value = value + + +class ReportResource(msrest.serialization.Model): + """Details about the resource processed by the configuration profile assignment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the resource. + :vartype name: str + :ivar id: ARM id of the resource. + :vartype id: str + :ivar type: Type of the resource. + :vartype type: str + :ivar status: Status of the resource. + :vartype status: str + :ivar error: Error message, if any, returned when deploying the resource. + :vartype error: ~automanage_client.models.ErrorDetail + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'status': {'readonly': True}, + 'error': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ReportResource, self).__init__(**kwargs) + self.name = None + self.id = None + self.type = None + self.status = None + self.error = None + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~automanage_client.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~automanage_client.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~automanage_client.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~automanage_client.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/__init__.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/__init__.py index 9520dfd09e18..d889ce914774 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/__init__.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/__init__.py @@ -6,14 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._accounts_operations import AccountsOperations +from ._best_practices_operations import BestPracticesOperations +from ._best_practices_versions_operations import BestPracticesVersionsOperations +from ._configuration_profiles_operations import ConfigurationProfilesOperations +from ._configuration_profiles_versions_operations import ConfigurationProfilesVersionsOperations from ._configuration_profile_assignments_operations import ConfigurationProfileAssignmentsOperations -from ._configuration_profile_preferences_operations import ConfigurationProfilePreferencesOperations from ._operations import Operations +from ._reports_operations import ReportsOperations __all__ = [ - 'AccountsOperations', + 'BestPracticesOperations', + 'BestPracticesVersionsOperations', + 'ConfigurationProfilesOperations', + 'ConfigurationProfilesVersionsOperations', 'ConfigurationProfileAssignmentsOperations', - 'ConfigurationProfilePreferencesOperations', 'Operations', + 'ReportsOperations', ] diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_accounts_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_accounts_operations.py deleted file mode 100644 index d97b79a4a8b1..000000000000 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_accounts_operations.py +++ /dev/null @@ -1,426 +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 typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import 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.mgmt.core.exceptions import ARMErrorFormat - -from .. import 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]] - -class AccountsOperations(object): - """AccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~automanage_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def create_or_update( - self, - account_name, # type: str - resource_group_name, # type: str - parameters, # type: "models.Account" - **kwargs # type: Any - ): - # type: (...) -> "models.Account" - """Creates an Automanage Account. - - :param account_name: Name of the Automanage account. - :type account_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param parameters: Parameters supplied to create or update Automanage account. - :type parameters: ~automanage_client.models.Account - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Account, or the result of cls(response) - :rtype: ~automanage_client.models.Account - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Account"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Account') - 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(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('Account', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('Account', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}'} # type: ignore - - def get( - self, - account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "models.Account" - """Get information about a Automanage account. - - :param account_name: The Automanage account name. - :type account_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Account, or the result of cls(response) - :rtype: ~automanage_client.models.Account - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Account"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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'] = 'application/json' - - 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(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Account', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}'} # type: ignore - - def delete( - self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Delete a Automanage account. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param account_name: Name of the Automanage account. - :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - 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] - - 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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}'} # type: ignore - - def update( - self, - account_name, # type: str - resource_group_name, # type: str - parameters, # type: "models.AccountUpdate" - **kwargs # type: Any - ): - # type: (...) -> "models.Account" - """Updates an Automanage Account. - - :param account_name: Name of the Automanage account. - :type account_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param parameters: Parameters supplied to update Automanage account. - :type parameters: ~automanage_client.models.AccountUpdate - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Account, or the result of cls(response) - :rtype: ~automanage_client.models.Account - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Account"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AccountUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Account', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}'} # type: ignore - - def list_by_resource_group( - self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.AccountList"] - """Retrieve a list of Automanage accounts within a given resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :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 AccountList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.AccountList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.AccountList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('AccountList', 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]: - error = self._deserialize(models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts'} # type: ignore - - def list_by_subscription( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.AccountList"] - """Retrieve a list of Automanage accounts within a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccountList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.AccountList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.AccountList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - 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) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('AccountList', 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]: - error = self._deserialize(models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/accounts'} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_best_practices_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_best_practices_operations.py new file mode 100644 index 000000000000..791586577cfe --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_best_practices_operations.py @@ -0,0 +1,223 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import TYPE_CHECKING +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 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 +from .._vendor import _convert_request, _format_url_section + +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]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + best_practice_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Automanage/bestPractices/{bestPracticeName}') + path_format_arguments = { + "bestPracticeName": _SERIALIZER.url("best_practice_name", best_practice_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_list_by_tenant_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Automanage/bestPractices') + + # 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 + ) + +# fmt: on +class BestPracticesOperations(object): + """BestPracticesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~automanage_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get( + self, + best_practice_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.BestPractice" + """Get information about a Automanage best practice. + + :param best_practice_name: The Automanage best practice name. + :type best_practice_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BestPractice, or the result of cls(response) + :rtype: ~automanage_client.models.BestPractice + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BestPractice"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + best_practice_name=best_practice_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BestPractice', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/providers/Microsoft.Automanage/bestPractices/{bestPracticeName}'} # type: ignore + + + @distributed_trace + def list_by_tenant( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.BestPracticeList"] + """Retrieve a list of Automanage best practices. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BestPracticeList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.BestPracticeList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BestPracticeList"] + 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_list_by_tenant_request( + template_url=self.list_by_tenant.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_tenant_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("BestPracticeList", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_tenant.metadata = {'url': '/providers/Microsoft.Automanage/bestPractices'} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_best_practices_versions_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_best_practices_versions_operations.py new file mode 100644 index 000000000000..d140fc3125de --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_best_practices_versions_operations.py @@ -0,0 +1,240 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import TYPE_CHECKING +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 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 +from .._vendor import _convert_request, _format_url_section + +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]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + best_practice_name, # type: str + version_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Automanage/bestPractices/{bestPracticeName}/versions/{versionName}') + path_format_arguments = { + "bestPracticeName": _SERIALIZER.url("best_practice_name", best_practice_name, 'str'), + "versionName": _SERIALIZER.url("version_name", version_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_list_by_tenant_request( + best_practice_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Automanage/bestPractices/{bestPracticeName}/versions') + path_format_arguments = { + "bestPracticeName": _SERIALIZER.url("best_practice_name", best_practice_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 + ) + +# fmt: on +class BestPracticesVersionsOperations(object): + """BestPracticesVersionsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~automanage_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get( + self, + best_practice_name, # type: str + version_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.BestPractice" + """Get information about a Automanage best practice version. + + :param best_practice_name: The Automanage best practice name. + :type best_practice_name: str + :param version_name: The Automanage best practice version name. + :type version_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BestPractice, or the result of cls(response) + :rtype: ~automanage_client.models.BestPractice + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BestPractice"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + best_practice_name=best_practice_name, + version_name=version_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BestPractice', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/providers/Microsoft.Automanage/bestPractices/{bestPracticeName}/versions/{versionName}'} # type: ignore + + + @distributed_trace + def list_by_tenant( + self, + best_practice_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.BestPracticeList"] + """Retrieve a list of Automanage best practices versions. + + :param best_practice_name: The Automanage best practice name. + :type best_practice_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BestPracticeList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.BestPracticeList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BestPracticeList"] + 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_list_by_tenant_request( + best_practice_name=best_practice_name, + template_url=self.list_by_tenant.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_tenant_request( + best_practice_name=best_practice_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("BestPracticeList", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_tenant.metadata = {'url': '/providers/Microsoft.Automanage/bestPractices/{bestPracticeName}/versions'} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_assignments_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_assignments_operations.py index 3ce28d9f8d6f..c5a8a6171b0e 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_assignments_operations.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_assignments_operations.py @@ -5,26 +5,216 @@ # 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 TYPE_CHECKING import warnings -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.polling import LROPoller, NoPolling, PollingMethod +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 azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer -from .. import models +from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + configuration_profile_assignment_name, # type: str + subscription_id, # type: str + resource_group_name, # type: str + vm_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}') + path_format_arguments = { + "configurationProfileAssignmentName": _SERIALIZER.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + configuration_profile_assignment_name, # type: str + subscription_id, # type: str + vm_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "configurationProfileAssignmentName": _SERIALIZER.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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, # type: str + configuration_profile_assignment_name, # type: str + subscription_id, # type: str + vm_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "configurationProfileAssignmentName": _SERIALIZER.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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_list_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfileAssignments') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _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_by_subscription_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/configurationProfileAssignments') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + 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 + ) + +# fmt: on class ConfigurationProfileAssignmentsOperations(object): """ConfigurationProfileAssignmentsOperations operations. @@ -39,7 +229,7 @@ class ConfigurationProfileAssignmentsOperations(object): :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): self._client = client @@ -47,51 +237,61 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def _create_or_update_initial( + @distributed_trace + def create_or_update( self, configuration_profile_assignment_name, # type: str resource_group_name, # type: str vm_name, # type: str - parameters, # type: "models.ConfigurationProfileAssignment" + parameters, # type: "_models.ConfigurationProfileAssignment" **kwargs # type: Any ): - # type: (...) -> "models.ConfigurationProfileAssignment" - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignment"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'configurationProfileAssignmentName': self._serialize.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'vmName': self._serialize.url("vm_name", vm_name, 'str'), + # type: (...) -> "_models.ConfigurationProfileAssignment" + """Creates an association between a VM and Automanage configuration profile. + + :param configuration_profile_assignment_name: Name of the configuration profile assignment. + Only default is supported. + :type configuration_profile_assignment_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. + :type vm_name: str + :param parameters: Parameters supplied to the create or update configuration profile + assignment. + :type parameters: ~automanage_client.models.ConfigurationProfileAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationProfileAssignment, or the result of cls(response) + :rtype: ~automanage_client.models.ConfigurationProfileAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {})) - # 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'] = 'application/json' + _json = self._serialize.body(parameters, 'ConfigurationProfileAssignment') - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConfigurationProfileAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + request = build_create_or_update_request( + configuration_profile_assignment_name=configuration_profile_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) 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(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: @@ -104,80 +304,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore - def begin_create_or_update( - self, - configuration_profile_assignment_name, # type: str - resource_group_name, # type: str - vm_name, # type: str - parameters, # type: "models.ConfigurationProfileAssignment" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["models.ConfigurationProfileAssignment"] - """Creates an association between a VM and Automanage configuration profile. + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore - :param configuration_profile_assignment_name: Name of the configuration profile assignment. - Only default is supported. - :type configuration_profile_assignment_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. - :type vm_name: str - :param parameters: Parameters supplied to the create or update configuration profile - assignment. - :type parameters: ~automanage_client.models.ConfigurationProfileAssignment - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ConfigurationProfileAssignment or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~automanage_client.models.ConfigurationProfileAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignment"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - configuration_profile_assignment_name=configuration_profile_assignment_name, - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -185,7 +316,7 @@ def get( vm_name, # type: str **kwargs # type: Any ): - # type: (...) -> "models.ConfigurationProfileAssignment" + # type: (...) -> "_models.ConfigurationProfileAssignment" """Get information about a configuration profile assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -199,36 +330,29 @@ def get( :rtype: ~automanage_client.models.ConfigurationProfileAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignment"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'configurationProfileAssignmentName': self._serialize.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'vmName': self._serialize.url("vm_name", vm_name, 'str'), + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - 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') + error_map.update(kwargs.pop('error_map', {})) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + + request = build_get_request( + resource_group_name=resource_group_name, + configuration_profile_assignment_name=configuration_profile_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(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) @@ -237,8 +361,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -261,34 +388,28 @@ def delete( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'configurationProfileAssignmentName': self._serialize.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'vmName': self._serialize.url("vm_name", vm_name, 'str'), + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - 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') + error_map.update(kwargs.pop('error_map', {})) - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + configuration_profile_assignment_name=configuration_profile_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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -296,52 +417,55 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore + + @distributed_trace def list( self, resource_group_name, # type: str **kwargs # type: Any ): - # type: (...) -> Iterable["models.ConfigurationProfileAssignmentList"] + # type: (...) -> Iterable["_models.ConfigurationProfileAssignmentList"] """Get list of configuration profile assignments. :param resource_group_name: The name of the resource group. The name is case insensitive. :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 ConfigurationProfileAssignmentList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.ConfigurationProfileAssignmentList] + :return: An iterator like instance of either ConfigurationProfileAssignmentList or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~automanage_client.models.ConfigurationProfileAssignmentList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignmentList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignmentList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - 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', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - 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, + 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, + 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('ConfigurationProfileAssignmentList', pipeline_response) + deserialized = self._deserialize("ConfigurationProfileAssignmentList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -354,59 +478,61 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfileAssignments'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs # type: Any ): - # type: (...) -> Iterable["models.ConfigurationProfileAssignmentList"] + # type: (...) -> Iterable["_models.ConfigurationProfileAssignmentList"] """Get list of configuration profile assignments under a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfigurationProfileAssignmentList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.ConfigurationProfileAssignmentList] + :return: An iterator like instance of either ConfigurationProfileAssignmentList or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~automanage_client.models.ConfigurationProfileAssignmentList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignmentList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignmentList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - 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_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.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_by_subscription_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('ConfigurationProfileAssignmentList', pipeline_response) + deserialized = self._deserialize("ConfigurationProfileAssignmentList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -419,12 +545,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_preferences_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_preferences_operations.py deleted file mode 100644 index 094cc67131d5..000000000000 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_preferences_operations.py +++ /dev/null @@ -1,426 +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 typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import 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.mgmt.core.exceptions import ARMErrorFormat - -from .. import 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]] - -class ConfigurationProfilePreferencesOperations(object): - """ConfigurationProfilePreferencesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~automanage_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def create_or_update( - self, - configuration_profile_preference_name, # type: str - resource_group_name, # type: str - parameters, # type: "models.ConfigurationProfilePreference" - **kwargs # type: Any - ): - # type: (...) -> "models.ConfigurationProfilePreference" - """Creates a configuration profile preference. - - :param configuration_profile_preference_name: Name of the configuration profile preference. - :type configuration_profile_preference_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param parameters: Parameters supplied to create or update configuration profile preference. - :type parameters: ~automanage_client.models.ConfigurationProfilePreference - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigurationProfilePreference, or the result of cls(response) - :rtype: ~automanage_client.models.ConfigurationProfilePreference - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreference"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'configurationProfilePreferenceName': self._serialize.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConfigurationProfilePreference') - 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(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('ConfigurationProfilePreference', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('ConfigurationProfilePreference', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}'} # type: ignore - - def get( - self, - configuration_profile_preference_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "models.ConfigurationProfilePreference" - """Get information about a configuration profile preference. - - :param configuration_profile_preference_name: The configuration profile preference name. - :type configuration_profile_preference_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigurationProfilePreference, or the result of cls(response) - :rtype: ~automanage_client.models.ConfigurationProfilePreference - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreference"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'configurationProfilePreferenceName': self._serialize.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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'] = 'application/json' - - 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(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('ConfigurationProfilePreference', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}'} # type: ignore - - def delete( - self, - resource_group_name, # type: str - configuration_profile_preference_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Delete a configuration profile preference. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param configuration_profile_preference_name: Name of the configuration profile preference. - :type configuration_profile_preference_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'configurationProfilePreferenceName': self._serialize.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - 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] - - 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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}'} # type: ignore - - def update( - self, - configuration_profile_preference_name, # type: str - resource_group_name, # type: str - parameters, # type: "models.ConfigurationProfilePreferenceUpdate" - **kwargs # type: Any - ): - # type: (...) -> "models.ConfigurationProfilePreference" - """Updates a configuration profile preference. - - :param configuration_profile_preference_name: Name of the configuration profile preference. - :type configuration_profile_preference_name: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param parameters: Parameters supplied to create or update configuration profile preference. - :type parameters: ~automanage_client.models.ConfigurationProfilePreferenceUpdate - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConfigurationProfilePreference, or the result of cls(response) - :rtype: ~automanage_client.models.ConfigurationProfilePreference - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreference"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'configurationProfilePreferenceName': self._serialize.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConfigurationProfilePreferenceUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('ConfigurationProfilePreference', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}'} # type: ignore - - def list_by_resource_group( - self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.ConfigurationProfilePreferenceList"] - """Retrieve a list of configuration profile preferences within a given resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :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 ConfigurationProfilePreferenceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.ConfigurationProfilePreferenceList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreferenceList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ConfigurationProfilePreferenceList', 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]: - error = self._deserialize(models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences'} # type: ignore - - def list_by_subscription( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.ConfigurationProfilePreferenceList"] - """Retrieve a list of configuration profile preferences within a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfigurationProfilePreferenceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.ConfigurationProfilePreferenceList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreferenceList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - 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) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ConfigurationProfilePreferenceList', 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]: - error = self._deserialize(models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/configurationProfilePreferences'} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profiles_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profiles_operations.py new file mode 100644 index 000000000000..4f2e5b91150c --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profiles_operations.py @@ -0,0 +1,637 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import TYPE_CHECKING +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 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 +from .._vendor import _convert_request, _format_url_section + +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]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + configuration_profile_name, # type: str + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}') + path_format_arguments = { + "configurationProfileName": _SERIALIZER.url("configuration_profile_name", configuration_profile_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + 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, + **kwargs + ) + + +def build_get_request( + configuration_profile_name, # type: str + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}') + path_format_arguments = { + "configurationProfileName": _SERIALIZER.url("configuration_profile_name", configuration_profile_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + 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, # type: str + configuration_profile_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "configurationProfileName": _SERIALIZER.url("configuration_profile_name", configuration_profile_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + 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_update_request( + configuration_profile_name, # type: str + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}') + path_format_arguments = { + "configurationProfileName": _SERIALIZER.url("configuration_profile_name", configuration_profile_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + 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="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + 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_by_subscription_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/configurationProfiles') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + 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 + ) + +# fmt: on +class ConfigurationProfilesOperations(object): + """ConfigurationProfilesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~automanage_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def create_or_update( + self, + configuration_profile_name, # type: str + resource_group_name, # type: str + parameters, # type: "_models.ConfigurationProfile" + **kwargs # type: Any + ): + # type: (...) -> "_models.ConfigurationProfile" + """Creates a configuration profile. + + :param configuration_profile_name: Name of the configuration profile. + :type configuration_profile_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to create or update configuration profile. + :type parameters: ~automanage_client.models.ConfigurationProfile + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationProfile, or the result of cls(response) + :rtype: ~automanage_client.models.ConfigurationProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfile"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ConfigurationProfile') + + request = build_create_or_update_request( + configuration_profile_name=configuration_profile_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_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) + + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ConfigurationProfile', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ConfigurationProfile', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}'} # type: ignore + + + @distributed_trace + def get( + self, + configuration_profile_name, # type: str + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.ConfigurationProfile" + """Get information about a configuration profile. + + :param configuration_profile_name: The configuration profile name. + :type configuration_profile_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationProfile, or the result of cls(response) + :rtype: ~automanage_client.models.ConfigurationProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfile"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + configuration_profile_name=configuration_profile_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConfigurationProfile', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}'} # type: ignore + + + @distributed_trace + def delete( + self, + resource_group_name, # type: str + configuration_profile_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Delete a configuration profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param configuration_profile_name: Name of the configuration profile. + :type configuration_profile_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + resource_group_name=resource_group_name, + configuration_profile_name=configuration_profile_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}'} # type: ignore + + + @distributed_trace + def update( + self, + configuration_profile_name, # type: str + resource_group_name, # type: str + parameters, # type: "_models.ConfigurationProfileUpdate" + **kwargs # type: Any + ): + # type: (...) -> "_models.ConfigurationProfile" + """Updates a configuration profile. + + :param configuration_profile_name: Name of the configuration profile. + :type configuration_profile_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to update configuration profile. + :type parameters: ~automanage_client.models.ConfigurationProfileUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationProfile, or the result of cls(response) + :rtype: ~automanage_client.models.ConfigurationProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfile"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ConfigurationProfileUpdate') + + request = build_update_request( + configuration_profile_name=configuration_profile_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConfigurationProfile', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}'} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ConfigurationProfileList"] + """Retrieve a list of configuration profile within a given resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :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 ConfigurationProfileList or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.ConfigurationProfileList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileList"] + 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_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_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("ConfigurationProfileList", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles'} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ConfigurationProfileList"] + """Retrieve a list of configuration profile within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConfigurationProfileList or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.ConfigurationProfileList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileList"] + 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_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_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("ConfigurationProfileList", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/configurationProfiles'} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profiles_versions_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profiles_versions_operations.py new file mode 100644 index 000000000000..2e6b7aae7237 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profiles_versions_operations.py @@ -0,0 +1,570 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import TYPE_CHECKING +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 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 +from .._vendor import _convert_request, _format_url_section + +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]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + configuration_profile_name, # type: str + version_name, # type: str + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions/{versionName}') + path_format_arguments = { + "configurationProfileName": _SERIALIZER.url("configuration_profile_name", configuration_profile_name, 'str'), + "versionName": _SERIALIZER.url("version_name", version_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + 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, + **kwargs + ) + + +def build_get_request( + configuration_profile_name, # type: str + version_name, # type: str + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions/{versionName}') + path_format_arguments = { + "configurationProfileName": _SERIALIZER.url("configuration_profile_name", configuration_profile_name, 'str'), + "versionName": _SERIALIZER.url("version_name", version_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + 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, # type: str + configuration_profile_name, # type: str + version_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions/{versionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "configurationProfileName": _SERIALIZER.url("configuration_profile_name", configuration_profile_name, 'str'), + "versionName": _SERIALIZER.url("version_name", version_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + 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_update_request( + configuration_profile_name, # type: str + version_name, # type: str + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions/{versionName}') + path_format_arguments = { + "configurationProfileName": _SERIALIZER.url("configuration_profile_name", configuration_profile_name, 'str'), + "versionName": _SERIALIZER.url("version_name", version_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + 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="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_child_resources_request( + configuration_profile_name, # type: str + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions') + path_format_arguments = { + "configurationProfileName": _SERIALIZER.url("configuration_profile_name", configuration_profile_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + 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 + ) + +# fmt: on +class ConfigurationProfilesVersionsOperations(object): + """ConfigurationProfilesVersionsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~automanage_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def create_or_update( + self, + configuration_profile_name, # type: str + version_name, # type: str + resource_group_name, # type: str + parameters, # type: "_models.ConfigurationProfile" + **kwargs # type: Any + ): + # type: (...) -> "_models.ConfigurationProfile" + """Creates a configuration profile version. + + :param configuration_profile_name: Name of the configuration profile. + :type configuration_profile_name: str + :param version_name: The configuration profile version name. + :type version_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to create or update configuration profile. + :type parameters: ~automanage_client.models.ConfigurationProfile + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationProfile, or the result of cls(response) + :rtype: ~automanage_client.models.ConfigurationProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfile"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ConfigurationProfile') + + request = build_create_or_update_request( + configuration_profile_name=configuration_profile_name, + version_name=version_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_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) + + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ConfigurationProfile', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ConfigurationProfile', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions/{versionName}'} # type: ignore + + + @distributed_trace + def get( + self, + configuration_profile_name, # type: str + version_name, # type: str + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.ConfigurationProfile" + """Get information about a configuration profile version. + + :param configuration_profile_name: The configuration profile name. + :type configuration_profile_name: str + :param version_name: The configuration profile version name. + :type version_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationProfile, or the result of cls(response) + :rtype: ~automanage_client.models.ConfigurationProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfile"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + configuration_profile_name=configuration_profile_name, + version_name=version_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConfigurationProfile', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions/{versionName}'} # type: ignore + + + @distributed_trace + def delete( + self, + resource_group_name, # type: str + configuration_profile_name, # type: str + version_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Delete a configuration profile version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param configuration_profile_name: Name of the configuration profile. + :type configuration_profile_name: str + :param version_name: The configuration profile version name. + :type version_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + resource_group_name=resource_group_name, + configuration_profile_name=configuration_profile_name, + version_name=version_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions/{versionName}'} # type: ignore + + + @distributed_trace + def update( + self, + configuration_profile_name, # type: str + version_name, # type: str + resource_group_name, # type: str + parameters, # type: "_models.ConfigurationProfileUpdate" + **kwargs # type: Any + ): + # type: (...) -> "_models.ConfigurationProfile" + """Updates a configuration profile version. + + :param configuration_profile_name: Name of the configuration profile. + :type configuration_profile_name: str + :param version_name: The configuration profile version name. + :type version_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to update configuration profile. + :type parameters: ~automanage_client.models.ConfigurationProfileUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationProfile, or the result of cls(response) + :rtype: ~automanage_client.models.ConfigurationProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfile"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ConfigurationProfileUpdate') + + request = build_update_request( + configuration_profile_name=configuration_profile_name, + version_name=version_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConfigurationProfile', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions/{versionName}'} # type: ignore + + + @distributed_trace + def list_child_resources( + self, + configuration_profile_name, # type: str + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ConfigurationProfileList"] + """Retrieve a list of configuration profile version for a configuration profile. + + :param configuration_profile_name: Name of the configuration profile. + :type configuration_profile_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :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 ConfigurationProfileList or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.ConfigurationProfileList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileList"] + 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_list_child_resources_request( + configuration_profile_name=configuration_profile_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_child_resources.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_child_resources_request( + configuration_profile_name=configuration_profile_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_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("ConfigurationProfileList", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_child_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions'} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_operations.py index 7aac97cd377a..2ff23e7e0dc3 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_operations.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_operations.py @@ -5,24 +5,58 @@ # 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 TYPE_CHECKING import warnings -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 +from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Automanage/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 + ) + +# fmt: on class Operations(object): """Operations operations. @@ -37,7 +71,7 @@ class Operations(object): :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): self._client = client @@ -45,44 +79,45 @@ 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"] + # type: (...) -> Iterable["_models.OperationListResult"] """Lists all of the available Automanage REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.OperationList] + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.OperationList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - 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("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -95,12 +130,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_reports_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_reports_operations.py new file mode 100644 index 000000000000..3f32dcbe27c7 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_reports_operations.py @@ -0,0 +1,273 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import TYPE_CHECKING +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 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 +from .._vendor import _convert_request, _format_url_section + +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]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + resource_group_name, # type: str + configuration_profile_assignment_name, # type: str + report_name, # type: str + subscription_id, # type: str + vm_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports/{reportName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "configurationProfileAssignmentName": _SERIALIZER.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), + "reportName": _SERIALIZER.url("report_name", report_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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_list_by_configuration_profile_assignments_request( + subscription_id, # type: str + resource_group_name, # type: str + configuration_profile_assignment_name, # type: str + vm_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "configurationProfileAssignmentName": _SERIALIZER.url("configuration_profile_assignment_name", configuration_profile_assignment_name, '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 + ) + +# fmt: on +class ReportsOperations(object): + """ReportsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~automanage_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get( + self, + resource_group_name, # type: str + configuration_profile_assignment_name, # type: str + report_name, # type: str + vm_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.Report" + """Get information about a report associated with a configuration profile assignment run. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param configuration_profile_assignment_name: The configuration profile assignment name. + :type configuration_profile_assignment_name: str + :param report_name: The report name. + :type report_name: str + :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: Report, or the result of cls(response) + :rtype: ~automanage_client.models.Report + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Report"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_group_name=resource_group_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + report_name=report_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) + + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Report', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports/{reportName}'} # type: ignore + + + @distributed_trace + def list_by_configuration_profile_assignments( + self, + resource_group_name, # type: str + configuration_profile_assignment_name, # type: str + vm_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ReportList"] + """Retrieve a list of reports within a given configuration profile assignment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param configuration_profile_assignment_name: The configuration profile assignment name. + :type configuration_profile_assignment_name: str + :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 ReportList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.ReportList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportList"] + 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_list_by_configuration_profile_assignments_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + vm_name=vm_name, + template_url=self.list_by_configuration_profile_assignments.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_configuration_profile_assignments_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + 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("ReportList", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_configuration_profile_assignments.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports'} # type: ignore