From 84d1079eae98b9e63565ce13c6b26c572268b55c Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Mon, 1 Aug 2022 19:25:00 -0700 Subject: [PATCH] [AutoRelease] t2-automanage-2022-08-01-93502(Do not merge) (#25479) * code and test * Update CHANGELOG.md Co-authored-by: PythonSdkPipelines Co-authored-by: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> --- .../azure-mgmt-automanage/CHANGELOG.md | 35 + .../azure-mgmt-automanage/MANIFEST.in | 3 +- .../azure-mgmt-automanage/README.md | 2 +- .../azure-mgmt-automanage/_meta.json | 11 + .../azure/mgmt/automanage/__init__.py | 12 +- .../mgmt/automanage/_automanage_client.py | 150 ++- .../azure/mgmt/automanage/_configuration.py | 31 +- .../azure/mgmt/automanage/_metadata.json | 56 - .../azure/mgmt/automanage/_patch.py | 19 + .../azure/mgmt/automanage/_vendor.py | 27 + .../azure/mgmt/automanage/_version.py | 2 +- .../azure/mgmt/automanage/aio/__init__.py | 12 +- .../mgmt/automanage/aio/_automanage_client.py | 157 +++ .../aio/_automanage_client_async.py | 78 -- ...nfiguration_async.py => _configuration.py} | 18 +- .../azure/mgmt/automanage/aio/_patch.py | 19 + .../automanage/aio/operations/__init__.py | 40 + .../operations/_best_practices_operations.py | 181 +++ .../_best_practices_versions_operations.py | 190 +++ ...guration_profile_assignments_operations.py | 698 +++++++++++ ...tion_profile_hci_assignments_operations.py | 256 ++++ ...ion_profile_hcrp_assignments_operations.py | 256 ++++ .../_configuration_profiles_operations.py | 482 +++++++ ...figuration_profiles_versions_operations.py | 347 ++++++ .../aio/operations/_hci_reports_operations.py | 211 ++++ .../operations/_hcrp_reports_operations.py | 211 ++++ .../automanage/aio/operations/_operations.py | 122 ++ .../mgmt/automanage/aio/operations/_patch.py | 19 + .../aio/operations/_reports_operations.py | 211 ++++ .../_service_principals_operations.py | 184 +++ .../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 ------- .../aio/operations_async/_operations_async.py | 102 -- .../azure/mgmt/automanage/models/__init__.py | 129 +- .../models/_automanage_client_enums.py | 58 +- .../azure/mgmt/automanage/models/_models.py | 760 ------------ .../mgmt/automanage/models/_models_py3.py | 1066 +++++++++------- .../azure/mgmt/automanage/models/_patch.py | 19 + .../mgmt/automanage/operations/__init__.py | 29 +- .../operations/_accounts_operations.py | 426 ------- .../operations/_best_practices_operations.py | 243 ++++ .../_best_practices_versions_operations.py | 260 ++++ ...guration_profile_assignments_operations.py | 1103 +++++++++++++---- ...tion_profile_hci_assignments_operations.py | 384 ++++++ ...ion_profile_hcrp_assignments_operations.py | 384 ++++++ ...guration_profile_preferences_operations.py | 426 ------- .../_configuration_profiles_operations.py | 714 +++++++++++ ...figuration_profiles_versions_operations.py | 510 ++++++++ .../operations/_hci_reports_operations.py | 293 +++++ .../operations/_hcrp_reports_operations.py | 293 +++++ .../mgmt/automanage/operations/_operations.py | 148 ++- .../mgmt/automanage/operations/_patch.py | 19 + .../operations/_reports_operations.py | 293 +++++ .../_service_principals_operations.py | 251 ++++ sdk/automanage/azure-mgmt-automanage/setup.py | 9 +- shared_requirements.txt | 2 + 58 files changed, 9190 insertions(+), 4043 deletions(-) create mode 100644 sdk/automanage/azure-mgmt-automanage/_meta.json delete mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_metadata.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} (76%) 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_profile_hci_assignments_operations.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_hcrp_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 create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_hci_reports_operations.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_hcrp_reports_operations.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_operations.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_patch.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_reports_operations.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_service_principals_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/aio/operations_async/_operations_async.py delete mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_patch.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 create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_hci_assignments_operations.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_hcrp_assignments_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/_hci_reports_operations.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_hcrp_reports_operations.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_patch.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_reports_operations.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_service_principals_operations.py diff --git a/sdk/automanage/azure-mgmt-automanage/CHANGELOG.md b/sdk/automanage/azure-mgmt-automanage/CHANGELOG.md index 5b18df47e51b..8d3ab113cd85 100644 --- a/sdk/automanage/azure-mgmt-automanage/CHANGELOG.md +++ b/sdk/automanage/azure-mgmt-automanage/CHANGELOG.md @@ -1,5 +1,40 @@ # Release History +## 1.0.0 (2022-08-02) + +**Features** + + - Added operation ConfigurationProfileAssignmentsOperations.create_or_update + - Added operation ConfigurationProfileAssignmentsOperations.list_by_cluster_name + - Added operation ConfigurationProfileAssignmentsOperations.list_by_machine_name + - Added operation ConfigurationProfileAssignmentsOperations.list_by_virtual_machines + - Added operation group BestPracticesOperations + - Added operation group BestPracticesVersionsOperations + - Added operation group ConfigurationProfileHCIAssignmentsOperations + - Added operation group ConfigurationProfileHCRPAssignmentsOperations + - Added operation group ConfigurationProfilesOperations + - Added operation group ConfigurationProfilesVersionsOperations + - Added operation group HCIReportsOperations + - Added operation group HCRPReportsOperations + - Added operation group ReportsOperations + - Added operation group ServicePrincipalsOperations + - Model ConfigurationProfileAssignment has a new parameter managed_by + - Model ConfigurationProfileAssignment has a new parameter system_data + - Model ConfigurationProfileAssignmentProperties has a new parameter status + - Model Operation has a new parameter action_type + - Model Operation has a new parameter origin + +**Breaking changes** + + - Model ConfigurationProfileAssignmentProperties no longer has parameter account_id + - Model ConfigurationProfileAssignmentProperties no longer has parameter compliance + - Model ConfigurationProfileAssignmentProperties no longer has parameter configuration_profile_preference_id + - Model ConfigurationProfileAssignmentProperties no longer has parameter provisioning_status + - Model Operation no longer has parameter status_code + - Removed operation ConfigurationProfileAssignmentsOperations.begin_create_or_update + - Removed operation group AccountsOperations + - Removed operation group ConfigurationProfilePreferencesOperations + ## 1.0.0b2 (2021-04-21) - Fix dependency for package diff --git a/sdk/automanage/azure-mgmt-automanage/MANIFEST.in b/sdk/automanage/azure-mgmt-automanage/MANIFEST.in index 2c31e8da0cb1..0647fc8b294c 100644 --- a/sdk/automanage/azure-mgmt-automanage/MANIFEST.in +++ b/sdk/automanage/azure-mgmt-automanage/MANIFEST.in @@ -1,6 +1,7 @@ include _meta.json -recursive-include tests *.py *.yaml +recursive-include tests *.py *.json include *.md include azure/__init__.py include azure/mgmt/__init__.py include LICENSE +include azure/mgmt/automanage/py.typed diff --git a/sdk/automanage/azure-mgmt-automanage/README.md b/sdk/automanage/azure-mgmt-automanage/README.md index 93127b0aad2e..84780897ecc2 100644 --- a/sdk/automanage/azure-mgmt-automanage/README.md +++ b/sdk/automanage/azure-mgmt-automanage/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Auto Manage Management Client Library. -This package has been tested with Python 3.6+. +This package has been tested with Python 3.7+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ diff --git a/sdk/automanage/azure-mgmt-automanage/_meta.json b/sdk/automanage/azure-mgmt-automanage/_meta.json new file mode 100644 index 000000000000..d81368e6a1d0 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.16.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "2dcad6d6e9a96882eb6d317e7500a94be007a9c6", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/automanage/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/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..6fe494b898f5 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/__init__.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/__init__.py @@ -10,10 +10,14 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AutomanageClient'] try: - from ._patch import patch_sdk - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import except ImportError: - pass + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['AutomanageClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_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..5720f7f3e430 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,145 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import AutomanageClientConfiguration -from .operations import AccountsOperations -from .operations import ConfigurationProfileAssignmentsOperations -from .operations import ConfigurationProfilePreferencesOperations -from .operations import Operations from . import models +from ._configuration import AutomanageClientConfiguration +from .operations import BestPracticesOperations, BestPracticesVersionsOperations, ConfigurationProfileAssignmentsOperations, ConfigurationProfileHCIAssignmentsOperations, ConfigurationProfileHCRPAssignmentsOperations, ConfigurationProfilesOperations, ConfigurationProfilesVersionsOperations, HCIReportsOperations, HCRPReportsOperations, Operations, ReportsOperations, ServicePrincipalsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class AutomanageClient(object): +class AutomanageClient: # pylint: disable=too-many-instance-attributes """Automanage Client. - :ivar accounts: AccountsOperations operations - :vartype accounts: automanage_client.operations.AccountsOperations + :ivar best_practices: BestPracticesOperations operations + :vartype best_practices: azure.mgmt.automanage.operations.BestPracticesOperations + :ivar best_practices_versions: BestPracticesVersionsOperations operations + :vartype best_practices_versions: + azure.mgmt.automanage.operations.BestPracticesVersionsOperations + :ivar configuration_profiles: ConfigurationProfilesOperations operations + :vartype configuration_profiles: + azure.mgmt.automanage.operations.ConfigurationProfilesOperations + :ivar configuration_profiles_versions: ConfigurationProfilesVersionsOperations operations + :vartype configuration_profiles_versions: + azure.mgmt.automanage.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: + azure.mgmt.automanage.operations.ConfigurationProfileAssignmentsOperations :ivar operations: Operations operations - :vartype operations: automanage_client.operations.Operations + :vartype operations: azure.mgmt.automanage.operations.Operations + :ivar reports: ReportsOperations operations + :vartype reports: azure.mgmt.automanage.operations.ReportsOperations + :ivar service_principals: ServicePrincipalsOperations operations + :vartype service_principals: azure.mgmt.automanage.operations.ServicePrincipalsOperations + :ivar configuration_profile_hcrp_assignments: ConfigurationProfileHCRPAssignmentsOperations + operations + :vartype configuration_profile_hcrp_assignments: + azure.mgmt.automanage.operations.ConfigurationProfileHCRPAssignmentsOperations + :ivar hcrp_reports: HCRPReportsOperations operations + :vartype hcrp_reports: azure.mgmt.automanage.operations.HCRPReportsOperations + :ivar configuration_profile_hci_assignments: ConfigurationProfileHCIAssignmentsOperations + operations + :vartype configuration_profile_hci_assignments: + azure.mgmt.automanage.operations.ConfigurationProfileHCIAssignmentsOperations + :ivar hci_reports: HCIReportsOperations operations + :vartype hci_reports: azure.mgmt.automanage.operations.HCIReportsOperations :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 + :keyword api_version: Api Version. Default value is "2022-05-04". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AutomanageClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + 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 = 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.accounts = AccountsOperations( - self._client, self._config, self._serialize, self._deserialize) + 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.configuration_profile_preferences = ConfigurationProfilePreferencesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.reports = ReportsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.service_principals = ServicePrincipalsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.configuration_profile_hcrp_assignments = ConfigurationProfileHCRPAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.hcrp_reports = HCRPReportsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.configuration_profile_hci_assignments = ConfigurationProfileHCIAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.hci_reports = HCIReportsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/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 + """ + + 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..965b7846ec99 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_configuration.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_configuration.py @@ -6,21 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AutomanageClientConfiguration(Configuration): +class AutomanageClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AutomanageClient. Note that all parameters used to create this instance are saved as instance @@ -30,26 +29,29 @@ class AutomanageClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-05-04". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AutomanageClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-05-04") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(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 = api_version + 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 +64,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 deleted file mode 100644 index 3ce69338c090..000000000000 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_metadata.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "chosen_version": "2020-06-30-preview", - "total_api_version_list": ["2020-06-30-preview"], - "client": { - "name": "AutomanageClient", - "filename": "_automanage_client", - "description": "Automanage Client." - }, - "global_parameters": { - "sync_method": { - "credential": { - "method_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", - "description": "The ID of the target subscription.", - "docstring_type": "str", - "required": true - } - }, - "async_method": { - "credential": { - "method_signature": "credential, # type: \"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", - "description": "The ID of the target subscription.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id" - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"] - }, - "operation_groups": { - "accounts": "AccountsOperations", - "configuration_profile_assignments": "ConfigurationProfileAssignmentsOperations", - "configuration_profile_preferences": "ConfigurationProfilePreferencesOperations", - "operations": "Operations" - }, - "operation_mixins": { - }, - "sync_imports": "None", - "async_imports": "None" -} \ 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..0ad201a8c586 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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..c47f66669f1b 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.0" 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..7c25a329f2e7 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,15 @@ # 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 + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['AutomanageClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_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..242a5700b990 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_automanage_client.py @@ -0,0 +1,157 @@ +# 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, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ._configuration import AutomanageClientConfiguration +from .operations import BestPracticesOperations, BestPracticesVersionsOperations, ConfigurationProfileAssignmentsOperations, ConfigurationProfileHCIAssignmentsOperations, ConfigurationProfileHCRPAssignmentsOperations, ConfigurationProfilesOperations, ConfigurationProfilesVersionsOperations, HCIReportsOperations, HCRPReportsOperations, Operations, ReportsOperations, ServicePrincipalsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class AutomanageClient: # pylint: disable=too-many-instance-attributes + """Automanage Client. + + :ivar best_practices: BestPracticesOperations operations + :vartype best_practices: azure.mgmt.automanage.aio.operations.BestPracticesOperations + :ivar best_practices_versions: BestPracticesVersionsOperations operations + :vartype best_practices_versions: + azure.mgmt.automanage.aio.operations.BestPracticesVersionsOperations + :ivar configuration_profiles: ConfigurationProfilesOperations operations + :vartype configuration_profiles: + azure.mgmt.automanage.aio.operations.ConfigurationProfilesOperations + :ivar configuration_profiles_versions: ConfigurationProfilesVersionsOperations operations + :vartype configuration_profiles_versions: + azure.mgmt.automanage.aio.operations.ConfigurationProfilesVersionsOperations + :ivar configuration_profile_assignments: ConfigurationProfileAssignmentsOperations operations + :vartype configuration_profile_assignments: + azure.mgmt.automanage.aio.operations.ConfigurationProfileAssignmentsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.automanage.aio.operations.Operations + :ivar reports: ReportsOperations operations + :vartype reports: azure.mgmt.automanage.aio.operations.ReportsOperations + :ivar service_principals: ServicePrincipalsOperations operations + :vartype service_principals: azure.mgmt.automanage.aio.operations.ServicePrincipalsOperations + :ivar configuration_profile_hcrp_assignments: ConfigurationProfileHCRPAssignmentsOperations + operations + :vartype configuration_profile_hcrp_assignments: + azure.mgmt.automanage.aio.operations.ConfigurationProfileHCRPAssignmentsOperations + :ivar hcrp_reports: HCRPReportsOperations operations + :vartype hcrp_reports: azure.mgmt.automanage.aio.operations.HCRPReportsOperations + :ivar configuration_profile_hci_assignments: ConfigurationProfileHCIAssignmentsOperations + operations + :vartype configuration_profile_hci_assignments: + azure.mgmt.automanage.aio.operations.ConfigurationProfileHCIAssignmentsOperations + :ivar hci_reports: HCIReportsOperations operations + :vartype hci_reports: azure.mgmt.automanage.aio.operations.HCIReportsOperations + :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 + :keyword api_version: Api Version. Default value is "2022-05-04". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: 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 + ) + self.service_principals = ServicePrincipalsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.configuration_profile_hcrp_assignments = ConfigurationProfileHCRPAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.hcrp_reports = HCRPReportsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.configuration_profile_hci_assignments = ConfigurationProfileHCIAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.hci_reports = HCIReportsOperations( + 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 76% 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..ea5c24edf3b8 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 @@ -18,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AutomanageClientConfiguration(Configuration): +class AutomanageClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AutomanageClient. Note that all parameters used to create this instance are saved as instance @@ -28,6 +29,9 @@ class AutomanageClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-05-04". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -36,17 +40,18 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AutomanageClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-05-04") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(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 = api_version + 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 +63,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..0ad201a8c586 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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..01ab8455817b --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/__init__.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._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 +from ._service_principals_operations import ServicePrincipalsOperations +from ._configuration_profile_hcrp_assignments_operations import ConfigurationProfileHCRPAssignmentsOperations +from ._hcrp_reports_operations import HCRPReportsOperations +from ._configuration_profile_hci_assignments_operations import ConfigurationProfileHCIAssignmentsOperations +from ._hci_reports_operations import HCIReportsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'BestPracticesOperations', + 'BestPracticesVersionsOperations', + 'ConfigurationProfilesOperations', + 'ConfigurationProfilesVersionsOperations', + 'ConfigurationProfileAssignmentsOperations', + 'Operations', + 'ReportsOperations', + 'ServicePrincipalsOperations', + 'ConfigurationProfileHCRPAssignmentsOperations', + 'HCRPReportsOperations', + 'ConfigurationProfileHCIAssignmentsOperations', + 'HCIReportsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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..d50d06b1deea --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_best_practices_operations.py @@ -0,0 +1,181 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._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: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.aio.AutomanageClient`'s + :attr:`best_practices` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + 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: ~azure.mgmt.automanage.models.BestPractice + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BestPractice] + + + request = build_get_request( + best_practice_name=best_practice_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('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[~azure.mgmt.automanage.models.BestPracticeList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BestPracticeList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_tenant_request( + api_version=api_version, + template_url=self.list_by_tenant.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_tenant_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_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..fb7c825dad62 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_best_practices_versions_operations.py @@ -0,0 +1,190 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._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: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.aio.AutomanageClient`'s + :attr:`best_practices_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + 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: ~azure.mgmt.automanage.models.BestPractice + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BestPractice] + + + request = build_get_request( + best_practice_name=best_practice_name, + version_name=version_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('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[~azure.mgmt.automanage.models.BestPracticeList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BestPracticeList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_tenant_request( + best_practice_name=best_practice_name, + api_version=api_version, + template_url=self.list_by_tenant.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_tenant_request( + best_practice_name=best_practice_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_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..b5c1abd6285d --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_assignments_operations.py @@ -0,0 +1,698 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._configuration_profile_assignments_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_cluster_name_request, build_list_by_machine_name_request, build_list_by_subscription_request, build_list_by_virtual_machines_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ConfigurationProfileAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.aio.AutomanageClient`'s + :attr:`configuration_profile_assignments` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def 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: ~azure.mgmt.automanage.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: ~azure.mgmt.automanage.models.ConfigurationProfileAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileAssignment] + + _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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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: ~azure.mgmt.automanage.models.ConfigurationProfileAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileAssignment] + + + 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, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('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( # pylint: disable=inconsistent-return-statements + 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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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_by_virtual_machines( + self, + resource_group_name: str, + vm_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 + :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 ConfigurationProfileAssignmentList or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automanage.models.ConfigurationProfileAssignmentList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileAssignmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_virtual_machines_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vm_name=vm_name, + api_version=api_version, + template_url=self.list_by_virtual_machines.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_virtual_machines_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vm_name=vm_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_virtual_machines.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments"} # 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[~azure.mgmt.automanage.models.ConfigurationProfileAssignmentList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileAssignmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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[~azure.mgmt.automanage.models.ConfigurationProfileAssignmentList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileAssignmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/configurationProfileAssignments"} # type: ignore + + @distributed_trace + def list_by_machine_name( + self, + resource_group_name: str, + machine_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 + :param machine_name: The name of the Arc machine. + :type machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConfigurationProfileAssignmentList or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automanage.models.ConfigurationProfileAssignmentList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileAssignmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_machine_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + machine_name=machine_name, + api_version=api_version, + template_url=self.list_by_machine_name.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_machine_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + machine_name=machine_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_machine_name.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments"} # type: ignore + + @distributed_trace + def list_by_cluster_name( + self, + resource_group_name: str, + cluster_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 + :param cluster_name: The name of the Arc machine. + :type cluster_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[~azure.mgmt.automanage.models.ConfigurationProfileAssignmentList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileAssignmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_cluster_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + api_version=api_version, + template_url=self.list_by_cluster_name.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_cluster_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_cluster_name.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments"} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_hci_assignments_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_hci_assignments_operations.py new file mode 100644 index 000000000000..ec6cbe1e365f --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_hci_assignments_operations.py @@ -0,0 +1,256 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._configuration_profile_hci_assignments_operations import build_create_or_update_request, build_delete_request, build_get_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ConfigurationProfileHCIAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.aio.AutomanageClient`'s + :attr:`configuration_profile_hci_assignments` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + cluster_name: str, + configuration_profile_assignment_name: str, + parameters: _models.ConfigurationProfileAssignment, + **kwargs: Any + ) -> _models.ConfigurationProfileAssignment: + """Creates an association between a AzureStackHCI cluster and Automanage configuration profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_name: The name of the Arc machine. + :type cluster_name: str + :param configuration_profile_assignment_name: Name of the configuration profile assignment. + Only default is supported. + :type configuration_profile_assignment_name: str + :param parameters: Parameters supplied to the create or update configuration profile + assignment. + :type parameters: ~azure.mgmt.automanage.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: ~azure.mgmt.automanage.models.ConfigurationProfileAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileAssignment] + + _json = self._serialize.body(parameters, 'ConfigurationProfileAssignment') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}"} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_name: str, + configuration_profile_assignment_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 cluster_name: The name of the Arc machine. + :type cluster_name: str + :param configuration_profile_assignment_name: The configuration profile assignment name. + :type configuration_profile_assignment_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: ~azure.mgmt.automanage.models.ConfigurationProfileAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileAssignment] + + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cluster_name=cluster_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_name: str, + configuration_profile_assignment_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 cluster_name: The name of the Arc machine. + :type cluster_name: str + :param configuration_profile_assignment_name: Name of the configuration profile assignment. + :type configuration_profile_assignment_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}"} # type: ignore + diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_hcrp_assignments_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_hcrp_assignments_operations.py new file mode 100644 index 000000000000..a3e1489936cc --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_hcrp_assignments_operations.py @@ -0,0 +1,256 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._configuration_profile_hcrp_assignments_operations import build_create_or_update_request, build_delete_request, build_get_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ConfigurationProfileHCRPAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.aio.AutomanageClient`'s + :attr:`configuration_profile_hcrp_assignments` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + machine_name: str, + configuration_profile_assignment_name: str, + parameters: _models.ConfigurationProfileAssignment, + **kwargs: Any + ) -> _models.ConfigurationProfileAssignment: + """Creates an association between a ARC machine and Automanage configuration profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param machine_name: The name of the Arc machine. + :type machine_name: str + :param configuration_profile_assignment_name: Name of the configuration profile assignment. + Only default is supported. + :type configuration_profile_assignment_name: str + :param parameters: Parameters supplied to the create or update configuration profile + assignment. + :type parameters: ~azure.mgmt.automanage.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: ~azure.mgmt.automanage.models.ConfigurationProfileAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileAssignment] + + _json = self._serialize.body(parameters, 'ConfigurationProfileAssignment') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + machine_name=machine_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}"} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + machine_name: str, + configuration_profile_assignment_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 machine_name: The name of the Arc machine. + :type machine_name: str + :param configuration_profile_assignment_name: The configuration profile assignment name. + :type configuration_profile_assignment_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: ~azure.mgmt.automanage.models.ConfigurationProfileAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileAssignment] + + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + machine_name=machine_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + machine_name: str, + configuration_profile_assignment_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 machine_name: The name of the Arc machine. + :type machine_name: str + :param configuration_profile_assignment_name: Name of the configuration profile assignment. + :type configuration_profile_assignment_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + machine_name=machine_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}"} # 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..09dab00f833d --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profiles_operations.py @@ -0,0 +1,482 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._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: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.aio.AutomanageClient`'s + :attr:`configuration_profiles` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @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: ~azure.mgmt.automanage.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: ~azure.mgmt.automanage.models.ConfigurationProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfile] + + _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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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: ~azure.mgmt.automanage.models.ConfigurationProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfile] + + + request = build_get_request( + configuration_profile_name=configuration_profile_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('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( # pylint: disable=inconsistent-return-statements + 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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + configuration_profile_name=configuration_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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: ~azure.mgmt.automanage.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: ~azure.mgmt.automanage.models.ConfigurationProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfile] + + _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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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[~azure.mgmt.automanage.models.ConfigurationProfileList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_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[~azure.mgmt.automanage.models.ConfigurationProfileList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_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..312a31673f45 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profiles_versions_operations.py @@ -0,0 +1,347 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._configuration_profiles_versions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_child_resources_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ConfigurationProfilesVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.aio.AutomanageClient`'s + :attr:`configuration_profiles_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def 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: ~azure.mgmt.automanage.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: ~azure.mgmt.automanage.models.ConfigurationProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfile] + + _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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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: ~azure.mgmt.automanage.models.ConfigurationProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfile] + + + 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, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('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( # pylint: disable=inconsistent-return-statements + 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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 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[~azure.mgmt.automanage.models.ConfigurationProfileList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_child_resources_request( + configuration_profile_name=configuration_profile_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_child_resources.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_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/_hci_reports_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_hci_reports_operations.py new file mode 100644 index 000000000000..7348cd6cd611 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_hci_reports_operations.py @@ -0,0 +1,211 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._hci_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 HCIReportsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.aio.AutomanageClient`'s + :attr:`hci_reports` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_name: str, + configuration_profile_assignment_name: str, + report_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 cluster_name: The name of the Arc machine. + :type cluster_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Report, or the result of cls(response) + :rtype: ~azure.mgmt.automanage.models.Report + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Report] + + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cluster_name=cluster_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + report_name=report_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Report', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports/{reportName}"} # type: ignore + + + @distributed_trace + def list_by_configuration_profile_assignments( + self, + resource_group_name: str, + cluster_name: str, + configuration_profile_assignment_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 cluster_name: The name of the Arc machine. + :type cluster_name: str + :param configuration_profile_assignment_name: The configuration profile assignment name. + :type configuration_profile_assignment_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[~azure.mgmt.automanage.models.ReportList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReportList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_configuration_profile_assignments_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + api_version=api_version, + template_url=self.list_by_configuration_profile_assignments.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_configuration_profile_assignments_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_configuration_profile_assignments.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports"} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_hcrp_reports_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_hcrp_reports_operations.py new file mode 100644 index 000000000000..be4c2f2db539 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_hcrp_reports_operations.py @@ -0,0 +1,211 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._hcrp_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 HCRPReportsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.aio.AutomanageClient`'s + :attr:`hcrp_reports` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + machine_name: str, + configuration_profile_assignment_name: str, + report_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 machine_name: The name of the Arc machine. + :type machine_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Report, or the result of cls(response) + :rtype: ~azure.mgmt.automanage.models.Report + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Report] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + machine_name=machine_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + report_name=report_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Report', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports/{reportName}"} # type: ignore + + + @distributed_trace + def list_by_configuration_profile_assignments( + self, + resource_group_name: str, + machine_name: str, + configuration_profile_assignment_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 machine_name: The name of the Arc machine. + :type machine_name: str + :param configuration_profile_assignment_name: The configuration profile assignment name. + :type configuration_profile_assignment_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[~azure.mgmt.automanage.models.ReportList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReportList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_configuration_profile_assignments_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + machine_name=machine_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + api_version=api_version, + template_url=self.list_by_configuration_profile_assignments.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_configuration_profile_assignments_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + machine_name=machine_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_configuration_profile_assignments.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports"} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_operations.py new file mode 100644 index 000000000000..e5f669686a03 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_operations.py @@ -0,0 +1,122 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.aio.AutomanageClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable[_models.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 OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automanage.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Automanage/operations"} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_patch.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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..198a9ad35a11 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_reports_operations.py @@ -0,0 +1,211 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._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: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.aio.AutomanageClient`'s + :attr:`reports` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + 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: ~azure.mgmt.automanage.models.Report + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Report] + + + 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, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('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[~azure.mgmt.automanage.models.ReportList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReportList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_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, + api_version=api_version, + template_url=self.list_by_configuration_profile_assignments.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_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/_service_principals_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_service_principals_operations.py new file mode 100644 index 000000000000..79a2b996c6cb --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_service_principals_operations.py @@ -0,0 +1,184 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._service_principals_operations import build_get_request, build_list_by_subscription_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ServicePrincipalsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.aio.AutomanageClient`'s + :attr:`service_principals` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ServicePrincipalListResult]: + """Get the Automanage AAD first party Application Service Principal details for the subscription + id. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServicePrincipalListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automanage.models.ServicePrincipalListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServicePrincipalListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ServicePrincipalListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/servicePrincipals"} # type: ignore + + @distributed_trace_async + async def get( + self, + **kwargs: Any + ) -> _models.ServicePrincipal: + """Get the Automanage AAD first party Application Service Principal details for the subscription + id. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServicePrincipal, or the result of cls(response) + :rtype: ~azure.mgmt.automanage.models.ServicePrincipal + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServicePrincipal] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ServicePrincipal', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/servicePrincipals/default"} # 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/aio/operations_async/_operations_async.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_operations_async.py deleted file mode 100644 index a584b47e9553..000000000000 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_operations_async.py +++ /dev/null @@ -1,102 +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 -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 Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :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 - - def list( - self, - **kwargs - ) -> AsyncIterable["models.OperationList"]: - """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] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.OperationList"] - 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 - # 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('OperationList', 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': '/providers/Microsoft.Automanage/operations'} # 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..7b0d818567b5 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 @@ -6,97 +6,70 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -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 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 ErrorAdditionalInfo - 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 ProxyResource - from ._models_py3 import Resource - 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 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 ErrorAdditionalInfo # 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 ProxyResource # type: ignore - from ._models import Resource # type: ignore - from ._models import TrackedResource # type: ignore - from ._models import UpdateResource # type: ignore +from ._models_py3 import BestPractice +from ._models_py3 import BestPracticeList +from ._models_py3 import ConfigurationProfile +from ._models_py3 import ConfigurationProfileAssignment +from ._models_py3 import ConfigurationProfileAssignmentList +from ._models_py3 import ConfigurationProfileAssignmentProperties +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 Operation +from ._models_py3 import OperationDisplay +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 ServicePrincipal +from ._models_py3 import ServicePrincipalListResult +from ._models_py3 import SystemData +from ._models_py3 import TrackedResource +from ._models_py3 import UpdateResource + from ._automanage_client_enums import ( - ConfigurationProfile, - EnableRealTimeProtection, - ProvisioningStatus, - ResourceIdentityType, - RunScheduledScan, - ScanType, - UpdateStatus, + ActionType, + CreatedByType, + Origin, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - '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', + 'ServicePrincipal', + 'ServicePrincipalListResult', + 'SystemData', 'TrackedResource', 'UpdateResource', - 'ConfigurationProfile', - 'EnableRealTimeProtection', - 'ProvisioningStatus', - 'ResourceIdentityType', - 'RunScheduledScan', - 'ScanType', - 'UpdateStatus', + 'ActionType', + 'CreatedByType', + 'Origin', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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..5417184a81d3 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,29 @@ # -------------------------------------------------------------------------- from enum import Enum +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(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """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(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """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(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system" """ - 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 deleted file mode 100644 index 4a02132654d4..000000000000 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models.py +++ /dev/null @@ -1,760 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class Resource(msrest.serialization.Model): - """Resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class TrackedResource(Resource): - """The resource model definition for a ARM tracked top level resource. - - 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 - """ - - _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'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.location = kwargs['location'] - - -class Account(TrackedResource): - """Definition of the Automanage account. - - 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 identity: The identity of the Automanage account. - :type identity: ~automanage_client.models.AccountIdentity - """ - - _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'}, - 'identity': {'key': 'identity', 'type': 'AccountIdentity'}, - } - - def __init__( - self, - **kwargs - ): - super(Account, self).__init__(**kwargs) - self.identity = kwargs.get('identity', None) - - -class AccountIdentity(msrest.serialization.Model): - """Identity for the Automanage account. - - 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 - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - 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) - - -class ConfigurationProfileAssignment(Resource): - """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 - - /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 properties: Properties of the configuration profile assignment. - :type properties: ~automanage_client.models.ConfigurationProfileAssignmentProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ConfigurationProfileAssignmentProperties'}, - } - - def __init__( - self, - **kwargs - ): - 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 - - -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] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ConfigurationProfileAssignment]'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfigurationProfileAssignmentList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ConfigurationProfileAssignmentProperties(msrest.serialization.Model): - """Automanage configuration profile assignment properties. - - 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 - """ - - _validation = { - 'provisioning_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'}, - } - - def __init__( - self, - **kwargs - ): - 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) - - -class ConfigurationProfilePreferenceList(msrest.serialization.Model): - """The response of the list ConfigurationProfilePreference operation. - - :param value: Result of the list ConfigurationProfilePreference operation. - :type value: list[~automanage_client.models.ConfigurationProfilePreference] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ConfigurationProfilePreference]'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfigurationProfilePreferenceList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ConfigurationProfilePreferenceProperties(msrest.serialization.Model): - """Automanage configuration profile preference 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 - """ - - _attribute_map = { - 'vm_backup': {'key': 'vmBackup', 'type': 'ConfigurationProfilePreferenceVmBackup'}, - 'anti_malware': {'key': 'antiMalware', 'type': 'ConfigurationProfilePreferenceAntiMalware'}, - } - - 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) - - -class ConfigurationProfilePreferenceUpdate(UpdateResource): - """Definition of the configuration profile preference. - - :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 - """ - - _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) - - -class ConfigurationProfilePreferenceVmBackup(msrest.serialization.Model): - """Automanage configuration profile VM Backup preferences. - - :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 - """ - - _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'}, - } - - 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) - - -class ErrorAdditionalInfo(msrest.serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: object - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - 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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~automanage_client.models.ErrorResponse] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~automanage_client.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponseError, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = 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 - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'status_code': {'key': 'properties.statusCode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.is_data_action = kwargs.get('is_data_action', None) - self.display = kwargs.get('display', None) - self.status_code = kwargs.get('status_code', None) - - -class OperationDisplay(msrest.serialization.Model): - """Provider, Resource, Operation and description values. - - :param provider: Service provider: Microsoft.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 - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationList(msrest.serialization.Model): - """The response model for the list of Automanage operations. - - :param value: List of Automanage operations supported by the Automanage resource provider. - :type value: list[~automanage_client.models.Operation] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ProxyResource(Resource): - """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProxyResource, self).__init__(**kwargs) 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..1381919bcff9 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,26 +6,106 @@ # 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, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._automanage_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + + +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: ~azure.mgmt.automanage.models.SystemData + :ivar configuration: configuration dictionary of the configuration profile. + :vartype configuration: 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'}, + } + + def __init__( + self, + *, + configuration: Optional[Any] = None, + **kwargs + ): + """ + :keyword configuration: configuration dictionary of the configuration profile. + :paramtype configuration: any + """ + super(BestPractice, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.system_data = None + self.configuration = configuration + + +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[~azure.mgmt.automanage.models.BestPractice] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[BestPractice]'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.BestPractice"]] = None, + **kwargs + ): + """ + :keyword value: Result of the list best practice operation. + :paramtype value: list[~azure.mgmt.automanage.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 +125,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -52,24 +134,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 +176,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: ~azure.mgmt.automanage.models.ConfigurationProfileProperties + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.automanage.models.SystemData """ _validation = { @@ -127,6 +218,7 @@ class Account(TrackedResource): 'name': {'readonly': True}, 'type': {'readonly': True}, 'location': {'required': True}, + 'system_data': {'readonly': True}, } _attribute_map = { @@ -135,7 +227,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 +236,87 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["AccountIdentity"] = None, + properties: Optional["_models.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: ~azure.mgmt.automanage.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: ~azure.mgmt.automanage.models.ConfigurationProfileAssignmentProperties + :ivar managed_by: Azure resource id. Indicates if this resource is managed by another Azure + resource. + :vartype managed_by: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.automanage.models.SystemData """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'managed_by': {'readonly': True}, + 'system_data': {'readonly': True}, } _attribute_map = { @@ -283,49 +324,31 @@ class ConfigurationProfileAssignment(Resource): 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'properties': {'key': 'properties', 'type': 'ConfigurationProfileAssignmentProperties'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__( self, *, - properties: Optional["ConfigurationProfileAssignmentProperties"] = None, + properties: Optional["_models.ConfigurationProfileAssignmentProperties"] = None, **kwargs ): + """ + :keyword properties: Properties of the configuration profile assignment. + :paramtype properties: ~azure.mgmt.automanage.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.managed_by = 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[~azure.mgmt.automanage.models.ConfigurationProfileAssignment] """ _attribute_map = { @@ -335,9 +358,13 @@ class ConfigurationProfileAssignmentList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ConfigurationProfileAssignment"]] = None, + value: Optional[List["_models.ConfigurationProfileAssignment"]] = None, **kwargs ): + """ + :keyword value: Result of the list configuration profile assignment operation. + :paramtype value: list[~azure.mgmt.automanage.models.ConfigurationProfileAssignment] + """ super(ConfigurationProfileAssignmentList, self).__init__(**kwargs) self.value = value @@ -347,261 +374,145 @@ 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 """ _validation = { - 'provisioning_status': {'readonly': True}, + 'target_id': {'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'}, } def __init__( self, *, - configuration_profile: Optional[Union[str, "ConfigurationProfile"]] = None, - target_id: Optional[str] = None, - account_id: Optional[str] = None, - configuration_profile_preference_id: Optional[str] = None, - compliance: Optional["ConfigurationProfileAssignmentCompliance"] = None, + configuration_profile: Optional[str] = None, **kwargs ): + """ + :keyword configuration_profile: The Automanage configurationProfile ARM Resource URI. + :paramtype configuration_profile: str + """ 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.target_id = None + self.status = 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[~azure.mgmt.automanage.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["_models.ConfigurationProfile"]] = None, **kwargs ): - super(ConfigurationProfilePreferenceList, self).__init__(**kwargs) + """ + :keyword value: Result of the list ConfigurationProfile operation. + :paramtype value: list[~azure.mgmt.automanage.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 """ _attribute_map = { - 'vm_backup': {'key': 'vmBackup', 'type': 'ConfigurationProfilePreferenceVmBackup'}, - 'anti_malware': {'key': 'antiMalware', 'type': 'ConfigurationProfilePreferenceAntiMalware'}, + 'configuration': {'key': 'configuration', 'type': 'object'}, } def __init__( self, *, - vm_backup: Optional["ConfigurationProfilePreferenceVmBackup"] = None, - anti_malware: Optional["ConfigurationProfilePreferenceAntiMalware"] = None, + configuration: Optional[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 + """ + super(ConfigurationProfileProperties, self).__init__(**kwargs) + self.configuration = configuration -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: ~azure.mgmt.automanage.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["_models.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: ~azure.mgmt.automanage.models.ConfigurationProfileProperties + """ + super(ConfigurationProfileUpdate, self).__init__(tags=tags, **kwargs) + self.properties = properties class ErrorAdditionalInfo(msrest.serialization.Model): @@ -612,7 +523,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 +540,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,9 +559,9 @@ 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[~azure.mgmt.automanage.models.ErrorDetail] :ivar additional_info: The error additional info. - :vartype additional_info: list[~automanage_client.models.ErrorAdditionalInfo] + :vartype additional_info: list[~azure.mgmt.automanage.models.ErrorAdditionalInfo] """ _validation = { @@ -684,7 +576,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 +584,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 +594,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: ~azure.mgmt.automanage.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + **kwargs + ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.automanage.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: ~azure.mgmt.automanage.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + "user,system". + :vartype origin: str or ~azure.mgmt.automanage.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Known values are: "Internal". + :vartype action_type: str or ~azure.mgmt.automanage.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, + display: Optional["_models.OperationDisplay"] = None, **kwargs ): + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.automanage.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 +709,358 @@ 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. - :param value: List of Automanage operations supported by the Automanage resource provider. - :type value: list[~automanage_client.models.Operation] + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.automanage.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(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +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 - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.automanage.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[~azure.mgmt.automanage.models.ReportResource] + :ivar error: Error message, if any, returned by the configuration profile assignment + processing. + :vartype error: ~azure.mgmt.automanage.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, *, - value: Optional[List["Operation"]] = None, + start_time: Optional[str] = None, + end_time: Optional[str] = None, **kwargs ): - super(OperationList, 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[~azure.mgmt.automanage.models.Report] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Report]'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.Report"]] = None, + **kwargs + ): + """ + :keyword value: Result of the list report operation. + :paramtype value: list[~azure.mgmt.automanage.models.Report] + """ + super(ReportList, self).__init__(**kwargs) self.value = value -class ProxyResource(Resource): - """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. +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: ~azure.mgmt.automanage.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 ServicePrincipal(ProxyResource): + """The Service Principal Id for the subscription. 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: ~azure.mgmt.automanage.models.SystemData + :ivar service_principal_id: The Service Principal Id for the subscription. + :vartype service_principal_id: str + :ivar authorization_set: Returns the contributor RBAC Role exist or not for the Service + Principal Id. + :vartype authorization_set: bool """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'service_principal_id': {'readonly': True}, + 'authorization_set': {'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'}, + 'service_principal_id': {'key': 'properties.servicePrincipalId', 'type': 'str'}, + 'authorization_set': {'key': 'properties.authorizationSet', 'type': 'bool'}, } def __init__( self, **kwargs ): - super(ProxyResource, self).__init__(**kwargs) + """ + """ + super(ServicePrincipal, self).__init__(**kwargs) + self.system_data = None + self.service_principal_id = None + self.authorization_set = None + + +class ServicePrincipalListResult(msrest.serialization.Model): + """The list of ServicePrincipals. + + :ivar value: The list of servicePrincipals. + :vartype value: list[~azure.mgmt.automanage.models.ServicePrincipal] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ServicePrincipal]'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ServicePrincipal"]] = None, + **kwargs + ): + """ + :keyword value: The list of servicePrincipals. + :paramtype value: list[~azure.mgmt.automanage.models.ServicePrincipal] + """ + super(ServicePrincipalListResult, self).__init__(**kwargs) + self.value = value + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.automanage.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.automanage.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.automanage.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.automanage.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/models/_patch.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/__init__.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/__init__.py index 9520dfd09e18..01ab8455817b 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,35 @@ # 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 +from ._service_principals_operations import ServicePrincipalsOperations +from ._configuration_profile_hcrp_assignments_operations import ConfigurationProfileHCRPAssignmentsOperations +from ._hcrp_reports_operations import HCRPReportsOperations +from ._configuration_profile_hci_assignments_operations import ConfigurationProfileHCIAssignmentsOperations +from ._hci_reports_operations import HCIReportsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AccountsOperations', + 'BestPracticesOperations', + 'BestPracticesVersionsOperations', + 'ConfigurationProfilesOperations', + 'ConfigurationProfilesVersionsOperations', 'ConfigurationProfileAssignmentsOperations', - 'ConfigurationProfilePreferencesOperations', 'Operations', + 'ReportsOperations', + 'ServicePrincipalsOperations', + 'ConfigurationProfileHCRPAssignmentsOperations', + 'HCRPReportsOperations', + 'ConfigurationProfileHCIAssignmentsOperations', + 'HCIReportsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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..10aa33c50afb --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_best_practices_operations.py @@ -0,0 +1,243 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + best_practice_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_tenant_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Automanage/bestPractices") + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class BestPracticesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.AutomanageClient`'s + :attr:`best_practices` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + 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: ~azure.mgmt.automanage.models.BestPractice + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BestPractice] + + + request = build_get_request( + best_practice_name=best_practice_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('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 + ) -> 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[~azure.mgmt.automanage.models.BestPracticeList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BestPracticeList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_tenant_request( + api_version=api_version, + template_url=self.list_by_tenant.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_tenant_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_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..3dd5cd47d601 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_best_practices_versions_operations.py @@ -0,0 +1,260 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + best_practice_name: str, + version_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Automanage/bestPractices/{bestPracticeName}/versions/{versionName}") # pylint: disable=line-too-long + 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_tenant_request( + best_practice_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class BestPracticesVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.AutomanageClient`'s + :attr:`best_practices_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + 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: ~azure.mgmt.automanage.models.BestPractice + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BestPractice] + + + request = build_get_request( + best_practice_name=best_practice_name, + version_name=version_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('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 + ) -> 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[~azure.mgmt.automanage.models.BestPracticeList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BestPracticeList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_tenant_request( + best_practice_name=best_practice_name, + api_version=api_version, + template_url=self.list_by_tenant.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_tenant_request( + best_practice_name=best_practice_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_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..c5bc7860e591 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,93 +6,415 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.core.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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models - -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 ConfigurationProfileAssignmentsOperations(object): - """ConfigurationProfileAssignmentsOperations 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. +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + configuration_profile_assignment_name: str, + subscription_id: str, + resource_group_name: str, + vm_name: str, + *, + json: Optional[_models.ConfigurationProfileAssignment] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}") # pylint: disable=line-too-long + 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + configuration_profile_assignment_name: str, + subscription_id: str, + vm_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}") # pylint: disable=line-too-long + 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + configuration_profile_assignment_name: str, + subscription_id: str, + vm_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}") # pylint: disable=line-too-long + 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_virtual_machines_request( + subscription_id: str, + resource_group_name: str, + vm_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "vmName": _SERIALIZER.url("vm_name", vm_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfileAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/configurationProfileAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_machine_name_request( + subscription_id: str, + resource_group_name: str, + machine_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "machineName": _SERIALIZER.url("machine_name", machine_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_cluster_name_request( + subscription_id: str, + resource_group_name: str, + cluster_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ConfigurationProfileAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :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. + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.AutomanageClient`'s + :attr:`configuration_profile_assignments` attribute. """ - models = models + models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def _create_or_update_initial( - self, - configuration_profile_assignment_name, # type: str - resource_group_name, # type: str - vm_name, # type: str - 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'), - } - 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' + @distributed_trace + 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. - 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) + :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: ~azure.mgmt.automanage.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: ~azure.mgmt.automanage.models.ConfigurationProfileAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileAssignment] + + _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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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,88 +427,18 @@ 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. - - :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) + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}"} # type: ignore - 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 - configuration_profile_assignment_name, # type: str - vm_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "models.ConfigurationProfileAssignment" + 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. @@ -196,39 +449,44 @@ def get( :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 + :rtype: ~azure.mgmt.automanage.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'), + 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileAssignment] + + + 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, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(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,16 +495,18 @@ 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 - def delete( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - configuration_profile_assignment_name, # type: str - vm_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -260,88 +520,198 @@ def delete( :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'), + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}"} # type: ignore - def list( + + @distributed_trace + def list_by_virtual_machines( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.ConfigurationProfileAssignmentList"] + resource_group_name: str, + vm_name: str, + **kwargs: Any + ) -> 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 + :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 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[~azure.mgmt.automanage.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" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileAssignmentList] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + if not next_link: + + request = build_list_by_virtual_machines_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vm_name=vm_name, + api_version=api_version, + template_url=self.list_by_virtual_machines.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_virtual_machines_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vm_name=vm_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ConfigurationProfileAssignmentList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_virtual_machines.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments"} # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + **kwargs: Any + ) -> 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[~azure.mgmt.automanage.models.ConfigurationProfileAssignmentList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileAssignmentList] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): if not next_link: - # 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, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ConfigurationProfileAssignmentList', pipeline_response) + deserialized = self._deserialize("ConfigurationProfileAssignmentList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -350,63 +720,261 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(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 + 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"] + **kwargs: Any + ) -> 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[~azure.mgmt.automanage.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" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileAssignmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ConfigurationProfileAssignmentList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/configurationProfileAssignments"} # type: ignore + + @distributed_trace + def list_by_machine_name( + self, + resource_group_name: str, + machine_name: str, + **kwargs: Any + ) -> 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 + :param machine_name: The name of the Arc machine. + :type machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConfigurationProfileAssignmentList or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.automanage.models.ConfigurationProfileAssignmentList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileAssignmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_machine_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + machine_name=machine_name, + api_version=api_version, + template_url=self.list_by_machine_name.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_machine_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + machine_name=machine_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ConfigurationProfileAssignmentList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_machine_name.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments"} # type: ignore + + @distributed_trace + def list_by_cluster_name( + self, + resource_group_name: str, + cluster_name: str, + **kwargs: Any + ) -> 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 + :param cluster_name: The name of the Arc machine. + :type cluster_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[~azure.mgmt.automanage.models.ConfigurationProfileAssignmentList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileAssignmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): if not next_link: - # 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_cluster_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + api_version=api_version, + template_url=self.list_by_cluster_name.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_cluster_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ConfigurationProfileAssignmentList', pipeline_response) + deserialized = self._deserialize("ConfigurationProfileAssignmentList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -415,17 +983,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(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_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/configurationProfileAssignments'} # type: ignore + list_by_cluster_name.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments"} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_hci_assignments_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_hci_assignments_operations.py new file mode 100644 index 000000000000..e968d63a2dd5 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_hci_assignments_operations.py @@ -0,0 +1,384 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + cluster_name: str, + configuration_profile_assignment_name: str, + *, + json: Optional[_models.ConfigurationProfileAssignment] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), + "configurationProfileAssignmentName": _SERIALIZER.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + subscription_id: str, + cluster_name: str, + configuration_profile_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), + "configurationProfileAssignmentName": _SERIALIZER.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + cluster_name: str, + configuration_profile_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), + "configurationProfileAssignmentName": _SERIALIZER.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ConfigurationProfileHCIAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.AutomanageClient`'s + :attr:`configuration_profile_hci_assignments` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + cluster_name: str, + configuration_profile_assignment_name: str, + parameters: _models.ConfigurationProfileAssignment, + **kwargs: Any + ) -> _models.ConfigurationProfileAssignment: + """Creates an association between a AzureStackHCI cluster and Automanage configuration profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param cluster_name: The name of the Arc machine. + :type cluster_name: str + :param configuration_profile_assignment_name: Name of the configuration profile assignment. + Only default is supported. + :type configuration_profile_assignment_name: str + :param parameters: Parameters supplied to the create or update configuration profile + assignment. + :type parameters: ~azure.mgmt.automanage.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: ~azure.mgmt.automanage.models.ConfigurationProfileAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileAssignment] + + _json = self._serialize.body(parameters, 'ConfigurationProfileAssignment') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}"} # type: ignore + + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_name: str, + configuration_profile_assignment_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 cluster_name: The name of the Arc machine. + :type cluster_name: str + :param configuration_profile_assignment_name: The configuration profile assignment name. + :type configuration_profile_assignment_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: ~azure.mgmt.automanage.models.ConfigurationProfileAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileAssignment] + + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cluster_name=cluster_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_name: str, + configuration_profile_assignment_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 cluster_name: The name of the Arc machine. + :type cluster_name: str + :param configuration_profile_assignment_name: Name of the configuration profile assignment. + :type configuration_profile_assignment_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}"} # type: ignore + diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_hcrp_assignments_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_hcrp_assignments_operations.py new file mode 100644 index 000000000000..f18e26244190 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_hcrp_assignments_operations.py @@ -0,0 +1,384 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + machine_name: str, + configuration_profile_assignment_name: str, + *, + json: Optional[_models.ConfigurationProfileAssignment] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "machineName": _SERIALIZER.url("machine_name", machine_name, 'str'), + "configurationProfileAssignmentName": _SERIALIZER.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + subscription_id: str, + machine_name: str, + configuration_profile_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "machineName": _SERIALIZER.url("machine_name", machine_name, 'str'), + "configurationProfileAssignmentName": _SERIALIZER.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + subscription_id: str, + machine_name: str, + configuration_profile_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "machineName": _SERIALIZER.url("machine_name", machine_name, 'str'), + "configurationProfileAssignmentName": _SERIALIZER.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ConfigurationProfileHCRPAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.AutomanageClient`'s + :attr:`configuration_profile_hcrp_assignments` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + machine_name: str, + configuration_profile_assignment_name: str, + parameters: _models.ConfigurationProfileAssignment, + **kwargs: Any + ) -> _models.ConfigurationProfileAssignment: + """Creates an association between a ARC machine and Automanage configuration profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param machine_name: The name of the Arc machine. + :type machine_name: str + :param configuration_profile_assignment_name: Name of the configuration profile assignment. + Only default is supported. + :type configuration_profile_assignment_name: str + :param parameters: Parameters supplied to the create or update configuration profile + assignment. + :type parameters: ~azure.mgmt.automanage.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: ~azure.mgmt.automanage.models.ConfigurationProfileAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileAssignment] + + _json = self._serialize.body(parameters, 'ConfigurationProfileAssignment') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + machine_name=machine_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}"} # type: ignore + + + @distributed_trace + def get( + self, + resource_group_name: str, + machine_name: str, + configuration_profile_assignment_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 machine_name: The name of the Arc machine. + :type machine_name: str + :param configuration_profile_assignment_name: The configuration profile assignment name. + :type configuration_profile_assignment_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: ~azure.mgmt.automanage.models.ConfigurationProfileAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileAssignment] + + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + machine_name=machine_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + machine_name: str, + configuration_profile_assignment_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 machine_name: The name of the Arc machine. + :type machine_name: str + :param configuration_profile_assignment_name: Name of the configuration profile assignment. + :type configuration_profile_assignment_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + machine_name=machine_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}"} # type: ignore + 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..573ba479b78d --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profiles_operations.py @@ -0,0 +1,714 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + configuration_profile_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: Optional[_models.ConfigurationProfile] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}") # pylint: disable=line-too-long + 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + configuration_profile_name: str, + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}") # pylint: disable=line-too-long + 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + configuration_profile_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}") # pylint: disable=line-too-long + 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_update_request( + configuration_profile_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: Optional[_models.ConfigurationProfileUpdate] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}") # pylint: disable=line-too-long + 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ConfigurationProfilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.AutomanageClient`'s + :attr:`configuration_profiles` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + 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: ~azure.mgmt.automanage.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: ~azure.mgmt.automanage.models.ConfigurationProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfile] + + _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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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: 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: ~azure.mgmt.automanage.models.ConfigurationProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfile] + + + request = build_get_request( + configuration_profile_name=configuration_profile_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('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( # pylint: disable=inconsistent-return-statements + 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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + configuration_profile_name=configuration_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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: 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: ~azure.mgmt.automanage.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: ~azure.mgmt.automanage.models.ConfigurationProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfile] + + _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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) -> 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[~azure.mgmt.automanage.models.ConfigurationProfileList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> 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[~azure.mgmt.automanage.models.ConfigurationProfileList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_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..c7debe58f5d5 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profiles_versions_operations.py @@ -0,0 +1,510 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + configuration_profile_name: str, + version_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: Optional[_models.ConfigurationProfile] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions/{versionName}") # pylint: disable=line-too-long + 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + configuration_profile_name: str, + version_name: str, + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions/{versionName}") # pylint: disable=line-too-long + 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + configuration_profile_name: str, + version_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions/{versionName}") # pylint: disable=line-too-long + 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_child_resources_request( + configuration_profile_name: str, + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions") # pylint: disable=line-too-long + 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ConfigurationProfilesVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.AutomanageClient`'s + :attr:`configuration_profiles_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def 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: ~azure.mgmt.automanage.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: ~azure.mgmt.automanage.models.ConfigurationProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfile] + + _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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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: 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: ~azure.mgmt.automanage.models.ConfigurationProfile + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfile] + + + 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, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('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( # pylint: disable=inconsistent-return-statements + 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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + 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, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 list_child_resources( + self, + configuration_profile_name: str, + resource_group_name: str, + **kwargs: Any + ) -> 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[~azure.mgmt.automanage.models.ConfigurationProfileList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationProfileList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_child_resources_request( + configuration_profile_name=configuration_profile_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_child_resources.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_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/_hci_reports_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_hci_reports_operations.py new file mode 100644 index 000000000000..878d027422fd --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_hci_reports_operations.py @@ -0,0 +1,293 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + subscription_id: str, + cluster_name: str, + configuration_profile_assignment_name: str, + report_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports/{reportName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), + "configurationProfileAssignmentName": _SERIALIZER.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), + "reportName": _SERIALIZER.url("report_name", report_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_configuration_profile_assignments_request( + subscription_id: str, + resource_group_name: str, + cluster_name: str, + configuration_profile_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), + "configurationProfileAssignmentName": _SERIALIZER.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class HCIReportsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.AutomanageClient`'s + :attr:`hci_reports` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_name: str, + configuration_profile_assignment_name: str, + report_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 cluster_name: The name of the Arc machine. + :type cluster_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Report, or the result of cls(response) + :rtype: ~azure.mgmt.automanage.models.Report + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Report] + + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cluster_name=cluster_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + report_name=report_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Report', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports/{reportName}"} # type: ignore + + + @distributed_trace + def list_by_configuration_profile_assignments( + self, + resource_group_name: str, + cluster_name: str, + configuration_profile_assignment_name: str, + **kwargs: Any + ) -> 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 cluster_name: The name of the Arc machine. + :type cluster_name: str + :param configuration_profile_assignment_name: The configuration profile assignment name. + :type configuration_profile_assignment_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[~azure.mgmt.automanage.models.ReportList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReportList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_configuration_profile_assignments_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + api_version=api_version, + template_url=self.list_by_configuration_profile_assignments.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_configuration_profile_assignments_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_configuration_profile_assignments.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports"} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_hcrp_reports_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_hcrp_reports_operations.py new file mode 100644 index 000000000000..f09c746088bb --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_hcrp_reports_operations.py @@ -0,0 +1,293 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + machine_name: str, + configuration_profile_assignment_name: str, + report_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports/{reportName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "machineName": _SERIALIZER.url("machine_name", machine_name, 'str'), + "configurationProfileAssignmentName": _SERIALIZER.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), + "reportName": _SERIALIZER.url("report_name", report_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_configuration_profile_assignments_request( + subscription_id: str, + resource_group_name: str, + machine_name: str, + configuration_profile_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "machineName": _SERIALIZER.url("machine_name", machine_name, 'str'), + "configurationProfileAssignmentName": _SERIALIZER.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class HCRPReportsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.AutomanageClient`'s + :attr:`hcrp_reports` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + machine_name: str, + configuration_profile_assignment_name: str, + report_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 machine_name: The name of the Arc machine. + :type machine_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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Report, or the result of cls(response) + :rtype: ~azure.mgmt.automanage.models.Report + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Report] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + machine_name=machine_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + report_name=report_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Report', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports/{reportName}"} # type: ignore + + + @distributed_trace + def list_by_configuration_profile_assignments( + self, + resource_group_name: str, + machine_name: str, + configuration_profile_assignment_name: str, + **kwargs: Any + ) -> 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 machine_name: The name of the Arc machine. + :type machine_name: str + :param configuration_profile_assignment_name: The configuration profile assignment name. + :type configuration_profile_assignment_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[~azure.mgmt.automanage.models.ReportList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReportList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_configuration_profile_assignments_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + machine_name=machine_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + api_version=api_version, + template_url=self.list_by_configuration_profile_assignments.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_configuration_profile_assignments_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + machine_name=machine_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_configuration_profile_assignments.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports"} # 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..f0f3c0decd01 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,84 +6,122 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from .. import models +from .. import models as _models +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Automanage/operations") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') -class Operations(object): - """Operations operations. + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) - 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. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :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. + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.AutomanageClient`'s + :attr:`operations` attribute. """ - models = models + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.OperationList"] + **kwargs: Any + ) -> 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[~azure.mgmt.automanage.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.OperationList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationList', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -91,17 +130,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Automanage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Automanage/operations"} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_patch.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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..c5263cb0228d --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_reports_operations.py @@ -0,0 +1,293 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + configuration_profile_assignment_name: str, + report_name: str, + subscription_id: str, + vm_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports/{reportName}") # pylint: disable=line-too-long + 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_configuration_profile_assignments_request( + subscription_id: str, + resource_group_name: str, + configuration_profile_assignment_name: str, + vm_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ReportsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.AutomanageClient`'s + :attr:`reports` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + 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: ~azure.mgmt.automanage.models.Report + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Report] + + + 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, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('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 + ) -> 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[~azure.mgmt.automanage.models.ReportList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReportList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_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, + api_version=api_version, + template_url=self.list_by_configuration_profile_assignments.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_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/operations/_service_principals_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_service_principals_operations.py new file mode 100644 index 000000000000..9287ba948964 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_service_principals_operations.py @@ -0,0 +1,251 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/servicePrincipals") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/servicePrincipals/default") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ServicePrincipalsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automanage.AutomanageClient`'s + :attr:`service_principals` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable[_models.ServicePrincipalListResult]: + """Get the Automanage AAD first party Application Service Principal details for the subscription + id. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServicePrincipalListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automanage.models.ServicePrincipalListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServicePrincipalListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ServicePrincipalListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/servicePrincipals"} # type: ignore + + @distributed_trace + def get( + self, + **kwargs: Any + ) -> _models.ServicePrincipal: + """Get the Automanage AAD first party Application Service Principal details for the subscription + id. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServicePrincipal, or the result of cls(response) + :rtype: ~azure.mgmt.automanage.models.ServicePrincipal + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServicePrincipal] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ServicePrincipal', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/servicePrincipals/default"} # type: ignore + diff --git a/sdk/automanage/azure-mgmt-automanage/setup.py b/sdk/automanage/azure-mgmt-automanage/setup.py index 9fd6f0c5f0c9..10c6fcc6788b 100644 --- a/sdk/automanage/azure-mgmt-automanage/setup.py +++ b/sdk/automanage/azure-mgmt-automanage/setup.py @@ -51,7 +51,6 @@ 'Programming Language :: Python', 'Programming Language :: Python :: 3 :: Only', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', @@ -65,10 +64,14 @@ 'azure', 'azure.mgmt', ]), + include_package_data=True, + package_data={ + 'pytyped': ['py.typed'], + }, install_requires=[ 'msrest>=0.6.21', 'azure-common~=1.1', - 'azure-mgmt-core>=1.3.0,<2.0.0', + 'azure-mgmt-core>=1.3.1,<2.0.0', ], - python_requires=">=3.6" + python_requires=">=3.7" ) diff --git a/shared_requirements.txt b/shared_requirements.txt index 5fc3d898b1aa..01ad66e3a081 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -403,3 +403,5 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-mgmt-datalake-analytics azure-mgmt-core>=1.3.1,<2.0.0 #override azure-mgmt-recoveryservices msrest>=0.6.21 #override azure-mgmt-recoveryservices azure-mgmt-core>=1.3.1,<2.0.0 +#override azure-mgmt-automanage msrest>=0.6.21 +#override azure-mgmt-automanage azure-mgmt-core>=1.3.1,<2.0.0