diff --git a/sdk/resources/azure-mgmt-resource/_meta.json b/sdk/resources/azure-mgmt-resource/_meta.json index 66dfc00d9450b..385c566a43a5d 100644 --- a/sdk/resources/azure-mgmt-resource/_meta.json +++ b/sdk/resources/azure-mgmt-resource/_meta.json @@ -1,7 +1,7 @@ { "autorest": "3.3.0", "use": "@autorest/python@5.6.6", - "commit": "c55d37d10ded9ef904539fe5814df3ea333b66a8", + "commit": "a51292fefc306800c8ac008b5a5c84e8e06e66b7", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest_command": "autorest specification/resources/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.6.6 --version=3.3.0", "readme": "specification/resources/resource-manager/readme.md" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_resource_management_client.py index d982c169a4615..d95b09903d739 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_resource_management_client.py @@ -56,7 +56,7 @@ class ResourceManagementClient(MultiApiClientMixin, _SDKClient): :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ - DEFAULT_API_VERSION = '2020-10-01' + DEFAULT_API_VERSION = '2021-01-01' _PROFILE_TAG = "azure.mgmt.resource.resources.ResourceManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -104,6 +104,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2019-10-01: :mod:`v2019_10_01.models` * 2020-06-01: :mod:`v2020_06_01.models` * 2020-10-01: :mod:`v2020_10_01.models` + * 2021-01-01: :mod:`v2021_01_01.models` """ if api_version == '2016-02-01': from .v2016_02_01 import models @@ -144,6 +145,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2020-10-01': from .v2020_10_01 import models return models + elif api_version == '2021-01-01': + from .v2021_01_01 import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -163,6 +167,7 @@ def deployment_operations(self): * 2019-10-01: :class:`DeploymentOperationsOperations` * 2020-06-01: :class:`DeploymentOperationsOperations` * 2020-10-01: :class:`DeploymentOperationsOperations` + * 2021-01-01: :class:`DeploymentOperationsOperations` """ api_version = self._get_api_version('deployment_operations') if api_version == '2016-02-01': @@ -191,6 +196,8 @@ def deployment_operations(self): from .v2020_06_01.operations import DeploymentOperationsOperations as OperationClass elif api_version == '2020-10-01': from .v2020_10_01.operations import DeploymentOperationsOperations as OperationClass + elif api_version == '2021-01-01': + from .v2021_01_01.operations import DeploymentOperationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'deployment_operations'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -212,6 +219,7 @@ def deployments(self): * 2019-10-01: :class:`DeploymentsOperations` * 2020-06-01: :class:`DeploymentsOperations` * 2020-10-01: :class:`DeploymentsOperations` + * 2021-01-01: :class:`DeploymentsOperations` """ api_version = self._get_api_version('deployments') if api_version == '2016-02-01': @@ -240,6 +248,8 @@ def deployments(self): from .v2020_06_01.operations import DeploymentsOperations as OperationClass elif api_version == '2020-10-01': from .v2020_10_01.operations import DeploymentsOperations as OperationClass + elif api_version == '2021-01-01': + from .v2021_01_01.operations import DeploymentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'deployments'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -257,6 +267,7 @@ def operations(self): * 2019-10-01: :class:`Operations` * 2020-06-01: :class:`Operations` * 2020-10-01: :class:`Operations` + * 2021-01-01: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2018-05-01': @@ -277,6 +288,8 @@ def operations(self): from .v2020_06_01.operations import Operations as OperationClass elif api_version == '2020-10-01': from .v2020_10_01.operations import Operations as OperationClass + elif api_version == '2021-01-01': + from .v2021_01_01.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -286,10 +299,13 @@ def provider_resource_types(self): """Instance depends on the API version: * 2020-10-01: :class:`ProviderResourceTypesOperations` + * 2021-01-01: :class:`ProviderResourceTypesOperations` """ api_version = self._get_api_version('provider_resource_types') if api_version == '2020-10-01': from .v2020_10_01.operations import ProviderResourceTypesOperations as OperationClass + elif api_version == '2021-01-01': + from .v2021_01_01.operations import ProviderResourceTypesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'provider_resource_types'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -311,6 +327,7 @@ def providers(self): * 2019-10-01: :class:`ProvidersOperations` * 2020-06-01: :class:`ProvidersOperations` * 2020-10-01: :class:`ProvidersOperations` + * 2021-01-01: :class:`ProvidersOperations` """ api_version = self._get_api_version('providers') if api_version == '2016-02-01': @@ -339,6 +356,8 @@ def providers(self): from .v2020_06_01.operations import ProvidersOperations as OperationClass elif api_version == '2020-10-01': from .v2020_10_01.operations import ProvidersOperations as OperationClass + elif api_version == '2021-01-01': + from .v2021_01_01.operations import ProvidersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'providers'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -360,6 +379,7 @@ def resource_groups(self): * 2019-10-01: :class:`ResourceGroupsOperations` * 2020-06-01: :class:`ResourceGroupsOperations` * 2020-10-01: :class:`ResourceGroupsOperations` + * 2021-01-01: :class:`ResourceGroupsOperations` """ api_version = self._get_api_version('resource_groups') if api_version == '2016-02-01': @@ -388,6 +408,8 @@ def resource_groups(self): from .v2020_06_01.operations import ResourceGroupsOperations as OperationClass elif api_version == '2020-10-01': from .v2020_10_01.operations import ResourceGroupsOperations as OperationClass + elif api_version == '2021-01-01': + from .v2021_01_01.operations import ResourceGroupsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'resource_groups'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -409,6 +431,7 @@ def resources(self): * 2019-10-01: :class:`ResourcesOperations` * 2020-06-01: :class:`ResourcesOperations` * 2020-10-01: :class:`ResourcesOperations` + * 2021-01-01: :class:`ResourcesOperations` """ api_version = self._get_api_version('resources') if api_version == '2016-02-01': @@ -437,6 +460,8 @@ def resources(self): from .v2020_06_01.operations import ResourcesOperations as OperationClass elif api_version == '2020-10-01': from .v2020_10_01.operations import ResourcesOperations as OperationClass + elif api_version == '2021-01-01': + from .v2021_01_01.operations import ResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'resources'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -458,6 +483,7 @@ def tags(self): * 2019-10-01: :class:`TagsOperations` * 2020-06-01: :class:`TagsOperations` * 2020-10-01: :class:`TagsOperations` + * 2021-01-01: :class:`TagsOperations` """ api_version = self._get_api_version('tags') if api_version == '2016-02-01': @@ -486,6 +512,8 @@ def tags(self): from .v2020_06_01.operations import TagsOperations as OperationClass elif api_version == '2020-10-01': from .v2020_10_01.operations import TagsOperations as OperationClass + elif api_version == '2021-01-01': + from .v2021_01_01.operations import TagsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'tags'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_resource_management_client.py index efe6785d232ee..8233cface5c68 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_resource_management_client.py @@ -54,7 +54,7 @@ class ResourceManagementClient(MultiApiClientMixin, _SDKClient): :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ - DEFAULT_API_VERSION = '2020-10-01' + DEFAULT_API_VERSION = '2021-01-01' _PROFILE_TAG = "azure.mgmt.resource.resources.ResourceManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -102,6 +102,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2019-10-01: :mod:`v2019_10_01.models` * 2020-06-01: :mod:`v2020_06_01.models` * 2020-10-01: :mod:`v2020_10_01.models` + * 2021-01-01: :mod:`v2021_01_01.models` """ if api_version == '2016-02-01': from ..v2016_02_01 import models @@ -142,6 +143,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2020-10-01': from ..v2020_10_01 import models return models + elif api_version == '2021-01-01': + from ..v2021_01_01 import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -161,6 +165,7 @@ def deployment_operations(self): * 2019-10-01: :class:`DeploymentOperationsOperations` * 2020-06-01: :class:`DeploymentOperationsOperations` * 2020-10-01: :class:`DeploymentOperationsOperations` + * 2021-01-01: :class:`DeploymentOperationsOperations` """ api_version = self._get_api_version('deployment_operations') if api_version == '2016-02-01': @@ -189,6 +194,8 @@ def deployment_operations(self): from ..v2020_06_01.aio.operations import DeploymentOperationsOperations as OperationClass elif api_version == '2020-10-01': from ..v2020_10_01.aio.operations import DeploymentOperationsOperations as OperationClass + elif api_version == '2021-01-01': + from ..v2021_01_01.aio.operations import DeploymentOperationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'deployment_operations'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -210,6 +217,7 @@ def deployments(self): * 2019-10-01: :class:`DeploymentsOperations` * 2020-06-01: :class:`DeploymentsOperations` * 2020-10-01: :class:`DeploymentsOperations` + * 2021-01-01: :class:`DeploymentsOperations` """ api_version = self._get_api_version('deployments') if api_version == '2016-02-01': @@ -238,6 +246,8 @@ def deployments(self): from ..v2020_06_01.aio.operations import DeploymentsOperations as OperationClass elif api_version == '2020-10-01': from ..v2020_10_01.aio.operations import DeploymentsOperations as OperationClass + elif api_version == '2021-01-01': + from ..v2021_01_01.aio.operations import DeploymentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'deployments'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -255,6 +265,7 @@ def operations(self): * 2019-10-01: :class:`Operations` * 2020-06-01: :class:`Operations` * 2020-10-01: :class:`Operations` + * 2021-01-01: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2018-05-01': @@ -275,6 +286,8 @@ def operations(self): from ..v2020_06_01.aio.operations import Operations as OperationClass elif api_version == '2020-10-01': from ..v2020_10_01.aio.operations import Operations as OperationClass + elif api_version == '2021-01-01': + from ..v2021_01_01.aio.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -284,10 +297,13 @@ def provider_resource_types(self): """Instance depends on the API version: * 2020-10-01: :class:`ProviderResourceTypesOperations` + * 2021-01-01: :class:`ProviderResourceTypesOperations` """ api_version = self._get_api_version('provider_resource_types') if api_version == '2020-10-01': from ..v2020_10_01.aio.operations import ProviderResourceTypesOperations as OperationClass + elif api_version == '2021-01-01': + from ..v2021_01_01.aio.operations import ProviderResourceTypesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'provider_resource_types'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -309,6 +325,7 @@ def providers(self): * 2019-10-01: :class:`ProvidersOperations` * 2020-06-01: :class:`ProvidersOperations` * 2020-10-01: :class:`ProvidersOperations` + * 2021-01-01: :class:`ProvidersOperations` """ api_version = self._get_api_version('providers') if api_version == '2016-02-01': @@ -337,6 +354,8 @@ def providers(self): from ..v2020_06_01.aio.operations import ProvidersOperations as OperationClass elif api_version == '2020-10-01': from ..v2020_10_01.aio.operations import ProvidersOperations as OperationClass + elif api_version == '2021-01-01': + from ..v2021_01_01.aio.operations import ProvidersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'providers'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -358,6 +377,7 @@ def resource_groups(self): * 2019-10-01: :class:`ResourceGroupsOperations` * 2020-06-01: :class:`ResourceGroupsOperations` * 2020-10-01: :class:`ResourceGroupsOperations` + * 2021-01-01: :class:`ResourceGroupsOperations` """ api_version = self._get_api_version('resource_groups') if api_version == '2016-02-01': @@ -386,6 +406,8 @@ def resource_groups(self): from ..v2020_06_01.aio.operations import ResourceGroupsOperations as OperationClass elif api_version == '2020-10-01': from ..v2020_10_01.aio.operations import ResourceGroupsOperations as OperationClass + elif api_version == '2021-01-01': + from ..v2021_01_01.aio.operations import ResourceGroupsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'resource_groups'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -407,6 +429,7 @@ def resources(self): * 2019-10-01: :class:`ResourcesOperations` * 2020-06-01: :class:`ResourcesOperations` * 2020-10-01: :class:`ResourcesOperations` + * 2021-01-01: :class:`ResourcesOperations` """ api_version = self._get_api_version('resources') if api_version == '2016-02-01': @@ -435,6 +458,8 @@ def resources(self): from ..v2020_06_01.aio.operations import ResourcesOperations as OperationClass elif api_version == '2020-10-01': from ..v2020_10_01.aio.operations import ResourcesOperations as OperationClass + elif api_version == '2021-01-01': + from ..v2021_01_01.aio.operations import ResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'resources'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -456,6 +481,7 @@ def tags(self): * 2019-10-01: :class:`TagsOperations` * 2020-06-01: :class:`TagsOperations` * 2020-10-01: :class:`TagsOperations` + * 2021-01-01: :class:`TagsOperations` """ api_version = self._get_api_version('tags') if api_version == '2016-02-01': @@ -484,6 +510,8 @@ def tags(self): from ..v2020_06_01.aio.operations import TagsOperations as OperationClass elif api_version == '2020-10-01': from ..v2020_10_01.aio.operations import TagsOperations as OperationClass + elif api_version == '2021-01-01': + from ..v2021_01_01.aio.operations import TagsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'tags'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models.py index 3a453a73ab82a..0c8fa05fd1792 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/models.py @@ -4,4 +4,4 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from .v2020_10_01.models import * +from .v2021_01_01.models import * diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/__init__.py new file mode 100644 index 0000000000000..d5207c07d07e5 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/__init__.py @@ -0,0 +1,19 @@ +# 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 ._resource_management_client import ResourceManagementClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ['ResourceManagementClient'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_configuration.py new file mode 100644 index 0000000000000..15e10bc228bd8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_configuration.py @@ -0,0 +1,71 @@ +# 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 + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import 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 ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2021-01-01" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_metadata.json new file mode 100644 index 0000000000000..4439d0be5e666 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_metadata.json @@ -0,0 +1,110 @@ +{ + "chosen_version": "2021-01-01", + "total_api_version_list": ["2021-01-01"], + "client": { + "name": "ResourceManagementClient", + "filename": "_resource_management_client", + "description": "Provides operations for working with resources and resource groups.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_default_policy_type": "BearerTokenCredentialPolicy", + "credential_default_policy_type_has_async_version": true, + "credential_key_header_name": null, + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "operations": "Operations", + "deployments": "DeploymentsOperations", + "providers": "ProvidersOperations", + "provider_resource_types": "ProviderResourceTypesOperations", + "resources": "ResourcesOperations", + "resource_groups": "ResourceGroupsOperations", + "tags": "TagsOperations", + "deployment_operations": "DeploymentOperationsOperations" + } +} \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_resource_management_client.py new file mode 100644 index 0000000000000..3613698812c11 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_resource_management_client.py @@ -0,0 +1,124 @@ +# 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 + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + from azure.core.pipeline.transport import HttpRequest, HttpResponse + +from ._configuration import ResourceManagementClientConfiguration +from .operations import Operations +from .operations import DeploymentsOperations +from .operations import ProvidersOperations +from .operations import ProviderResourceTypesOperations +from .operations import ResourcesOperations +from .operations import ResourceGroupsOperations +from .operations import TagsOperations +from .operations import DeploymentOperationsOperations +from . import models + + +class ResourceManagementClient(object): + """Provides operations for working with resources and resource groups. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.resource.resources.v2021_01_01.operations.Operations + :ivar deployments: DeploymentsOperations operations + :vartype deployments: azure.mgmt.resource.resources.v2021_01_01.operations.DeploymentsOperations + :ivar providers: ProvidersOperations operations + :vartype providers: azure.mgmt.resource.resources.v2021_01_01.operations.ProvidersOperations + :ivar provider_resource_types: ProviderResourceTypesOperations operations + :vartype provider_resource_types: azure.mgmt.resource.resources.v2021_01_01.operations.ProviderResourceTypesOperations + :ivar resources: ResourcesOperations operations + :vartype resources: azure.mgmt.resource.resources.v2021_01_01.operations.ResourcesOperations + :ivar resource_groups: ResourceGroupsOperations operations + :vartype resource_groups: azure.mgmt.resource.resources.v2021_01_01.operations.ResourceGroupsOperations + :ivar tags: TagsOperations operations + :vartype tags: azure.mgmt.resource.resources.v2021_01_01.operations.TagsOperations + :ivar deployment_operations: DeploymentOperationsOperations operations + :vartype deployment_operations: azure.mgmt.resource.resources.v2021_01_01.operations.DeploymentOperationsOperations + :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. + """ + + 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 = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations( + self._client, self._config, self._serialize, self._deserialize) + self.provider_resource_types = ProviderResourceTypesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, http_request, **kwargs): + # type: (HttpRequest, Any) -> HttpResponse + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.HttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ResourceManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_version.py new file mode 100644 index 0000000000000..e5754a47ce68f --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_version.py @@ -0,0 +1,9 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/__init__.py new file mode 100644 index 0000000000000..f11762bdb19bb --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/__init__.py @@ -0,0 +1,10 @@ +# 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 ._resource_management_client import ResourceManagementClient +__all__ = ['ResourceManagementClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_configuration.py new file mode 100644 index 0000000000000..087a46ad28d16 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_configuration.py @@ -0,0 +1,67 @@ +# 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, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2021-01-01" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_resource_management_client.py new file mode 100644 index 0000000000000..4cf579edb1fe3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_resource_management_client.py @@ -0,0 +1,117 @@ +# 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.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration import ResourceManagementClientConfiguration +from .operations import Operations +from .operations import DeploymentsOperations +from .operations import ProvidersOperations +from .operations import ProviderResourceTypesOperations +from .operations import ResourcesOperations +from .operations import ResourceGroupsOperations +from .operations import TagsOperations +from .operations import DeploymentOperationsOperations +from .. import models + + +class ResourceManagementClient(object): + """Provides operations for working with resources and resource groups. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.resource.resources.v2021_01_01.aio.operations.Operations + :ivar deployments: DeploymentsOperations operations + :vartype deployments: azure.mgmt.resource.resources.v2021_01_01.aio.operations.DeploymentsOperations + :ivar providers: ProvidersOperations operations + :vartype providers: azure.mgmt.resource.resources.v2021_01_01.aio.operations.ProvidersOperations + :ivar provider_resource_types: ProviderResourceTypesOperations operations + :vartype provider_resource_types: azure.mgmt.resource.resources.v2021_01_01.aio.operations.ProviderResourceTypesOperations + :ivar resources: ResourcesOperations operations + :vartype resources: azure.mgmt.resource.resources.v2021_01_01.aio.operations.ResourcesOperations + :ivar resource_groups: ResourceGroupsOperations operations + :vartype resource_groups: azure.mgmt.resource.resources.v2021_01_01.aio.operations.ResourceGroupsOperations + :ivar tags: TagsOperations operations + :vartype tags: azure.mgmt.resource.resources.v2021_01_01.aio.operations.TagsOperations + :ivar deployment_operations: DeploymentOperationsOperations operations + :vartype deployment_operations: azure.mgmt.resource.resources.v2021_01_01.aio.operations.DeploymentOperationsOperations + :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 = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations( + self._client, self._config, self._serialize, self._deserialize) + self.provider_resource_types = ProviderResourceTypesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ResourceManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/__init__.py new file mode 100644 index 0000000000000..b5dcba5d6d4b2 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/__init__.py @@ -0,0 +1,27 @@ +# 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 ._operations import Operations +from ._deployments_operations import DeploymentsOperations +from ._providers_operations import ProvidersOperations +from ._provider_resource_types_operations import ProviderResourceTypesOperations +from ._resources_operations import ResourcesOperations +from ._resource_groups_operations import ResourceGroupsOperations +from ._tags_operations import TagsOperations +from ._deployment_operations_operations import DeploymentOperationsOperations + +__all__ = [ + 'Operations', + 'DeploymentsOperations', + 'ProvidersOperations', + 'ProviderResourceTypesOperations', + 'ResourcesOperations', + 'ResourceGroupsOperations', + 'TagsOperations', + 'DeploymentOperationsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_deployment_operations_operations.py new file mode 100644 index 0000000000000..6ebc5bf57f2e4 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_deployment_operations_operations.py @@ -0,0 +1,725 @@ +# 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 ClientAuthenticationError, 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 as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentOperationsOperations: + """DeploymentOperationsOperations 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: ~azure.mgmt.resource.resources.v2021_01_01.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 get_at_scope( + self, + scope: str, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "_models.DeploymentOperation": + """Gets a deployments operation. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_scope( + self, + scope: str, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param top: The number of results to return. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_at_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + + async def get_at_tenant_scope( + self, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "_models.DeploymentOperation": + """Gets a deployments operation. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_tenant_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_tenant_scope( + self, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param top: The number of results to return. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_at_tenant_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + + async def get_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "_models.DeploymentOperation": + """Gets a deployments operation. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_management_group_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param top: The number of results to return. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_at_management_group_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + + async def get_at_subscription_scope( + self, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "_models.DeploymentOperation": + """Gets a deployments operation. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_subscription_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_subscription_scope( + self, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param top: The number of results to return. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_at_subscription_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + + async def get( + self, + resource_group_name: str, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "_models.DeploymentOperation": + """Gets a deployments operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name: str, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param top: The number of results to return. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_deployments_operations.py new file mode 100644 index 0000000000000..31a68edbfb0ad --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_deployments_operations.py @@ -0,0 +1,3942 @@ +# 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 ClientAuthenticationError, 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 as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentsOperations: + """DeploymentsOperations 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: ~azure.mgmt.resource.resources.v2021_01_01.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 _delete_at_scope_initial( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self._delete_at_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + 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 [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def begin_delete_at_scope( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> AsyncLROPoller[None]: + """Deletes a deployment from the deployment history. + + A template deployment that is currently running cannot be deleted. Deleting a template + deployment removes the associated deployment operations. This is an asynchronous operation that + returns a status of 202 until the template deployment is successfully deleted. The Location + response header contains the URI that is used to obtain the status of the process. While the + process is running, a call to the URI in the Location header returns a status of 202. When the + process finishes, the URI in the Location header returns a status of 204 on success. If the + asynchronous request failed, the URI in the Location header returns an error-level status code. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_at_scope_initial( + scope=scope, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence_at_scope( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> bool: + """Checks whether the deployment exists. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.check_existence_at_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(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 [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def _create_or_update_at_scope_initial( + self, + scope: str, + deployment_name: str, + parameters: "_models.Deployment", + **kwargs + ) -> "_models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_at_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Deployment') + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def begin_create_or_update_at_scope( + self, + scope: str, + deployment_name: str, + parameters: "_models.Deployment", + **kwargs + ) -> AsyncLROPoller["_models.DeploymentExtended"]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + 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_at_scope_initial( + scope=scope, + deployment_name=deployment_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('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get_at_scope( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> "_models.DeploymentExtended": + """Gets a deployment. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel_at_scope( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> None: + """Cancels a currently running template deployment. + + You can cancel a deployment only if the provisioningState is Accepted or Running. After the + deployment is canceled, the provisioningState is set to Canceled. Canceling a template + deployment stops the currently running template deployment and leaves the resources partially + deployed. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.cancel_at_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def _validate_at_scope_initial( + self, + scope: str, + deployment_name: str, + parameters: "_models.Deployment", + **kwargs + ) -> Optional["_models.DeploymentValidateResult"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._validate_at_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Deployment') + body_content_kwargs['content'] = body_content + request = self._client.post(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, 202, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _validate_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def begin_validate_at_scope( + self, + scope: str, + deployment_name: str, + parameters: "_models.Deployment", + **kwargs + ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to validate. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] + 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._validate_at_scope_initial( + scope=scope, + deployment_name=deployment_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('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def export_template_at_scope( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> "_models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.export_template_at_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_at_scope( + self, + scope: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["_models.DeploymentListResult"]: + """Get all the deployments at the given scope. + + :param scope: The resource scope. + :type scope: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :param top: The number of results to get. If null is passed, returns all deployments. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_at_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/'} # type: ignore + + async def _delete_at_tenant_scope_initial( + self, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self._delete_at_tenant_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + 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 [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def begin_delete_at_tenant_scope( + self, + deployment_name: str, + **kwargs + ) -> AsyncLROPoller[None]: + """Deletes a deployment from the deployment history. + + A template deployment that is currently running cannot be deleted. Deleting a template + deployment removes the associated deployment operations. This is an asynchronous operation that + returns a status of 202 until the template deployment is successfully deleted. The Location + response header contains the URI that is used to obtain the status of the process. While the + process is running, a call to the URI in the Location header returns a status of 202. When the + process finishes, the URI in the Location header returns a status of 204 on success. If the + asynchronous request failed, the URI in the Location header returns an error-level status code. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_at_tenant_scope_initial( + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence_at_tenant_scope( + self, + deployment_name: str, + **kwargs + ) -> bool: + """Checks whether the deployment exists. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.check_existence_at_tenant_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(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 [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def _create_or_update_at_tenant_scope_initial( + self, + deployment_name: str, + parameters: "_models.ScopedDeployment", + **kwargs + ) -> "_models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_at_tenant_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ScopedDeployment') + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def begin_create_or_update_at_tenant_scope( + self, + deployment_name: str, + parameters: "_models.ScopedDeployment", + **kwargs + ) -> AsyncLROPoller["_models.DeploymentExtended"]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + 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_at_tenant_scope_initial( + deployment_name=deployment_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('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get_at_tenant_scope( + self, + deployment_name: str, + **kwargs + ) -> "_models.DeploymentExtended": + """Gets a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_tenant_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel_at_tenant_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """Cancels a currently running template deployment. + + You can cancel a deployment only if the provisioningState is Accepted or Running. After the + deployment is canceled, the provisioningState is set to Canceled. Canceling a template + deployment stops the currently running template deployment and leaves the resources partially + deployed. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.cancel_at_tenant_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def _validate_at_tenant_scope_initial( + self, + deployment_name: str, + parameters: "_models.ScopedDeployment", + **kwargs + ) -> Optional["_models.DeploymentValidateResult"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._validate_at_tenant_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ScopedDeployment') + body_content_kwargs['content'] = body_content + request = self._client.post(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, 202, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _validate_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def begin_validate_at_tenant_scope( + self, + deployment_name: str, + parameters: "_models.ScopedDeployment", + **kwargs + ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to validate. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] + 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._validate_at_tenant_scope_initial( + deployment_name=deployment_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('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def _what_if_at_tenant_scope_initial( + self, + deployment_name: str, + parameters: "_models.ScopedDeploymentWhatIf", + **kwargs + ) -> Optional["_models.WhatIfOperationResult"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._what_if_at_tenant_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + body_content_kwargs['content'] = body_content + request = self._client.post(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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _what_if_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + async def begin_what_if_at_tenant_scope( + self, + deployment_name: str, + parameters: "_models.ScopedDeploymentWhatIf", + **kwargs + ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + """Returns changes that will be made by the deployment if executed at the scope of the tenant + group. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to validate. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeploymentWhatIf + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] + 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._what_if_at_tenant_scope_initial( + deployment_name=deployment_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('WhatIfOperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **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_what_if_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + async def export_template_at_tenant_scope( + self, + deployment_name: str, + **kwargs + ) -> "_models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.export_template_at_tenant_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_at_tenant_scope( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["_models.DeploymentListResult"]: + """Get all the deployments at the tenant scope. + + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :param top: The number of results to get. If null is passed, returns all deployments. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_at_tenant_scope.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/'} # type: ignore + + async def _delete_at_management_group_scope_initial( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self._delete_at_management_group_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + 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 [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def begin_delete_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> AsyncLROPoller[None]: + """Deletes a deployment from the deployment history. + + A template deployment that is currently running cannot be deleted. Deleting a template + deployment removes the associated deployment operations. This is an asynchronous operation that + returns a status of 202 until the template deployment is successfully deleted. The Location + response header contains the URI that is used to obtain the status of the process. While the + process is running, a call to the URI in the Location header returns a status of 202. When the + process finishes, the URI in the Location header returns a status of 204 on success. If the + asynchronous request failed, the URI in the Location header returns an error-level status code. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_at_management_group_scope_initial( + group_id=group_id, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> bool: + """Checks whether the deployment exists. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.check_existence_at_management_group_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(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 [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def _create_or_update_at_management_group_scope_initial( + self, + group_id: str, + deployment_name: str, + parameters: "_models.ScopedDeployment", + **kwargs + ) -> "_models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_at_management_group_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ScopedDeployment') + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def begin_create_or_update_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: "_models.ScopedDeployment", + **kwargs + ) -> AsyncLROPoller["_models.DeploymentExtended"]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + 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_at_management_group_scope_initial( + group_id=group_id, + deployment_name=deployment_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('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> "_models.DeploymentExtended": + """Gets a deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_management_group_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> None: + """Cancels a currently running template deployment. + + You can cancel a deployment only if the provisioningState is Accepted or Running. After the + deployment is canceled, the provisioningState is set to Canceled. Canceling a template + deployment stops the currently running template deployment and leaves the resources partially + deployed. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.cancel_at_management_group_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def _validate_at_management_group_scope_initial( + self, + group_id: str, + deployment_name: str, + parameters: "_models.ScopedDeployment", + **kwargs + ) -> Optional["_models.DeploymentValidateResult"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._validate_at_management_group_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ScopedDeployment') + body_content_kwargs['content'] = body_content + request = self._client.post(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, 202, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _validate_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def begin_validate_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: "_models.ScopedDeployment", + **kwargs + ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to validate. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] + 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._validate_at_management_group_scope_initial( + group_id=group_id, + deployment_name=deployment_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('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def _what_if_at_management_group_scope_initial( + self, + group_id: str, + deployment_name: str, + parameters: "_models.ScopedDeploymentWhatIf", + **kwargs + ) -> Optional["_models.WhatIfOperationResult"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._what_if_at_management_group_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + body_content_kwargs['content'] = body_content + request = self._client.post(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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _what_if_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + async def begin_what_if_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: "_models.ScopedDeploymentWhatIf", + **kwargs + ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + """Returns changes that will be made by the deployment if executed at the scope of the management + group. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to validate. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeploymentWhatIf + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] + 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._what_if_at_management_group_scope_initial( + group_id=group_id, + deployment_name=deployment_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('WhatIfOperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **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_what_if_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + async def export_template_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> "_models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.export_template_at_management_group_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_at_management_group_scope( + self, + group_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["_models.DeploymentListResult"]: + """Get all the deployments for a management group. + + :param group_id: The management group ID. + :type group_id: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :param top: The number of results to get. If null is passed, returns all deployments. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_at_management_group_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/'} # type: ignore + + async def _delete_at_subscription_scope_initial( + self, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.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 [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def begin_delete_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> AsyncLROPoller[None]: + """Deletes a deployment from the deployment history. + + A template deployment that is currently running cannot be deleted. Deleting a template + deployment removes the associated deployment operations. This is an asynchronous operation that + returns a status of 202 until the template deployment is successfully deleted. The Location + response header contains the URI that is used to obtain the status of the process. While the + process is running, a call to the URI in the Location header returns a status of 202. When the + process finishes, the URI in the Location header returns a status of 204 on success. If the + asynchronous request failed, the URI in the Location header returns an error-level status code. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_at_subscription_scope_initial( + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> bool: + """Checks whether the deployment exists. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(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 [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def _create_or_update_at_subscription_scope_initial( + self, + deployment_name: str, + parameters: "_models.Deployment", + **kwargs + ) -> "_models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Deployment') + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def begin_create_or_update_at_subscription_scope( + self, + deployment_name: str, + parameters: "_models.Deployment", + **kwargs + ) -> AsyncLROPoller["_models.DeploymentExtended"]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + 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_at_subscription_scope_initial( + deployment_name=deployment_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('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> "_models.DeploymentExtended": + """Gets a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_subscription_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """Cancels a currently running template deployment. + + You can cancel a deployment only if the provisioningState is Accepted or Running. After the + deployment is canceled, the provisioningState is set to Canceled. Canceling a template + deployment stops the currently running template deployment and leaves the resources partially + deployed. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def _validate_at_subscription_scope_initial( + self, + deployment_name: str, + parameters: "_models.Deployment", + **kwargs + ) -> Optional["_models.DeploymentValidateResult"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._validate_at_subscription_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Deployment') + body_content_kwargs['content'] = body_content + request = self._client.post(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, 202, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _validate_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def begin_validate_at_subscription_scope( + self, + deployment_name: str, + parameters: "_models.Deployment", + **kwargs + ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to validate. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] + 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._validate_at_subscription_scope_initial( + deployment_name=deployment_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('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def _what_if_at_subscription_scope_initial( + self, + deployment_name: str, + parameters: "_models.DeploymentWhatIf", + **kwargs + ) -> Optional["_models.WhatIfOperationResult"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._what_if_at_subscription_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'DeploymentWhatIf') + body_content_kwargs['content'] = body_content + request = self._client.post(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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _what_if_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + async def begin_what_if_at_subscription_scope( + self, + deployment_name: str, + parameters: "_models.DeploymentWhatIf", + **kwargs + ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to What If. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIf + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] + 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._what_if_at_subscription_scope_initial( + deployment_name=deployment_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('WhatIfOperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **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_what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + async def export_template_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> "_models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_at_subscription_scope( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["_models.DeploymentListResult"]: + """Get all the deployments for a subscription. + + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :param top: The number of results to get. If null is passed, returns all deployments. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_at_subscription_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self._delete_initial.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\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.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 [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def begin_delete( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> AsyncLROPoller[None]: + """Deletes a deployment from the deployment history. + + A template deployment that is currently running cannot be deleted. Deleting a template + deployment removes the associated deployment operations. Deleting a template deployment does + not affect the state of the resource group. This is an asynchronous operation that returns a + status of 202 until the template deployment is successfully deleted. The Location response + header contains the URI that is used to obtain the status of the process. While the process is + running, a call to the URI in the Location header returns a status of 202. When the process + finishes, the URI in the Location header returns a status of 204 on success. If the + asynchronous request failed, the URI in the Location header returns an error-level status code. + + :param resource_group_name: The name of the resource group with the deployment to delete. The + name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> bool: + """Checks whether the deployment exists. + + :param resource_group_name: The name of the resource group with the deployment to check. The + name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.check_existence.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\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(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 [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + deployment_name: str, + parameters: "_models.Deployment", + **kwargs + ) -> "_models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.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\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Deployment') + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: "_models.Deployment", + **kwargs + ) -> AsyncLROPoller["_models.DeploymentExtended"]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_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('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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.Resources/deployments/{deploymentName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> "_models.DeploymentExtended": + """Gets a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """Cancels a currently running template deployment. + + You can cancel a deployment only if the provisioningState is Accepted or Running. After the + deployment is canceled, the provisioningState is set to Canceled. Canceling a template + deployment stops the currently running template deployment and leaves the resource group + partially deployed. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.cancel.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\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def _validate_initial( + self, + resource_group_name: str, + deployment_name: str, + parameters: "_models.Deployment", + **kwargs + ) -> Optional["_models.DeploymentValidateResult"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._validate_initial.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\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Deployment') + body_content_kwargs['content'] = body_content + request = self._client.post(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, 202, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _validate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def begin_validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: "_models.Deployment", + **kwargs + ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to validate. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] + 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._validate_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_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('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def _what_if_initial( + self, + resource_group_name: str, + deployment_name: str, + parameters: "_models.DeploymentWhatIf", + **kwargs + ) -> Optional["_models.WhatIfOperationResult"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._what_if_initial.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\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'DeploymentWhatIf') + body_content_kwargs['content'] = body_content + request = self._client.post(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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _what_if_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + async def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: "_models.DeploymentWhatIf", + **kwargs + ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to validate. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIf + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] + 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._what_if_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_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('WhatIfOperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **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_what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + async def export_template( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> "_models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.export_template.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\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["_models.DeploymentListResult"]: + """Get all the deployments for a resource group. + + :param resource_group_name: The name of the resource group with the deployments to get. The + name is case insensitive. + :type resource_group_name: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :param top: The number of results to get. If null is passed, returns all deployments. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.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'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + + async def calculate_template_hash( + self, + template: object, + **kwargs + ) -> "_models.TemplateHashResult": + """Calculate the hash of the given template. + + :param template: The template provided to calculate hash. + :type template: object + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateHashResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateHashResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.calculate_template_hash.metadata['url'] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(template, 'object') + body_content_kwargs['content'] = body_content + request = self._client.post(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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TemplateHashResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_operations.py new file mode 100644 index 0000000000000..9b9f544376c68 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_operations.py @@ -0,0 +1,104 @@ +# 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 ClientAuthenticationError, 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 as _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: ~azure.mgmt.resource.resources.v2021_01_01.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.OperationListResult"]: + """Lists all of the available Microsoft.Resources 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.resource.resources.v2021_01_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = 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('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_provider_resource_types_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_provider_resource_types_operations.py new file mode 100644 index 0000000000000..517d3b627cd30 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_provider_resource_types_operations.py @@ -0,0 +1,101 @@ +# 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, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ProviderResourceTypesOperations: + """ProviderResourceTypesOperations 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: ~azure.mgmt.resource.resources.v2021_01_01.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 list( + self, + resource_provider_namespace: str, + expand: Optional[str] = None, + **kwargs + ) -> "_models.ProviderResourceTypeListResult": + """List the resource types for a specified resource provider. + + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ProviderResourceTypeListResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ProviderResourceTypeListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderResourceTypeListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ProviderResourceTypeListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_providers_operations.py new file mode 100644 index 0000000000000..85fbb1ba4c0c2 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_providers_operations.py @@ -0,0 +1,475 @@ +# 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 ClientAuthenticationError, 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 as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ProvidersOperations: + """ProvidersOperations 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: ~azure.mgmt.resource.resources.v2021_01_01.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 unregister( + self, + resource_provider_namespace: str, + **kwargs + ) -> "_models.Provider": + """Unregisters a subscription from a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to unregister. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.unregister.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + async def register_at_management_group_scope( + self, + resource_provider_namespace: str, + group_id: str, + **kwargs + ) -> None: + """Registers a management group with a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to register. + :type resource_provider_namespace: str + :param group_id: The management group ID. + :type group_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.register_at_management_group_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, 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] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + register_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + async def register( + self, + resource_provider_namespace: str, + **kwargs + ) -> "_models.Provider": + """Registers a subscription with a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to register. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.register.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + def list( + self, + top: Optional[int] = None, + expand: Optional[str] = None, + **kwargs + ) -> AsyncIterable["_models.ProviderListResult"]: + """Gets all resource providers for a subscription. + + :param top: The number of results to return. If null is passed returns all deployments. + :type top: int + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + 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('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + + def list_at_tenant_scope( + self, + top: Optional[int] = None, + expand: Optional[str] = None, + **kwargs + ) -> AsyncIterable["_models.ProviderListResult"]: + """Gets all resource providers for the tenant. + + :param top: The number of results to return. If null is passed returns all providers. + :type top: int + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_at_tenant_scope.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + 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('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore + + async def get( + self, + resource_provider_namespace: str, + expand: Optional[str] = None, + **kwargs + ) -> "_models.Provider": + """Gets the specified resource provider. + + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + + async def get_at_tenant_scope( + self, + resource_provider_namespace: str, + expand: Optional[str] = None, + **kwargs + ) -> "_models.Provider": + """Gets the specified resource provider at the tenant level. + + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_tenant_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/{resourceProviderNamespace}'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_resource_groups_operations.py new file mode 100644 index 0000000000000..ee7f7b2002764 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_resource_groups_operations.py @@ -0,0 +1,589 @@ +# 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 ClientAuthenticationError, 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 as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourceGroupsOperations: + """ResourceGroupsOperations 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: ~azure.mgmt.resource.resources.v2021_01_01.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 check_existence( + self, + resource_group_name: str, + **kwargs + ) -> bool: + """Checks whether a resource group exists. + + :param resource_group_name: The name of the resource group to check. 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: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.check_existence.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'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(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 [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + parameters: "_models.ResourceGroup", + **kwargs + ) -> "_models.ResourceGroup": + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + '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'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ResourceGroup') + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self._delete_initial.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'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def begin_delete( + self, + resource_group_name: str, + **kwargs + ) -> AsyncLROPoller[None]: + """Deletes a resource group. + + When you delete a resource group, all of its resources are also deleted. Deleting a resource + group deletes all of its template deployments and currently stored operations. + + :param resource_group_name: The name of the resource group to delete. 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_initial( + resource_group_name=resource_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + 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'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + **kwargs + ) -> "_models.ResourceGroup": + """Gets a resource group. + + :param resource_group_name: The name of the resource group to get. 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: ResourceGroup, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + parameters: "_models.ResourceGroupPatchable", + **kwargs + ) -> "_models.ResourceGroup": + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.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'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def _export_template_initial( + self, + resource_group_name: str, + parameters: "_models.ExportTemplateRequest", + **kwargs + ) -> Optional["_models.ResourceGroupExportResult"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ResourceGroupExportResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._export_template_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + '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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ExportTemplateRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _export_template_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + async def begin_export_template( + self, + resource_group_name: str, + parameters: "_models.ExportTemplateRequest", + **kwargs + ) -> AsyncLROPoller["_models.ResourceGroupExportResult"]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ExportTemplateRequest + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] + 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._export_template_initial( + resource_group_name=resource_group_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('ResourceGroupExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **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_export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["_models.ResourceGroupListResult"]: + """Gets all the resource groups for a subscription. + + :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by + tag names and values. For example, to filter for a tag name and value, use $filter=tagName eq + 'tag1' and tagValue eq 'Value1'. + :type filter: str + :param top: The number of results to return. If null is passed, returns all resource groups. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('ResourceGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_resources_operations.py new file mode 100644 index 0000000000000..8f3dcbf20a37b --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_resources_operations.py @@ -0,0 +1,1527 @@ +# 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 ClientAuthenticationError, 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 as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourcesOperations: + """ResourcesOperations 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: ~azure.mgmt.resource.resources.v2021_01_01.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_by_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["_models.ResourceListResult"]: + """Get all the resources for a resource group. + + :param resource_group_name: The resource group with the resources to get. + :type resource_group_name: str + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When you filter by a tag name and value, + the tags for each resource are not returned in the results.:code:`
`:code:`
`You can use + some properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :param top: The number of results to return. If null is passed, returns all resources. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.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'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore + + async def _move_resources_initial( + self, + source_resource_group_name: str, + parameters: "_models.ResourcesMoveInfo", + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._move_resources_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') + body_content_kwargs['content'] = body_content + request = self._client.post(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 [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + async def begin_move_resources( + self, + source_resource_group_name: str, + parameters: "_models.ResourcesMoveInfo", + **kwargs + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourcesMoveInfo + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._move_resources_initial( + source_resource_group_name=source_resource_group_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): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + async def _validate_move_resources_initial( + self, + source_resource_group_name: str, + parameters: "_models.ResourcesMoveInfo", + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._validate_move_resources_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') + body_content_kwargs['content'] = body_content + request = self._client.post(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 [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + async def begin_validate_move_resources( + self, + source_resource_group_name: str, + parameters: "_models.ResourcesMoveInfo", + **kwargs + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourcesMoveInfo + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._validate_move_resources_initial( + source_resource_group_name=source_resource_group_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): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["_models.ResourceListResult"]: + """Get all the resources in a subscription. + + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When you filter by a tag name and value, + the tags for each resource are not returned in the results.:code:`
`:code:`
`You can use + some properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :param top: The number of results to return. If null is passed, returns all resource groups. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + **kwargs + ) -> bool: + """Checks whether a resource exists. + + :param resource_group_name: The name of the resource group containing the resource to check. + The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. + :type resource_name: str + :param api_version: The API version to use for the operation. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + accept = "application/json" + + # Construct URL + url = self.check_existence.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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(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 [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + accept = "application/json" + + # Construct URL + url = self._delete_initial.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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def begin_delete( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + **kwargs + ) -> AsyncLROPoller[None]: + """Deletes a resource. + + :param resource_group_name: The name of the resource group that contains the resource to + delete. The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource to delete. + :type resource_name: str + :param api_version: The API version to use for the operation. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: "_models.GenericResource", + **kwargs + ) -> Optional["_models.GenericResource"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'GenericResource') + 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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: "_models.GenericResource", + **kwargs + ) -> AsyncLROPoller["_models.GenericResource"]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. + :type resource_type: str + :param resource_name: The name of the resource to create. + :type resource_name: str + :param api_version: The API version to use for the operation. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] + 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( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + 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('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: "_models.GenericResource", + **kwargs + ) -> Optional["_models.GenericResource"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'GenericResource') + 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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: "_models.GenericResource", + **kwargs + ) -> AsyncLROPoller["_models.GenericResource"]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. + :type resource_type: str + :param resource_name: The name of the resource to update. + :type resource_name: str + :param api_version: The API version to use for the operation. + :type api_version: str + :param parameters: Parameters for updating the resource. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] + 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._update_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + 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('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + **kwargs + ) -> "_models.GenericResource": + """Gets a resource. + + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource. + :type resource_type: str + :param resource_name: The name of the resource to get. + :type resource_name: str + :param api_version: The API version to use for the operation. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def check_existence_by_id( + self, + resource_id: str, + api_version: str, + **kwargs + ) -> bool: + """Checks by ID whether a resource exists. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param api_version: The API version to use for the operation. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + accept = "application/json" + + # Construct URL + url = self.check_existence_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(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 [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def _delete_by_id_initial( + self, + resource_id: str, + api_version: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + accept = "application/json" + + # Construct URL + url = self._delete_by_id_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def begin_delete_by_id( + self, + resource_id: str, + api_version: str, + **kwargs + ) -> AsyncLROPoller[None]: + """Deletes a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param api_version: The API version to use for the operation. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_by_id_initial( + resource_id=resource_id, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def _create_or_update_by_id_initial( + self, + resource_id: str, + api_version: str, + parameters: "_models.GenericResource", + **kwargs + ) -> Optional["_models.GenericResource"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'GenericResource') + 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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: "_models.GenericResource", + **kwargs + ) -> AsyncLROPoller["_models.GenericResource"]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param api_version: The API version to use for the operation. + :type api_version: str + :param parameters: Create or update resource parameters. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] + 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_by_id_initial( + resource_id=resource_id, + api_version=api_version, + 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('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def _update_by_id_initial( + self, + resource_id: str, + api_version: str, + parameters: "_models.GenericResource", + **kwargs + ) -> Optional["_models.GenericResource"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_by_id_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'GenericResource') + 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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: "_models.GenericResource", + **kwargs + ) -> AsyncLROPoller["_models.GenericResource"]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param api_version: The API version to use for the operation. + :type api_version: str + :param parameters: Update resource parameters. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] + 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._update_by_id_initial( + resource_id=resource_id, + api_version=api_version, + 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('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def get_by_id( + self, + resource_id: str, + api_version: str, + **kwargs + ) -> "_models.GenericResource": + """Gets a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param api_version: The API version to use for the operation. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + accept = "application/json" + + # Construct URL + url = self.get_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_tags_operations.py new file mode 100644 index 0000000000000..59ed54caabebe --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_tags_operations.py @@ -0,0 +1,594 @@ +# 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 ClientAuthenticationError, 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 as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TagsOperations: + """TagsOperations 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: ~azure.mgmt.resource.resources.v2021_01_01.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 delete_value( + self, + tag_name: str, + tag_value: str, + **kwargs + ) -> None: + """Deletes a predefined tag value for a predefined tag name. + + This operation allows deleting a value from the list of predefined values for an existing + predefined tag name. The value being deleted must not be in use as a tag value for the given + tag name for any resource. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag to delete. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.delete_value.metadata['url'] # type: ignore + path_format_arguments = { + 'tagName': self._serialize.url("tag_name", tag_name, 'str'), + 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + async def create_or_update_value( + self, + tag_name: str, + tag_value: str, + **kwargs + ) -> "_models.TagValue": + """Creates a predefined value for a predefined tag name. + + This operation allows adding a value to the list of predefined values for an existing + predefined tag name. A tag value can have a maximum of 256 characters. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag to create. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagValue, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.create_or_update_value.metadata['url'] # type: ignore + path_format_arguments = { + 'tagName': self._serialize.url("tag_name", tag_name, 'str'), + 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.put(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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('TagValue', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + async def create_or_update( + self, + tag_name: str, + **kwargs + ) -> "_models.TagDetails": + """Creates a predefined tag name. + + This operation allows adding a name to the list of predefined tag names for the given + subscription. A tag name can have a maximum of 512 characters and is case-insensitive. Tag + names cannot have the following prefixes which are reserved for Azure use: 'microsoft', + 'azure', 'windows'. + + :param tag_name: The name of the tag to create. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDetails, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'tagName': self._serialize.url("tag_name", tag_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.put(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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + async def delete( + self, + tag_name: str, + **kwargs + ) -> None: + """Deletes a predefined tag name. + + This operation allows deleting a name from the list of predefined tag names for the given + subscription. The name being deleted must not be in use as a tag name for any resource. All + predefined values for the given name must have already been deleted. + + :param tag_name: The name of the tag. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'tagName': self._serialize.url("tag_name", tag_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["_models.TagsListResult"]: + """Gets a summary of tag usage under the subscription. + + This operation performs a union of predefined tags, resource tags, resource group tags and + subscription tags, and returns a summary of usage for each tag name and value under the given + subscription. In case of a large number of tags, this operation may return a previously cached + result. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TagsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.TagsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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('TagsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore + + async def create_or_update_at_scope( + self, + scope: str, + parameters: "_models.TagsResource", + **kwargs + ) -> "_models.TagsResource": + """Creates or updates the entire set of tags on a resource or subscription. + + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. + + :param scope: The resource scope. + :type scope: str + :param parameters: + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update_at_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'TagsResource') + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TagsResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + async def update_at_scope( + self, + scope: str, + parameters: "_models.TagsPatchResource", + **kwargs + ) -> "_models.TagsResource": + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The resource scope. + :type scope: str + :param parameters: + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsPatchResource + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update_at_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'TagsPatchResource') + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TagsResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + async def get_at_scope( + self, + scope: str, + **kwargs + ) -> "_models.TagsResource": + """Gets the entire set of tags on a resource or subscription. + + Gets the entire set of tags on a resource or subscription. + + :param scope: The resource scope. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TagsResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + async def delete_at_scope( + self, + scope: str, + **kwargs + ) -> None: + """Deletes the entire set of tags on a resource or subscription. + + Deletes the entire set of tags on a resource or subscription. + + :param scope: The resource scope. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.delete_at_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/__init__.py new file mode 100644 index 0000000000000..ddf599b2f51fd --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/__init__.py @@ -0,0 +1,268 @@ +# 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. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import Alias + from ._models_py3 import AliasPath + from ._models_py3 import AliasPathMetadata + from ._models_py3 import AliasPattern + from ._models_py3 import ApiProfile + from ._models_py3 import BasicDependency + from ._models_py3 import DebugSetting + from ._models_py3 import Dependency + from ._models_py3 import Deployment + from ._models_py3 import DeploymentExportResult + from ._models_py3 import DeploymentExtended + from ._models_py3 import DeploymentExtendedFilter + from ._models_py3 import DeploymentListResult + from ._models_py3 import DeploymentOperation + from ._models_py3 import DeploymentOperationProperties + from ._models_py3 import DeploymentOperationsListResult + from ._models_py3 import DeploymentProperties + from ._models_py3 import DeploymentPropertiesExtended + from ._models_py3 import DeploymentValidateResult + from ._models_py3 import DeploymentWhatIf + from ._models_py3 import DeploymentWhatIfProperties + from ._models_py3 import DeploymentWhatIfSettings + from ._models_py3 import ErrorAdditionalInfo + from ._models_py3 import ErrorResponse + from ._models_py3 import ExportTemplateRequest + from ._models_py3 import ExpressionEvaluationOptions + from ._models_py3 import ExtendedLocation + from ._models_py3 import GenericResource + from ._models_py3 import GenericResourceExpanded + from ._models_py3 import GenericResourceFilter + from ._models_py3 import HttpMessage + from ._models_py3 import Identity + from ._models_py3 import IdentityUserAssignedIdentitiesValue + from ._models_py3 import OnErrorDeployment + from ._models_py3 import OnErrorDeploymentExtended + from ._models_py3 import Operation + from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult + from ._models_py3 import ParametersLink + from ._models_py3 import Plan + from ._models_py3 import Provider + from ._models_py3 import ProviderExtendedLocation + from ._models_py3 import ProviderListResult + from ._models_py3 import ProviderResourceType + from ._models_py3 import ProviderResourceTypeListResult + from ._models_py3 import Resource + from ._models_py3 import ResourceGroup + from ._models_py3 import ResourceGroupExportResult + from ._models_py3 import ResourceGroupFilter + from ._models_py3 import ResourceGroupListResult + from ._models_py3 import ResourceGroupPatchable + from ._models_py3 import ResourceGroupProperties + from ._models_py3 import ResourceListResult + from ._models_py3 import ResourceProviderOperationDisplayProperties + from ._models_py3 import ResourceReference + from ._models_py3 import ResourcesMoveInfo + from ._models_py3 import ScopedDeployment + from ._models_py3 import ScopedDeploymentWhatIf + from ._models_py3 import Sku + from ._models_py3 import StatusMessage + from ._models_py3 import SubResource + from ._models_py3 import TagCount + from ._models_py3 import TagDetails + from ._models_py3 import TagValue + from ._models_py3 import Tags + from ._models_py3 import TagsListResult + from ._models_py3 import TagsPatchResource + from ._models_py3 import TagsResource + from ._models_py3 import TargetResource + from ._models_py3 import TemplateHashResult + from ._models_py3 import TemplateLink + from ._models_py3 import WhatIfChange + from ._models_py3 import WhatIfOperationResult + from ._models_py3 import WhatIfPropertyChange +except (SyntaxError, ImportError): + from ._models import Alias # type: ignore + from ._models import AliasPath # type: ignore + from ._models import AliasPathMetadata # type: ignore + from ._models import AliasPattern # type: ignore + from ._models import ApiProfile # type: ignore + from ._models import BasicDependency # type: ignore + from ._models import DebugSetting # type: ignore + from ._models import Dependency # type: ignore + from ._models import Deployment # type: ignore + from ._models import DeploymentExportResult # type: ignore + from ._models import DeploymentExtended # type: ignore + from ._models import DeploymentExtendedFilter # type: ignore + from ._models import DeploymentListResult # type: ignore + from ._models import DeploymentOperation # type: ignore + from ._models import DeploymentOperationProperties # type: ignore + from ._models import DeploymentOperationsListResult # type: ignore + from ._models import DeploymentProperties # type: ignore + from ._models import DeploymentPropertiesExtended # type: ignore + from ._models import DeploymentValidateResult # type: ignore + from ._models import DeploymentWhatIf # type: ignore + from ._models import DeploymentWhatIfProperties # type: ignore + from ._models import DeploymentWhatIfSettings # type: ignore + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import ExportTemplateRequest # type: ignore + from ._models import ExpressionEvaluationOptions # type: ignore + from ._models import ExtendedLocation # type: ignore + from ._models import GenericResource # type: ignore + from ._models import GenericResourceExpanded # type: ignore + from ._models import GenericResourceFilter # type: ignore + from ._models import HttpMessage # type: ignore + from ._models import Identity # type: ignore + from ._models import IdentityUserAssignedIdentitiesValue # type: ignore + from ._models import OnErrorDeployment # type: ignore + from ._models import OnErrorDeploymentExtended # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import ParametersLink # type: ignore + from ._models import Plan # type: ignore + from ._models import Provider # type: ignore + from ._models import ProviderExtendedLocation # type: ignore + from ._models import ProviderListResult # type: ignore + from ._models import ProviderResourceType # type: ignore + from ._models import ProviderResourceTypeListResult # type: ignore + from ._models import Resource # type: ignore + from ._models import ResourceGroup # type: ignore + from ._models import ResourceGroupExportResult # type: ignore + from ._models import ResourceGroupFilter # type: ignore + from ._models import ResourceGroupListResult # type: ignore + from ._models import ResourceGroupPatchable # type: ignore + from ._models import ResourceGroupProperties # type: ignore + from ._models import ResourceListResult # type: ignore + from ._models import ResourceProviderOperationDisplayProperties # type: ignore + from ._models import ResourceReference # type: ignore + from ._models import ResourcesMoveInfo # type: ignore + from ._models import ScopedDeployment # type: ignore + from ._models import ScopedDeploymentWhatIf # type: ignore + from ._models import Sku # type: ignore + from ._models import StatusMessage # type: ignore + from ._models import SubResource # type: ignore + from ._models import TagCount # type: ignore + from ._models import TagDetails # type: ignore + from ._models import TagValue # type: ignore + from ._models import Tags # type: ignore + from ._models import TagsListResult # type: ignore + from ._models import TagsPatchResource # type: ignore + from ._models import TagsResource # type: ignore + from ._models import TargetResource # type: ignore + from ._models import TemplateHashResult # type: ignore + from ._models import TemplateLink # type: ignore + from ._models import WhatIfChange # type: ignore + from ._models import WhatIfOperationResult # type: ignore + from ._models import WhatIfPropertyChange # type: ignore + +from ._resource_management_client_enums import ( + AliasPathAttributes, + AliasPathTokenType, + AliasPatternType, + AliasType, + ChangeType, + DeploymentMode, + ExpressionEvaluationOptionsScopeType, + ExtendedLocationType, + OnErrorDeploymentType, + PropertyChangeType, + ProvisioningOperation, + ProvisioningState, + ResourceIdentityType, + TagsPatchOperation, + WhatIfResultFormat, +) + +__all__ = [ + 'Alias', + 'AliasPath', + 'AliasPathMetadata', + 'AliasPattern', + 'ApiProfile', + 'BasicDependency', + 'DebugSetting', + 'Dependency', + 'Deployment', + 'DeploymentExportResult', + 'DeploymentExtended', + 'DeploymentExtendedFilter', + 'DeploymentListResult', + 'DeploymentOperation', + 'DeploymentOperationProperties', + 'DeploymentOperationsListResult', + 'DeploymentProperties', + 'DeploymentPropertiesExtended', + 'DeploymentValidateResult', + 'DeploymentWhatIf', + 'DeploymentWhatIfProperties', + 'DeploymentWhatIfSettings', + 'ErrorAdditionalInfo', + 'ErrorResponse', + 'ExportTemplateRequest', + 'ExpressionEvaluationOptions', + 'ExtendedLocation', + 'GenericResource', + 'GenericResourceExpanded', + 'GenericResourceFilter', + 'HttpMessage', + 'Identity', + 'IdentityUserAssignedIdentitiesValue', + 'OnErrorDeployment', + 'OnErrorDeploymentExtended', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'ParametersLink', + 'Plan', + 'Provider', + 'ProviderExtendedLocation', + 'ProviderListResult', + 'ProviderResourceType', + 'ProviderResourceTypeListResult', + 'Resource', + 'ResourceGroup', + 'ResourceGroupExportResult', + 'ResourceGroupFilter', + 'ResourceGroupListResult', + 'ResourceGroupPatchable', + 'ResourceGroupProperties', + 'ResourceListResult', + 'ResourceProviderOperationDisplayProperties', + 'ResourceReference', + 'ResourcesMoveInfo', + 'ScopedDeployment', + 'ScopedDeploymentWhatIf', + 'Sku', + 'StatusMessage', + 'SubResource', + 'TagCount', + 'TagDetails', + 'TagValue', + 'Tags', + 'TagsListResult', + 'TagsPatchResource', + 'TagsResource', + 'TargetResource', + 'TemplateHashResult', + 'TemplateLink', + 'WhatIfChange', + 'WhatIfOperationResult', + 'WhatIfPropertyChange', + 'AliasPathAttributes', + 'AliasPathTokenType', + 'AliasPatternType', + 'AliasType', + 'ChangeType', + 'DeploymentMode', + 'ExpressionEvaluationOptionsScopeType', + 'ExtendedLocationType', + 'OnErrorDeploymentType', + 'PropertyChangeType', + 'ProvisioningOperation', + 'ProvisioningState', + 'ResourceIdentityType', + 'TagsPatchOperation', + 'WhatIfResultFormat', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_models.py new file mode 100644 index 0000000000000..364de8c61cf36 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_models.py @@ -0,0 +1,2584 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import msrest.serialization + + +class Alias(msrest.serialization.Model): + """The alias type. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param name: The alias name. + :type name: str + :param paths: The paths for an alias. + :type paths: list[~azure.mgmt.resource.resources.v2021_01_01.models.AliasPath] + :param type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + "Mask". + :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasType + :param default_path: The default path for an alias. + :type default_path: str + :param default_pattern: The default pattern for an alias. + :type default_pattern: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPattern + :ivar default_metadata: The default alias path metadata. Applies to the default path and to any + alias path that doesn't have metadata. + :vartype default_metadata: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPathMetadata + """ + + _validation = { + 'default_metadata': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'paths': {'key': 'paths', 'type': '[AliasPath]'}, + 'type': {'key': 'type', 'type': 'str'}, + 'default_path': {'key': 'defaultPath', 'type': 'str'}, + 'default_pattern': {'key': 'defaultPattern', 'type': 'AliasPattern'}, + 'default_metadata': {'key': 'defaultMetadata', 'type': 'AliasPathMetadata'}, + } + + def __init__( + self, + **kwargs + ): + super(Alias, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.paths = kwargs.get('paths', None) + self.type = kwargs.get('type', None) + self.default_path = kwargs.get('default_path', None) + self.default_pattern = kwargs.get('default_pattern', None) + self.default_metadata = None + + +class AliasPath(msrest.serialization.Model): + """The type of the paths for alias. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param path: The path of an alias. + :type path: str + :param api_versions: The API versions. + :type api_versions: list[str] + :param pattern: The pattern for an alias path. + :type pattern: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPattern + :ivar metadata: The metadata of the alias path. If missing, fall back to the default metadata + of the alias. + :vartype metadata: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPathMetadata + """ + + _validation = { + 'metadata': {'readonly': True}, + } + + _attribute_map = { + 'path': {'key': 'path', 'type': 'str'}, + 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, + 'pattern': {'key': 'pattern', 'type': 'AliasPattern'}, + 'metadata': {'key': 'metadata', 'type': 'AliasPathMetadata'}, + } + + def __init__( + self, + **kwargs + ): + super(AliasPath, self).__init__(**kwargs) + self.path = kwargs.get('path', None) + self.api_versions = kwargs.get('api_versions', None) + self.pattern = kwargs.get('pattern', None) + self.metadata = None + + +class AliasPathMetadata(msrest.serialization.Model): + """AliasPathMetadata. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The type of the token that the alias path is referring to. Possible values include: + "NotSpecified", "Any", "String", "Object", "Array", "Integer", "Number", "Boolean". + :vartype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPathTokenType + :ivar attributes: The attributes of the token that the alias path is referring to. Possible + values include: "None", "Modifiable". + :vartype attributes: str or + ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPathAttributes + """ + + _validation = { + 'type': {'readonly': True}, + 'attributes': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'attributes': {'key': 'attributes', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AliasPathMetadata, self).__init__(**kwargs) + self.type = None + self.attributes = None + + +class AliasPattern(msrest.serialization.Model): + """The type of the pattern for an alias path. + + :param phrase: The alias pattern phrase. + :type phrase: str + :param variable: The alias pattern variable. + :type variable: str + :param type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPatternType + """ + + _attribute_map = { + 'phrase': {'key': 'phrase', 'type': 'str'}, + 'variable': {'key': 'variable', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AliasPattern, self).__init__(**kwargs) + self.phrase = kwargs.get('phrase', None) + self.variable = kwargs.get('variable', None) + self.type = kwargs.get('type', None) + + +class ApiProfile(msrest.serialization.Model): + """ApiProfile. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar profile_version: The profile version. + :vartype profile_version: str + :ivar api_version: The API version. + :vartype api_version: str + """ + + _validation = { + 'profile_version': {'readonly': True}, + 'api_version': {'readonly': True}, + } + + _attribute_map = { + 'profile_version': {'key': 'profileVersion', 'type': 'str'}, + 'api_version': {'key': 'apiVersion', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ApiProfile, self).__init__(**kwargs) + self.profile_version = None + self.api_version = None + + +class BasicDependency(msrest.serialization.Model): + """Deployment dependency information. + + :param id: The ID of the dependency. + :type id: str + :param resource_type: The dependency resource type. + :type resource_type: str + :param resource_name: The dependency resource name. + :type resource_name: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'resource_name': {'key': 'resourceName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BasicDependency, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.resource_type = kwargs.get('resource_type', None) + self.resource_name = kwargs.get('resource_name', None) + + +class DebugSetting(msrest.serialization.Model): + """The debug setting. + + :param detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :type detail_level: str + """ + + _attribute_map = { + 'detail_level': {'key': 'detailLevel', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DebugSetting, self).__init__(**kwargs) + self.detail_level = kwargs.get('detail_level', None) + + +class Dependency(msrest.serialization.Model): + """Deployment dependency information. + + :param depends_on: The list of dependencies. + :type depends_on: list[~azure.mgmt.resource.resources.v2021_01_01.models.BasicDependency] + :param id: The ID of the dependency. + :type id: str + :param resource_type: The dependency resource type. + :type resource_type: str + :param resource_name: The dependency resource name. + :type resource_name: str + """ + + _attribute_map = { + 'depends_on': {'key': 'dependsOn', 'type': '[BasicDependency]'}, + 'id': {'key': 'id', 'type': 'str'}, + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'resource_name': {'key': 'resourceName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Dependency, self).__init__(**kwargs) + self.depends_on = kwargs.get('depends_on', None) + self.id = kwargs.get('id', None) + self.resource_type = kwargs.get('resource_type', None) + self.resource_name = kwargs.get('resource_name', None) + + +class Deployment(msrest.serialization.Model): + """Deployment operation parameters. + + All required parameters must be populated in order to send to Azure. + + :param location: The location to store the deployment data. + :type location: str + :param properties: Required. The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentProperties + :param tags: A set of tags. Deployment tags. + :type tags: dict[str, str] + """ + + _validation = { + 'properties': {'required': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(Deployment, self).__init__(**kwargs) + self.location = kwargs.get('location', None) + self.properties = kwargs['properties'] + self.tags = kwargs.get('tags', None) + + +class DeploymentExportResult(msrest.serialization.Model): + """The deployment export result. + + :param template: The template content. + :type template: object + """ + + _attribute_map = { + 'template': {'key': 'template', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentExportResult, self).__init__(**kwargs) + self.template = kwargs.get('template', None) + + +class DeploymentExtended(msrest.serialization.Model): + """Deployment information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the deployment. + :vartype id: str + :ivar name: The name of the deployment. + :vartype name: str + :ivar type: The type of the deployment. + :vartype type: str + :param location: the location of the deployment. + :type location: str + :param properties: Deployment properties. + :type properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentPropertiesExtended + :param tags: A set of tags. Deployment tags. + :type tags: dict[str, 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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentExtended, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = kwargs.get('location', None) + self.properties = kwargs.get('properties', None) + self.tags = kwargs.get('tags', None) + + +class DeploymentExtendedFilter(msrest.serialization.Model): + """Deployment filter. + + :param provisioning_state: The provisioning state. + :type provisioning_state: str + """ + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentExtendedFilter, self).__init__(**kwargs) + self.provisioning_state = kwargs.get('provisioning_state', None) + + +class DeploymentListResult(msrest.serialization.Model): + """List of deployments. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: An array of deployments. + :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class DeploymentOperation(msrest.serialization.Model): + """Deployment operation information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Full deployment operation ID. + :vartype id: str + :ivar operation_id: Deployment operation ID. + :vartype operation_id: str + :param properties: Deployment properties. + :type properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'operation_id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'operation_id': {'key': 'operationId', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentOperation, self).__init__(**kwargs) + self.id = None + self.operation_id = None + self.properties = kwargs.get('properties', None) + + +class DeploymentOperationProperties(msrest.serialization.Model): + """Deployment operation properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_operation: The name of the current provisioning operation. Possible values + include: "NotSpecified", "Create", "Delete", "Waiting", "AzureAsyncOperationWaiting", + "ResourceCacheWaiting", "Action", "Read", "EvaluateDeploymentOutput", "DeploymentCleanup". + :vartype provisioning_operation: str or + ~azure.mgmt.resource.resources.v2021_01_01.models.ProvisioningOperation + :ivar provisioning_state: The state of the provisioning. + :vartype provisioning_state: str + :ivar timestamp: The date and time of the operation. + :vartype timestamp: ~datetime.datetime + :ivar duration: The duration of the operation. + :vartype duration: str + :ivar service_request_id: Deployment operation service request id. + :vartype service_request_id: str + :ivar status_code: Operation status code from the resource provider. This property may not be + set if a response has not yet been received. + :vartype status_code: str + :ivar status_message: Operation status message from the resource provider. This property is + optional. It will only be provided if an error was received from the resource provider. + :vartype status_message: ~azure.mgmt.resource.resources.v2021_01_01.models.StatusMessage + :ivar target_resource: The target resource. + :vartype target_resource: ~azure.mgmt.resource.resources.v2021_01_01.models.TargetResource + :ivar request: The HTTP request message. + :vartype request: ~azure.mgmt.resource.resources.v2021_01_01.models.HttpMessage + :ivar response: The HTTP response message. + :vartype response: ~azure.mgmt.resource.resources.v2021_01_01.models.HttpMessage + """ + + _validation = { + 'provisioning_operation': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'timestamp': {'readonly': True}, + 'duration': {'readonly': True}, + 'service_request_id': {'readonly': True}, + 'status_code': {'readonly': True}, + 'status_message': {'readonly': True}, + 'target_resource': {'readonly': True}, + 'request': {'readonly': True}, + 'response': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_operation': {'key': 'provisioningOperation', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + 'duration': {'key': 'duration', 'type': 'str'}, + 'service_request_id': {'key': 'serviceRequestId', 'type': 'str'}, + 'status_code': {'key': 'statusCode', 'type': 'str'}, + 'status_message': {'key': 'statusMessage', 'type': 'StatusMessage'}, + 'target_resource': {'key': 'targetResource', 'type': 'TargetResource'}, + 'request': {'key': 'request', 'type': 'HttpMessage'}, + 'response': {'key': 'response', 'type': 'HttpMessage'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentOperationProperties, self).__init__(**kwargs) + self.provisioning_operation = None + self.provisioning_state = None + self.timestamp = None + self.duration = None + self.service_request_id = None + self.status_code = None + self.status_message = None + self.target_resource = None + self.request = None + self.response = None + + +class DeploymentOperationsListResult(msrest.serialization.Model): + """List of deployment operations. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: An array of deployment operations. + :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentOperationsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class DeploymentProperties(msrest.serialization.Model): + """Deployment properties. + + All required parameters must be populated in order to send to Azure. + + :param template: The template content. You use this element when you want to pass the template + syntax directly in the request rather than link to an existing template. It can be a JObject or + well-formed JSON string. Use either the templateLink property or the template property, but not + both. + :type template: object + :param template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :type template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink + :param parameters: Name and value pairs that define the deployment parameters for the template. + You use this element when you want to provide the parameter values directly in the request + rather than link to an existing parameter file. Use either the parametersLink property or the + parameters property, but not both. It can be a JObject or a well formed JSON string. + :type parameters: object + :param parameters_link: The URI of parameters file. You use this element to link to an existing + parameters file. Use either the parametersLink property or the parameters property, but not + both. + :type parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink + :param mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :type mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode + :param debug_setting: The debug setting of the deployment. + :type debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting + :param on_error_deployment: The deployment on error behavior. + :type on_error_deployment: ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeployment + :param expression_evaluation_options: Specifies whether template expressions are evaluated + within the scope of the parent template or nested template. Only applicable to nested + templates. If not specified, default value is outer. + :type expression_evaluation_options: + ~azure.mgmt.resource.resources.v2021_01_01.models.ExpressionEvaluationOptions + """ + + _validation = { + 'mode': {'required': True}, + } + + _attribute_map = { + 'template': {'key': 'template', 'type': 'object'}, + 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, + 'parameters': {'key': 'parameters', 'type': 'object'}, + 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, + 'mode': {'key': 'mode', 'type': 'str'}, + 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, + 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, + 'expression_evaluation_options': {'key': 'expressionEvaluationOptions', 'type': 'ExpressionEvaluationOptions'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentProperties, self).__init__(**kwargs) + self.template = kwargs.get('template', None) + self.template_link = kwargs.get('template_link', None) + self.parameters = kwargs.get('parameters', None) + self.parameters_link = kwargs.get('parameters_link', None) + self.mode = kwargs['mode'] + self.debug_setting = kwargs.get('debug_setting', None) + self.on_error_deployment = kwargs.get('on_error_deployment', None) + self.expression_evaluation_options = kwargs.get('expression_evaluation_options', None) + + +class DeploymentPropertiesExtended(msrest.serialization.Model): + """Deployment properties with additional details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Denotes the state of provisioning. Possible values include: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.resource.resources.v2021_01_01.models.ProvisioningState + :ivar correlation_id: The correlation ID of the deployment. + :vartype correlation_id: str + :ivar timestamp: The timestamp of the template deployment. + :vartype timestamp: ~datetime.datetime + :ivar duration: The duration of the template deployment. + :vartype duration: str + :ivar outputs: Key/value pairs that represent deployment output. + :vartype outputs: object + :ivar providers: The list of resource providers needed for the deployment. + :vartype providers: list[~azure.mgmt.resource.resources.v2021_01_01.models.Provider] + :ivar dependencies: The list of deployment dependencies. + :vartype dependencies: list[~azure.mgmt.resource.resources.v2021_01_01.models.Dependency] + :ivar template_link: The URI referencing the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink + :ivar parameters: Deployment parameters. + :vartype parameters: object + :ivar parameters_link: The URI referencing the parameters. + :vartype parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values + include: "Incremental", "Complete". + :vartype mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeploymentExtended + :ivar template_hash: The hash produced for the template. + :vartype template_hash: str + :ivar output_resources: Array of provisioned resources. + :vartype output_resources: + list[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceReference] + :ivar validated_resources: Array of validated resources. + :vartype validated_resources: + list[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceReference] + :ivar error: The deployment error. + :vartype error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + 'correlation_id': {'readonly': True}, + 'timestamp': {'readonly': True}, + 'duration': {'readonly': True}, + 'outputs': {'readonly': True}, + 'providers': {'readonly': True}, + 'dependencies': {'readonly': True}, + 'template_link': {'readonly': True}, + 'parameters': {'readonly': True}, + 'parameters_link': {'readonly': True}, + 'mode': {'readonly': True}, + 'debug_setting': {'readonly': True}, + 'on_error_deployment': {'readonly': True}, + 'template_hash': {'readonly': True}, + 'output_resources': {'readonly': True}, + 'validated_resources': {'readonly': True}, + 'error': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'correlation_id': {'key': 'correlationId', 'type': 'str'}, + 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + 'duration': {'key': 'duration', 'type': 'str'}, + 'outputs': {'key': 'outputs', 'type': 'object'}, + 'providers': {'key': 'providers', 'type': '[Provider]'}, + 'dependencies': {'key': 'dependencies', 'type': '[Dependency]'}, + 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, + 'parameters': {'key': 'parameters', 'type': 'object'}, + 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, + 'mode': {'key': 'mode', 'type': 'str'}, + 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, + 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, + 'template_hash': {'key': 'templateHash', 'type': 'str'}, + 'output_resources': {'key': 'outputResources', 'type': '[ResourceReference]'}, + 'validated_resources': {'key': 'validatedResources', 'type': '[ResourceReference]'}, + 'error': {'key': 'error', 'type': 'ErrorResponse'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentPropertiesExtended, self).__init__(**kwargs) + self.provisioning_state = None + self.correlation_id = None + self.timestamp = None + self.duration = None + self.outputs = None + self.providers = None + self.dependencies = None + self.template_link = None + self.parameters = None + self.parameters_link = None + self.mode = None + self.debug_setting = None + self.on_error_deployment = None + self.template_hash = None + self.output_resources = None + self.validated_resources = None + self.error = None + + +class DeploymentValidateResult(msrest.serialization.Model): + """Information from validate template deployment response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar error: The deployment validation error. + :vartype error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse + :param properties: The template deployment properties. + :type properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentPropertiesExtended + """ + + _validation = { + 'error': {'readonly': True}, + } + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponse'}, + 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentValidateResult, self).__init__(**kwargs) + self.error = None + self.properties = kwargs.get('properties', None) + + +class DeploymentWhatIf(msrest.serialization.Model): + """Deployment What-if operation parameters. + + All required parameters must be populated in order to send to Azure. + + :param location: The location to store the deployment data. + :type location: str + :param properties: Required. The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfProperties + """ + + _validation = { + 'properties': {'required': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'DeploymentWhatIfProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentWhatIf, self).__init__(**kwargs) + self.location = kwargs.get('location', None) + self.properties = kwargs['properties'] + + +class DeploymentWhatIfProperties(DeploymentProperties): + """Deployment What-if properties. + + All required parameters must be populated in order to send to Azure. + + :param template: The template content. You use this element when you want to pass the template + syntax directly in the request rather than link to an existing template. It can be a JObject or + well-formed JSON string. Use either the templateLink property or the template property, but not + both. + :type template: object + :param template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :type template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink + :param parameters: Name and value pairs that define the deployment parameters for the template. + You use this element when you want to provide the parameter values directly in the request + rather than link to an existing parameter file. Use either the parametersLink property or the + parameters property, but not both. It can be a JObject or a well formed JSON string. + :type parameters: object + :param parameters_link: The URI of parameters file. You use this element to link to an existing + parameters file. Use either the parametersLink property or the parameters property, but not + both. + :type parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink + :param mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :type mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode + :param debug_setting: The debug setting of the deployment. + :type debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting + :param on_error_deployment: The deployment on error behavior. + :type on_error_deployment: ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeployment + :param expression_evaluation_options: Specifies whether template expressions are evaluated + within the scope of the parent template or nested template. Only applicable to nested + templates. If not specified, default value is outer. + :type expression_evaluation_options: + ~azure.mgmt.resource.resources.v2021_01_01.models.ExpressionEvaluationOptions + :param what_if_settings: Optional What-If operation settings. + :type what_if_settings: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfSettings + """ + + _validation = { + 'mode': {'required': True}, + } + + _attribute_map = { + 'template': {'key': 'template', 'type': 'object'}, + 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, + 'parameters': {'key': 'parameters', 'type': 'object'}, + 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, + 'mode': {'key': 'mode', 'type': 'str'}, + 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, + 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, + 'expression_evaluation_options': {'key': 'expressionEvaluationOptions', 'type': 'ExpressionEvaluationOptions'}, + 'what_if_settings': {'key': 'whatIfSettings', 'type': 'DeploymentWhatIfSettings'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentWhatIfProperties, self).__init__(**kwargs) + self.what_if_settings = kwargs.get('what_if_settings', None) + + +class DeploymentWhatIfSettings(msrest.serialization.Model): + """Deployment What-If operation settings. + + :param result_format: The format of the What-If results. Possible values include: + "ResourceIdOnly", "FullResourcePayloads". + :type result_format: str or + ~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfResultFormat + """ + + _attribute_map = { + 'result_format': {'key': 'resultFormat', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentWhatIfSettings, self).__init__(**kwargs) + self.result_format = kwargs.get('result_format', 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): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.resource.resources.v2021_01_01.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(ErrorResponse, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ExportTemplateRequest(msrest.serialization.Model): + """Export resource group template request parameters. + + :param resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :type resources: list[str] + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :type options: str + """ + + _attribute_map = { + 'resources': {'key': 'resources', 'type': '[str]'}, + 'options': {'key': 'options', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExportTemplateRequest, self).__init__(**kwargs) + self.resources = kwargs.get('resources', None) + self.options = kwargs.get('options', None) + + +class ExpressionEvaluationOptions(msrest.serialization.Model): + """Specifies whether template expressions are evaluated within the scope of the parent template or nested template. + + :param scope: The scope to be used for evaluation of parameters, variables and functions in a + nested template. Possible values include: "NotSpecified", "Outer", "Inner". + :type scope: str or + ~azure.mgmt.resource.resources.v2021_01_01.models.ExpressionEvaluationOptionsScopeType + """ + + _attribute_map = { + 'scope': {'key': 'scope', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExpressionEvaluationOptions, self).__init__(**kwargs) + self.scope = kwargs.get('scope', None) + + +class ExtendedLocation(msrest.serialization.Model): + """Resource extended location. + + :param type: The extended location type. Possible values include: "EdgeZone". + :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocationType + :param name: The extended location name. + :type name: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExtendedLocation, self).__init__(**kwargs) + self.type = kwargs.get('type', None) + self.name = kwargs.get('name', None) + + +class Resource(msrest.serialization.Model): + """Specified resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param location: Resource location. + :type location: str + :param extended_location: Resource extended location. + :type extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation + :param tags: A set of tags. Resource tags. + :type tags: dict[str, 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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = kwargs.get('location', None) + self.extended_location = kwargs.get('extended_location', None) + self.tags = kwargs.get('tags', None) + + +class GenericResource(Resource): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param location: Resource location. + :type location: str + :param extended_location: Resource extended location. + :type extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param plan: The plan of the resource. + :type plan: ~azure.mgmt.resource.resources.v2021_01_01.models.Plan + :param properties: The resource properties. + :type properties: object + :param kind: The kind of the resource. + :type kind: str + :param managed_by: ID of the resource that manages this resource. + :type managed_by: str + :param sku: The SKU of the resource. + :type sku: ~azure.mgmt.resource.resources.v2021_01_01.models.Sku + :param identity: The identity of the resource. + :type identity: ~azure.mgmt.resource.resources.v2021_01_01.models.Identity + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'plan': {'key': 'plan', 'type': 'Plan'}, + 'properties': {'key': 'properties', 'type': 'object'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + } + + def __init__( + self, + **kwargs + ): + super(GenericResource, self).__init__(**kwargs) + self.plan = kwargs.get('plan', None) + self.properties = kwargs.get('properties', None) + self.kind = kwargs.get('kind', None) + self.managed_by = kwargs.get('managed_by', None) + self.sku = kwargs.get('sku', None) + self.identity = kwargs.get('identity', None) + + +class GenericResourceExpanded(GenericResource): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param location: Resource location. + :type location: str + :param extended_location: Resource extended location. + :type extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param plan: The plan of the resource. + :type plan: ~azure.mgmt.resource.resources.v2021_01_01.models.Plan + :param properties: The resource properties. + :type properties: object + :param kind: The kind of the resource. + :type kind: str + :param managed_by: ID of the resource that manages this resource. + :type managed_by: str + :param sku: The SKU of the resource. + :type sku: ~azure.mgmt.resource.resources.v2021_01_01.models.Sku + :param identity: The identity of the resource. + :type identity: ~azure.mgmt.resource.resources.v2021_01_01.models.Identity + :ivar created_time: The created time of the resource. This is only present if requested via the + $expand query parameter. + :vartype created_time: ~datetime.datetime + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. + :vartype provisioning_state: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + 'created_time': {'readonly': True}, + 'changed_time': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'plan': {'key': 'plan', 'type': 'Plan'}, + 'properties': {'key': 'properties', 'type': 'object'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, + 'changed_time': {'key': 'changedTime', 'type': 'iso-8601'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(GenericResourceExpanded, self).__init__(**kwargs) + self.created_time = None + self.changed_time = None + self.provisioning_state = None + + +class GenericResourceFilter(msrest.serialization.Model): + """Resource filter. + + :param resource_type: The resource type. + :type resource_type: str + :param tagname: The tag name. + :type tagname: str + :param tagvalue: The tag value. + :type tagvalue: str + """ + + _attribute_map = { + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'tagname': {'key': 'tagname', 'type': 'str'}, + 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(GenericResourceFilter, self).__init__(**kwargs) + self.resource_type = kwargs.get('resource_type', None) + self.tagname = kwargs.get('tagname', None) + self.tagvalue = kwargs.get('tagvalue', None) + + +class HttpMessage(msrest.serialization.Model): + """HTTP message. + + :param content: HTTP message content. + :type content: object + """ + + _attribute_map = { + 'content': {'key': 'content', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + super(HttpMessage, self).__init__(**kwargs) + self.content = kwargs.get('content', None) + + +class Identity(msrest.serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceIdentityType + :param user_assigned_identities: The list of user identities associated with the resource. The + user identity dictionary key references will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :type user_assigned_identities: dict[str, + ~azure.mgmt.resource.resources.v2021_01_01.models.IdentityUserAssignedIdentitiesValue] + """ + + _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'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{IdentityUserAssignedIdentitiesValue}'}, + } + + def __init__( + self, + **kwargs + ): + super(Identity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = kwargs.get('type', None) + self.user_assigned_identities = kwargs.get('user_assigned_identities', None) + + +class IdentityUserAssignedIdentitiesValue(msrest.serialization.Model): + """IdentityUserAssignedIdentitiesValue. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None + + +class OnErrorDeployment(msrest.serialization.Model): + """Deployment on error behavior. + + :param type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeploymentType + :param deployment_name: The deployment to be used on error case. + :type deployment_name: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OnErrorDeployment, self).__init__(**kwargs) + self.type = kwargs.get('type', None) + self.deployment_name = kwargs.get('deployment_name', None) + + +class OnErrorDeploymentExtended(msrest.serialization.Model): + """Deployment on error behavior with additional details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: The state of the provisioning for the on error deployment. + :vartype provisioning_state: str + :param type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeploymentType + :param deployment_name: The deployment to be used on error case. + :type deployment_name: str + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OnErrorDeploymentExtended, self).__init__(**kwargs) + self.provisioning_state = None + self.type = kwargs.get('type', None) + self.deployment_name = kwargs.get('deployment_name', None) + + +class Operation(msrest.serialization.Model): + """Microsoft.Resources operation. + + :param name: Operation name: {provider}/{resource}/{operation}. + :type name: str + :param display: The object that represents the operation. + :type display: ~azure.mgmt.resource.resources.v2021_01_01.models.OperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + def __init__( + self, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.display = kwargs.get('display', None) + + +class OperationDisplay(msrest.serialization.Model): + """The object that represents the operation. + + :param provider: Service provider: Microsoft.Resources. + :type provider: str + :param resource: Resource on which the operation is performed: Profile, endpoint, etc. + :type resource: str + :param operation: Operation type: Read, write, delete, etc. + :type operation: str + :param description: Description of the 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 OperationListResult(msrest.serialization.Model): + """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. + + :param value: List of Microsoft.Resources operations. + :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.Operation] + :param next_link: URL to get the next set of operation list results if there are any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class ParametersLink(msrest.serialization.Model): + """Entity representing the reference to the deployment parameters. + + All required parameters must be populated in order to send to Azure. + + :param uri: Required. The URI of the parameters file. + :type uri: str + :param content_version: If included, must match the ContentVersion in the template. + :type content_version: str + """ + + _validation = { + 'uri': {'required': True}, + } + + _attribute_map = { + 'uri': {'key': 'uri', 'type': 'str'}, + 'content_version': {'key': 'contentVersion', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ParametersLink, self).__init__(**kwargs) + self.uri = kwargs['uri'] + self.content_version = kwargs.get('content_version', None) + + +class Plan(msrest.serialization.Model): + """Plan for the resource. + + :param name: The plan ID. + :type name: str + :param publisher: The publisher ID. + :type publisher: str + :param product: The offer ID. + :type product: str + :param promotion_code: The promotion code. + :type promotion_code: str + :param version: The plan's version. + :type version: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Plan, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.publisher = kwargs.get('publisher', None) + self.product = kwargs.get('product', None) + self.promotion_code = kwargs.get('promotion_code', None) + self.version = kwargs.get('version', None) + + +class Provider(msrest.serialization.Model): + """Resource provider information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The provider ID. + :vartype id: str + :param namespace: The namespace of the resource provider. + :type namespace: str + :ivar registration_state: The registration state of the resource provider. + :vartype registration_state: str + :ivar registration_policy: The registration policy of the resource provider. + :vartype registration_policy: str + :ivar resource_types: The collection of provider resource types. + :vartype resource_types: + list[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderResourceType] + """ + + _validation = { + 'id': {'readonly': True}, + 'registration_state': {'readonly': True}, + 'registration_policy': {'readonly': True}, + 'resource_types': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'namespace': {'key': 'namespace', 'type': 'str'}, + 'registration_state': {'key': 'registrationState', 'type': 'str'}, + 'registration_policy': {'key': 'registrationPolicy', 'type': 'str'}, + 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, + } + + def __init__( + self, + **kwargs + ): + super(Provider, self).__init__(**kwargs) + self.id = None + self.namespace = kwargs.get('namespace', None) + self.registration_state = None + self.registration_policy = None + self.resource_types = None + + +class ProviderExtendedLocation(msrest.serialization.Model): + """The provider extended location. + + :param location: The azure location. + :type location: str + :param type: The extended location type. + :type type: str + :param extended_locations: The extended locations for the azure location. + :type extended_locations: list[str] + """ + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'extended_locations': {'key': 'extendedLocations', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(ProviderExtendedLocation, self).__init__(**kwargs) + self.location = kwargs.get('location', None) + self.type = kwargs.get('type', None) + self.extended_locations = kwargs.get('extended_locations', None) + + +class ProviderListResult(msrest.serialization.Model): + """List of resource providers. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: An array of resource providers. + :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.Provider] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Provider]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProviderListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class ProviderResourceType(msrest.serialization.Model): + """Resource type managed by the resource provider. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param resource_type: The resource type. + :type resource_type: str + :param locations: The collection of locations where this resource type can be created. + :type locations: list[str] + :param location_mappings: The location mappings that are supported by this resource type. + :type location_mappings: + list[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderExtendedLocation] + :param aliases: The aliases that are supported by this resource type. + :type aliases: list[~azure.mgmt.resource.resources.v2021_01_01.models.Alias] + :param api_versions: The API version. + :type api_versions: list[str] + :ivar default_api_version: The default API version. + :vartype default_api_version: str + :ivar api_profiles: The API profiles for the resource provider. + :vartype api_profiles: list[~azure.mgmt.resource.resources.v2021_01_01.models.ApiProfile] + :param capabilities: The additional capabilities offered by this resource type. + :type capabilities: str + :param properties: The properties. + :type properties: dict[str, str] + """ + + _validation = { + 'default_api_version': {'readonly': True}, + 'api_profiles': {'readonly': True}, + } + + _attribute_map = { + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'locations': {'key': 'locations', 'type': '[str]'}, + 'location_mappings': {'key': 'locationMappings', 'type': '[ProviderExtendedLocation]'}, + 'aliases': {'key': 'aliases', 'type': '[Alias]'}, + 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, + 'default_api_version': {'key': 'defaultApiVersion', 'type': 'str'}, + 'api_profiles': {'key': 'apiProfiles', 'type': '[ApiProfile]'}, + 'capabilities': {'key': 'capabilities', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(ProviderResourceType, self).__init__(**kwargs) + self.resource_type = kwargs.get('resource_type', None) + self.locations = kwargs.get('locations', None) + self.location_mappings = kwargs.get('location_mappings', None) + self.aliases = kwargs.get('aliases', None) + self.api_versions = kwargs.get('api_versions', None) + self.default_api_version = None + self.api_profiles = None + self.capabilities = kwargs.get('capabilities', None) + self.properties = kwargs.get('properties', None) + + +class ProviderResourceTypeListResult(msrest.serialization.Model): + """List of resource types of a resource provider. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: An array of resource types. + :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderResourceType] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ProviderResourceType]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProviderResourceTypeListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class ResourceGroup(msrest.serialization.Model): + """Resource group information. + + 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: The ID of the resource group. + :vartype id: str + :ivar name: The name of the resource group. + :vartype name: str + :ivar type: The type of the resource group. + :vartype type: str + :param properties: The resource group properties. + :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupProperties + :param location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :type location: str + :param managed_by: The ID of the resource that manages this resource group. + :type managed_by: str + :param tags: A set of tags. The tags attached to the resource group. + :type tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, + 'location': {'key': 'location', 'type': 'str'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceGroup, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.properties = kwargs.get('properties', None) + self.location = kwargs['location'] + self.managed_by = kwargs.get('managed_by', None) + self.tags = kwargs.get('tags', None) + + +class ResourceGroupExportResult(msrest.serialization.Model): + """Resource group export result. + + :param template: The template content. + :type template: object + :param error: The template export error. + :type error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse + """ + + _attribute_map = { + 'template': {'key': 'template', 'type': 'object'}, + 'error': {'key': 'error', 'type': 'ErrorResponse'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceGroupExportResult, self).__init__(**kwargs) + self.template = kwargs.get('template', None) + self.error = kwargs.get('error', None) + + +class ResourceGroupFilter(msrest.serialization.Model): + """Resource group filter. + + :param tag_name: The tag name. + :type tag_name: str + :param tag_value: The tag value. + :type tag_value: str + """ + + _attribute_map = { + 'tag_name': {'key': 'tagName', 'type': 'str'}, + 'tag_value': {'key': 'tagValue', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceGroupFilter, self).__init__(**kwargs) + self.tag_name = kwargs.get('tag_name', None) + self.tag_value = kwargs.get('tag_value', None) + + +class ResourceGroupListResult(msrest.serialization.Model): + """List of resource groups. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: An array of resource groups. + :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceGroupListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class ResourceGroupPatchable(msrest.serialization.Model): + """Resource group information. + + :param name: The name of the resource group. + :type name: str + :param properties: The resource group properties. + :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupProperties + :param managed_by: The ID of the resource that manages this resource group. + :type managed_by: str + :param tags: A set of tags. The tags attached to the resource group. + :type tags: dict[str, str] + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceGroupPatchable, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.properties = kwargs.get('properties', None) + self.managed_by = kwargs.get('managed_by', None) + self.tags = kwargs.get('tags', None) + + +class ResourceGroupProperties(msrest.serialization.Model): + """The resource group properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceGroupProperties, self).__init__(**kwargs) + self.provisioning_state = None + + +class ResourceListResult(msrest.serialization.Model): + """List of resource groups. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: An array of resources. + :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResourceExpanded] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): + """Resource provider operation's display properties. + + :param publisher: Operation description. + :type publisher: str + :param provider: Operation provider. + :type provider: str + :param resource: Operation resource. + :type resource: str + :param operation: Resource provider operation. + :type operation: str + :param description: Operation description. + :type description: str + """ + + _attribute_map = { + 'publisher': {'key': 'publisher', 'type': 'str'}, + '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(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) + self.publisher = kwargs.get('publisher', None) + 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 ResourceReference(msrest.serialization.Model): + """The resource Id model. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The fully qualified resource Id. + :vartype id: str + """ + + _validation = { + 'id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceReference, self).__init__(**kwargs) + self.id = None + + +class ResourcesMoveInfo(msrest.serialization.Model): + """Parameters of move resources. + + :param resources: The IDs of the resources. + :type resources: list[str] + :param target_resource_group: The target resource group. + :type target_resource_group: str + """ + + _attribute_map = { + 'resources': {'key': 'resources', 'type': '[str]'}, + 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourcesMoveInfo, self).__init__(**kwargs) + self.resources = kwargs.get('resources', None) + self.target_resource_group = kwargs.get('target_resource_group', None) + + +class ScopedDeployment(msrest.serialization.Model): + """Deployment operation parameters. + + All required parameters must be populated in order to send to Azure. + + :param location: Required. The location to store the deployment data. + :type location: str + :param properties: Required. The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentProperties + :param tags: A set of tags. Deployment tags. + :type tags: dict[str, str] + """ + + _validation = { + 'location': {'required': True}, + 'properties': {'required': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(ScopedDeployment, self).__init__(**kwargs) + self.location = kwargs['location'] + self.properties = kwargs['properties'] + self.tags = kwargs.get('tags', None) + + +class ScopedDeploymentWhatIf(msrest.serialization.Model): + """Deployment What-if operation parameters. + + All required parameters must be populated in order to send to Azure. + + :param location: Required. The location to store the deployment data. + :type location: str + :param properties: Required. The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfProperties + """ + + _validation = { + 'location': {'required': True}, + 'properties': {'required': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'DeploymentWhatIfProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(ScopedDeploymentWhatIf, self).__init__(**kwargs) + self.location = kwargs['location'] + self.properties = kwargs['properties'] + + +class Sku(msrest.serialization.Model): + """SKU for the resource. + + :param name: The SKU name. + :type name: str + :param tier: The SKU tier. + :type tier: str + :param size: The SKU size. + :type size: str + :param family: The SKU family. + :type family: str + :param model: The SKU model. + :type model: str + :param capacity: The SKU capacity. + :type capacity: int + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + 'size': {'key': 'size', 'type': 'str'}, + 'family': {'key': 'family', 'type': 'str'}, + 'model': {'key': 'model', 'type': 'str'}, + 'capacity': {'key': 'capacity', 'type': 'int'}, + } + + def __init__( + self, + **kwargs + ): + super(Sku, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.tier = kwargs.get('tier', None) + self.size = kwargs.get('size', None) + self.family = kwargs.get('family', None) + self.model = kwargs.get('model', None) + self.capacity = kwargs.get('capacity', None) + + +class StatusMessage(msrest.serialization.Model): + """Operation status message object. + + :param status: Status of the deployment operation. + :type status: str + :param error: The error reported by the operation. + :type error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse + """ + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'error': {'key': 'error', 'type': 'ErrorResponse'}, + } + + def __init__( + self, + **kwargs + ): + super(StatusMessage, self).__init__(**kwargs) + self.status = kwargs.get('status', None) + self.error = kwargs.get('error', None) + + +class SubResource(msrest.serialization.Model): + """Sub-resource. + + :param id: Resource ID. + :type id: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SubResource, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + + +class TagCount(msrest.serialization.Model): + """Tag count. + + :param type: Type of count. + :type type: str + :param value: Value of count. + :type value: int + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'int'}, + } + + def __init__( + self, + **kwargs + ): + super(TagCount, self).__init__(**kwargs) + self.type = kwargs.get('type', None) + self.value = kwargs.get('value', None) + + +class TagDetails(msrest.serialization.Model): + """Tag details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The tag name ID. + :vartype id: str + :param tag_name: The tag name. + :type tag_name: str + :param count: The total number of resources that use the resource tag. When a tag is initially + created and has no associated resources, the value is 0. + :type count: ~azure.mgmt.resource.resources.v2021_01_01.models.TagCount + :param values: The list of tag values. + :type values: list[~azure.mgmt.resource.resources.v2021_01_01.models.TagValue] + """ + + _validation = { + 'id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'tag_name': {'key': 'tagName', 'type': 'str'}, + 'count': {'key': 'count', 'type': 'TagCount'}, + 'values': {'key': 'values', 'type': '[TagValue]'}, + } + + def __init__( + self, + **kwargs + ): + super(TagDetails, self).__init__(**kwargs) + self.id = None + self.tag_name = kwargs.get('tag_name', None) + self.count = kwargs.get('count', None) + self.values = kwargs.get('values', None) + + +class Tags(msrest.serialization.Model): + """A dictionary of name and value pairs. + + :param tags: A set of tags. Dictionary of :code:``. + :type tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(Tags, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) + + +class TagsListResult(msrest.serialization.Model): + """List of subscription tags. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: An array of tags. + :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.TagDetails] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TagsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class TagsPatchResource(msrest.serialization.Model): + """Wrapper resource for tags patch API request only. + + :param operation: The operation type for the patch API. Possible values include: "Replace", + "Merge", "Delete". + :type operation: str or ~azure.mgmt.resource.resources.v2021_01_01.models.TagsPatchOperation + :param properties: The set of tags. + :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.Tags + """ + + _attribute_map = { + 'operation': {'key': 'operation', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'Tags'}, + } + + def __init__( + self, + **kwargs + ): + super(TagsPatchResource, self).__init__(**kwargs) + self.operation = kwargs.get('operation', None) + self.properties = kwargs.get('properties', None) + + +class TagsResource(msrest.serialization.Model): + """Wrapper resource for tags API requests and responses. + + 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: The ID of the tags wrapper resource. + :vartype id: str + :ivar name: The name of the tags wrapper resource. + :vartype name: str + :ivar type: The type of the tags wrapper resource. + :vartype type: str + :param properties: Required. The set of tags. + :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.Tags + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'properties': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'Tags'}, + } + + def __init__( + self, + **kwargs + ): + super(TagsResource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.properties = kwargs['properties'] + + +class TagValue(msrest.serialization.Model): + """Tag information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The tag value ID. + :vartype id: str + :param tag_value: The tag value. + :type tag_value: str + :param count: The tag value count. + :type count: ~azure.mgmt.resource.resources.v2021_01_01.models.TagCount + """ + + _validation = { + 'id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'tag_value': {'key': 'tagValue', 'type': 'str'}, + 'count': {'key': 'count', 'type': 'TagCount'}, + } + + def __init__( + self, + **kwargs + ): + super(TagValue, self).__init__(**kwargs) + self.id = None + self.tag_value = kwargs.get('tag_value', None) + self.count = kwargs.get('count', None) + + +class TargetResource(msrest.serialization.Model): + """Target resource. + + :param id: The ID of the resource. + :type id: str + :param resource_name: The name of the resource. + :type resource_name: str + :param resource_type: The type of the resource. + :type resource_type: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'resource_name': {'key': 'resourceName', 'type': 'str'}, + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TargetResource, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.resource_name = kwargs.get('resource_name', None) + self.resource_type = kwargs.get('resource_type', None) + + +class TemplateHashResult(msrest.serialization.Model): + """Result of the request to calculate template hash. It contains a string of minified template and its hash. + + :param minified_template: The minified template string. + :type minified_template: str + :param template_hash: The template hash. + :type template_hash: str + """ + + _attribute_map = { + 'minified_template': {'key': 'minifiedTemplate', 'type': 'str'}, + 'template_hash': {'key': 'templateHash', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TemplateHashResult, self).__init__(**kwargs) + self.minified_template = kwargs.get('minified_template', None) + self.template_hash = kwargs.get('template_hash', None) + + +class TemplateLink(msrest.serialization.Model): + """Entity representing the reference to the template. + + :param uri: The URI of the template to deploy. Use either the uri or id property, but not both. + :type uri: str + :param id: The resource id of a Template Spec. Use either the id or uri property, but not both. + :type id: str + :param relative_path: The relativePath property can be used to deploy a linked template at a + location relative to the parent. If the parent template was linked with a TemplateSpec, this + will reference an artifact in the TemplateSpec. If the parent was linked with a URI, the child + deployment will be a combination of the parent and relativePath URIs. + :type relative_path: str + :param content_version: If included, must match the ContentVersion in the template. + :type content_version: str + :param query_string: The query string (for example, a SAS token) to be used with the + templateLink URI. + :type query_string: str + """ + + _attribute_map = { + 'uri': {'key': 'uri', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'relative_path': {'key': 'relativePath', 'type': 'str'}, + 'content_version': {'key': 'contentVersion', 'type': 'str'}, + 'query_string': {'key': 'queryString', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TemplateLink, self).__init__(**kwargs) + self.uri = kwargs.get('uri', None) + self.id = kwargs.get('id', None) + self.relative_path = kwargs.get('relative_path', None) + self.content_version = kwargs.get('content_version', None) + self.query_string = kwargs.get('query_string', None) + + +class WhatIfChange(msrest.serialization.Model): + """Information about a single resource change predicted by What-If operation. + + All required parameters must be populated in order to send to Azure. + + :param resource_id: Required. Resource ID. + :type resource_id: str + :param change_type: Required. Type of change that will be made to the resource when the + deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", + "NoChange", "Modify", "Unsupported". + :type change_type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ChangeType + :param unsupported_reason: The explanation about why the resource is unsupported by What-If. + :type unsupported_reason: str + :param before: The snapshot of the resource before the deployment is executed. + :type before: object + :param after: The predicted snapshot of the resource after the deployment is executed. + :type after: object + :param delta: The predicted changes to resource properties. + :type delta: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfPropertyChange] + """ + + _validation = { + 'resource_id': {'required': True}, + 'change_type': {'required': True}, + } + + _attribute_map = { + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + 'change_type': {'key': 'changeType', 'type': 'str'}, + 'unsupported_reason': {'key': 'unsupportedReason', 'type': 'str'}, + 'before': {'key': 'before', 'type': 'object'}, + 'after': {'key': 'after', 'type': 'object'}, + 'delta': {'key': 'delta', 'type': '[WhatIfPropertyChange]'}, + } + + def __init__( + self, + **kwargs + ): + super(WhatIfChange, self).__init__(**kwargs) + self.resource_id = kwargs['resource_id'] + self.change_type = kwargs['change_type'] + self.unsupported_reason = kwargs.get('unsupported_reason', None) + self.before = kwargs.get('before', None) + self.after = kwargs.get('after', None) + self.delta = kwargs.get('delta', None) + + +class WhatIfOperationResult(msrest.serialization.Model): + """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. + + :param status: Status of the What-If operation. + :type status: str + :param error: Error when What-If operation fails. + :type error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse + :param changes: List of resource changes predicted by What-If operation. + :type changes: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfChange] + """ + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'error': {'key': 'error', 'type': 'ErrorResponse'}, + 'changes': {'key': 'properties.changes', 'type': '[WhatIfChange]'}, + } + + def __init__( + self, + **kwargs + ): + super(WhatIfOperationResult, self).__init__(**kwargs) + self.status = kwargs.get('status', None) + self.error = kwargs.get('error', None) + self.changes = kwargs.get('changes', None) + + +class WhatIfPropertyChange(msrest.serialization.Model): + """The predicted change to the resource property. + + All required parameters must be populated in order to send to Azure. + + :param path: Required. The path of the property. + :type path: str + :param property_change_type: Required. The type of property change. Possible values include: + "Create", "Delete", "Modify", "Array", "NoEffect". + :type property_change_type: str or + ~azure.mgmt.resource.resources.v2021_01_01.models.PropertyChangeType + :param before: The value of the property before the deployment is executed. + :type before: object + :param after: The value of the property after the deployment is executed. + :type after: object + :param children: Nested property changes. + :type children: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfPropertyChange] + """ + + _validation = { + 'path': {'required': True}, + 'property_change_type': {'required': True}, + } + + _attribute_map = { + 'path': {'key': 'path', 'type': 'str'}, + 'property_change_type': {'key': 'propertyChangeType', 'type': 'str'}, + 'before': {'key': 'before', 'type': 'object'}, + 'after': {'key': 'after', 'type': 'object'}, + 'children': {'key': 'children', 'type': '[WhatIfPropertyChange]'}, + } + + def __init__( + self, + **kwargs + ): + super(WhatIfPropertyChange, self).__init__(**kwargs) + self.path = kwargs['path'] + self.property_change_type = kwargs['property_change_type'] + self.before = kwargs.get('before', None) + self.after = kwargs.get('after', None) + self.children = kwargs.get('children', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_models_py3.py new file mode 100644 index 0000000000000..38d121b84ed14 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_models_py3.py @@ -0,0 +1,2839 @@ +# 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 Dict, List, Optional, Union + +import msrest.serialization + +from ._resource_management_client_enums import * + + +class Alias(msrest.serialization.Model): + """The alias type. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param name: The alias name. + :type name: str + :param paths: The paths for an alias. + :type paths: list[~azure.mgmt.resource.resources.v2021_01_01.models.AliasPath] + :param type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + "Mask". + :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasType + :param default_path: The default path for an alias. + :type default_path: str + :param default_pattern: The default pattern for an alias. + :type default_pattern: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPattern + :ivar default_metadata: The default alias path metadata. Applies to the default path and to any + alias path that doesn't have metadata. + :vartype default_metadata: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPathMetadata + """ + + _validation = { + 'default_metadata': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'paths': {'key': 'paths', 'type': '[AliasPath]'}, + 'type': {'key': 'type', 'type': 'str'}, + 'default_path': {'key': 'defaultPath', 'type': 'str'}, + 'default_pattern': {'key': 'defaultPattern', 'type': 'AliasPattern'}, + 'default_metadata': {'key': 'defaultMetadata', 'type': 'AliasPathMetadata'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + paths: Optional[List["AliasPath"]] = None, + type: Optional[Union[str, "AliasType"]] = None, + default_path: Optional[str] = None, + default_pattern: Optional["AliasPattern"] = None, + **kwargs + ): + super(Alias, self).__init__(**kwargs) + self.name = name + self.paths = paths + self.type = type + self.default_path = default_path + self.default_pattern = default_pattern + self.default_metadata = None + + +class AliasPath(msrest.serialization.Model): + """The type of the paths for alias. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param path: The path of an alias. + :type path: str + :param api_versions: The API versions. + :type api_versions: list[str] + :param pattern: The pattern for an alias path. + :type pattern: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPattern + :ivar metadata: The metadata of the alias path. If missing, fall back to the default metadata + of the alias. + :vartype metadata: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPathMetadata + """ + + _validation = { + 'metadata': {'readonly': True}, + } + + _attribute_map = { + 'path': {'key': 'path', 'type': 'str'}, + 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, + 'pattern': {'key': 'pattern', 'type': 'AliasPattern'}, + 'metadata': {'key': 'metadata', 'type': 'AliasPathMetadata'}, + } + + def __init__( + self, + *, + path: Optional[str] = None, + api_versions: Optional[List[str]] = None, + pattern: Optional["AliasPattern"] = None, + **kwargs + ): + super(AliasPath, self).__init__(**kwargs) + self.path = path + self.api_versions = api_versions + self.pattern = pattern + self.metadata = None + + +class AliasPathMetadata(msrest.serialization.Model): + """AliasPathMetadata. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The type of the token that the alias path is referring to. Possible values include: + "NotSpecified", "Any", "String", "Object", "Array", "Integer", "Number", "Boolean". + :vartype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPathTokenType + :ivar attributes: The attributes of the token that the alias path is referring to. Possible + values include: "None", "Modifiable". + :vartype attributes: str or + ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPathAttributes + """ + + _validation = { + 'type': {'readonly': True}, + 'attributes': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'attributes': {'key': 'attributes', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AliasPathMetadata, self).__init__(**kwargs) + self.type = None + self.attributes = None + + +class AliasPattern(msrest.serialization.Model): + """The type of the pattern for an alias path. + + :param phrase: The alias pattern phrase. + :type phrase: str + :param variable: The alias pattern variable. + :type variable: str + :param type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPatternType + """ + + _attribute_map = { + 'phrase': {'key': 'phrase', 'type': 'str'}, + 'variable': {'key': 'variable', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + phrase: Optional[str] = None, + variable: Optional[str] = None, + type: Optional[Union[str, "AliasPatternType"]] = None, + **kwargs + ): + super(AliasPattern, self).__init__(**kwargs) + self.phrase = phrase + self.variable = variable + self.type = type + + +class ApiProfile(msrest.serialization.Model): + """ApiProfile. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar profile_version: The profile version. + :vartype profile_version: str + :ivar api_version: The API version. + :vartype api_version: str + """ + + _validation = { + 'profile_version': {'readonly': True}, + 'api_version': {'readonly': True}, + } + + _attribute_map = { + 'profile_version': {'key': 'profileVersion', 'type': 'str'}, + 'api_version': {'key': 'apiVersion', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ApiProfile, self).__init__(**kwargs) + self.profile_version = None + self.api_version = None + + +class BasicDependency(msrest.serialization.Model): + """Deployment dependency information. + + :param id: The ID of the dependency. + :type id: str + :param resource_type: The dependency resource type. + :type resource_type: str + :param resource_name: The dependency resource name. + :type resource_name: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'resource_name': {'key': 'resourceName', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs + ): + super(BasicDependency, self).__init__(**kwargs) + self.id = id + self.resource_type = resource_type + self.resource_name = resource_name + + +class DebugSetting(msrest.serialization.Model): + """The debug setting. + + :param detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :type detail_level: str + """ + + _attribute_map = { + 'detail_level': {'key': 'detailLevel', 'type': 'str'}, + } + + def __init__( + self, + *, + detail_level: Optional[str] = None, + **kwargs + ): + super(DebugSetting, self).__init__(**kwargs) + self.detail_level = detail_level + + +class Dependency(msrest.serialization.Model): + """Deployment dependency information. + + :param depends_on: The list of dependencies. + :type depends_on: list[~azure.mgmt.resource.resources.v2021_01_01.models.BasicDependency] + :param id: The ID of the dependency. + :type id: str + :param resource_type: The dependency resource type. + :type resource_type: str + :param resource_name: The dependency resource name. + :type resource_name: str + """ + + _attribute_map = { + 'depends_on': {'key': 'dependsOn', 'type': '[BasicDependency]'}, + 'id': {'key': 'id', 'type': 'str'}, + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'resource_name': {'key': 'resourceName', 'type': 'str'}, + } + + def __init__( + self, + *, + depends_on: Optional[List["BasicDependency"]] = None, + id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs + ): + super(Dependency, self).__init__(**kwargs) + self.depends_on = depends_on + self.id = id + self.resource_type = resource_type + self.resource_name = resource_name + + +class Deployment(msrest.serialization.Model): + """Deployment operation parameters. + + All required parameters must be populated in order to send to Azure. + + :param location: The location to store the deployment data. + :type location: str + :param properties: Required. The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentProperties + :param tags: A set of tags. Deployment tags. + :type tags: dict[str, str] + """ + + _validation = { + 'properties': {'required': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + properties: "DeploymentProperties", + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(Deployment, self).__init__(**kwargs) + self.location = location + self.properties = properties + self.tags = tags + + +class DeploymentExportResult(msrest.serialization.Model): + """The deployment export result. + + :param template: The template content. + :type template: object + """ + + _attribute_map = { + 'template': {'key': 'template', 'type': 'object'}, + } + + def __init__( + self, + *, + template: Optional[object] = None, + **kwargs + ): + super(DeploymentExportResult, self).__init__(**kwargs) + self.template = template + + +class DeploymentExtended(msrest.serialization.Model): + """Deployment information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the deployment. + :vartype id: str + :ivar name: The name of the deployment. + :vartype name: str + :ivar type: The type of the deployment. + :vartype type: str + :param location: the location of the deployment. + :type location: str + :param properties: Deployment properties. + :type properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentPropertiesExtended + :param tags: A set of tags. Deployment tags. + :type tags: dict[str, 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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + properties: Optional["DeploymentPropertiesExtended"] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(DeploymentExtended, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.properties = properties + self.tags = tags + + +class DeploymentExtendedFilter(msrest.serialization.Model): + """Deployment filter. + + :param provisioning_state: The provisioning state. + :type provisioning_state: str + """ + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + provisioning_state: Optional[str] = None, + **kwargs + ): + super(DeploymentExtendedFilter, self).__init__(**kwargs) + self.provisioning_state = provisioning_state + + +class DeploymentListResult(msrest.serialization.Model): + """List of deployments. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: An array of deployments. + :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeploymentExtended"]] = None, + **kwargs + ): + super(DeploymentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DeploymentOperation(msrest.serialization.Model): + """Deployment operation information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Full deployment operation ID. + :vartype id: str + :ivar operation_id: Deployment operation ID. + :vartype operation_id: str + :param properties: Deployment properties. + :type properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'operation_id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'operation_id': {'key': 'operationId', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, + } + + def __init__( + self, + *, + properties: Optional["DeploymentOperationProperties"] = None, + **kwargs + ): + super(DeploymentOperation, self).__init__(**kwargs) + self.id = None + self.operation_id = None + self.properties = properties + + +class DeploymentOperationProperties(msrest.serialization.Model): + """Deployment operation properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_operation: The name of the current provisioning operation. Possible values + include: "NotSpecified", "Create", "Delete", "Waiting", "AzureAsyncOperationWaiting", + "ResourceCacheWaiting", "Action", "Read", "EvaluateDeploymentOutput", "DeploymentCleanup". + :vartype provisioning_operation: str or + ~azure.mgmt.resource.resources.v2021_01_01.models.ProvisioningOperation + :ivar provisioning_state: The state of the provisioning. + :vartype provisioning_state: str + :ivar timestamp: The date and time of the operation. + :vartype timestamp: ~datetime.datetime + :ivar duration: The duration of the operation. + :vartype duration: str + :ivar service_request_id: Deployment operation service request id. + :vartype service_request_id: str + :ivar status_code: Operation status code from the resource provider. This property may not be + set if a response has not yet been received. + :vartype status_code: str + :ivar status_message: Operation status message from the resource provider. This property is + optional. It will only be provided if an error was received from the resource provider. + :vartype status_message: ~azure.mgmt.resource.resources.v2021_01_01.models.StatusMessage + :ivar target_resource: The target resource. + :vartype target_resource: ~azure.mgmt.resource.resources.v2021_01_01.models.TargetResource + :ivar request: The HTTP request message. + :vartype request: ~azure.mgmt.resource.resources.v2021_01_01.models.HttpMessage + :ivar response: The HTTP response message. + :vartype response: ~azure.mgmt.resource.resources.v2021_01_01.models.HttpMessage + """ + + _validation = { + 'provisioning_operation': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'timestamp': {'readonly': True}, + 'duration': {'readonly': True}, + 'service_request_id': {'readonly': True}, + 'status_code': {'readonly': True}, + 'status_message': {'readonly': True}, + 'target_resource': {'readonly': True}, + 'request': {'readonly': True}, + 'response': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_operation': {'key': 'provisioningOperation', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + 'duration': {'key': 'duration', 'type': 'str'}, + 'service_request_id': {'key': 'serviceRequestId', 'type': 'str'}, + 'status_code': {'key': 'statusCode', 'type': 'str'}, + 'status_message': {'key': 'statusMessage', 'type': 'StatusMessage'}, + 'target_resource': {'key': 'targetResource', 'type': 'TargetResource'}, + 'request': {'key': 'request', 'type': 'HttpMessage'}, + 'response': {'key': 'response', 'type': 'HttpMessage'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentOperationProperties, self).__init__(**kwargs) + self.provisioning_operation = None + self.provisioning_state = None + self.timestamp = None + self.duration = None + self.service_request_id = None + self.status_code = None + self.status_message = None + self.target_resource = None + self.request = None + self.response = None + + +class DeploymentOperationsListResult(msrest.serialization.Model): + """List of deployment operations. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: An array of deployment operations. + :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeploymentOperation"]] = None, + **kwargs + ): + super(DeploymentOperationsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DeploymentProperties(msrest.serialization.Model): + """Deployment properties. + + All required parameters must be populated in order to send to Azure. + + :param template: The template content. You use this element when you want to pass the template + syntax directly in the request rather than link to an existing template. It can be a JObject or + well-formed JSON string. Use either the templateLink property or the template property, but not + both. + :type template: object + :param template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :type template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink + :param parameters: Name and value pairs that define the deployment parameters for the template. + You use this element when you want to provide the parameter values directly in the request + rather than link to an existing parameter file. Use either the parametersLink property or the + parameters property, but not both. It can be a JObject or a well formed JSON string. + :type parameters: object + :param parameters_link: The URI of parameters file. You use this element to link to an existing + parameters file. Use either the parametersLink property or the parameters property, but not + both. + :type parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink + :param mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :type mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode + :param debug_setting: The debug setting of the deployment. + :type debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting + :param on_error_deployment: The deployment on error behavior. + :type on_error_deployment: ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeployment + :param expression_evaluation_options: Specifies whether template expressions are evaluated + within the scope of the parent template or nested template. Only applicable to nested + templates. If not specified, default value is outer. + :type expression_evaluation_options: + ~azure.mgmt.resource.resources.v2021_01_01.models.ExpressionEvaluationOptions + """ + + _validation = { + 'mode': {'required': True}, + } + + _attribute_map = { + 'template': {'key': 'template', 'type': 'object'}, + 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, + 'parameters': {'key': 'parameters', 'type': 'object'}, + 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, + 'mode': {'key': 'mode', 'type': 'str'}, + 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, + 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, + 'expression_evaluation_options': {'key': 'expressionEvaluationOptions', 'type': 'ExpressionEvaluationOptions'}, + } + + def __init__( + self, + *, + mode: Union[str, "DeploymentMode"], + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + debug_setting: Optional["DebugSetting"] = None, + on_error_deployment: Optional["OnErrorDeployment"] = None, + expression_evaluation_options: Optional["ExpressionEvaluationOptions"] = None, + **kwargs + ): + super(DeploymentProperties, self).__init__(**kwargs) + self.template = template + self.template_link = template_link + self.parameters = parameters + self.parameters_link = parameters_link + self.mode = mode + self.debug_setting = debug_setting + self.on_error_deployment = on_error_deployment + self.expression_evaluation_options = expression_evaluation_options + + +class DeploymentPropertiesExtended(msrest.serialization.Model): + """Deployment properties with additional details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Denotes the state of provisioning. Possible values include: + "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", + "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.resource.resources.v2021_01_01.models.ProvisioningState + :ivar correlation_id: The correlation ID of the deployment. + :vartype correlation_id: str + :ivar timestamp: The timestamp of the template deployment. + :vartype timestamp: ~datetime.datetime + :ivar duration: The duration of the template deployment. + :vartype duration: str + :ivar outputs: Key/value pairs that represent deployment output. + :vartype outputs: object + :ivar providers: The list of resource providers needed for the deployment. + :vartype providers: list[~azure.mgmt.resource.resources.v2021_01_01.models.Provider] + :ivar dependencies: The list of deployment dependencies. + :vartype dependencies: list[~azure.mgmt.resource.resources.v2021_01_01.models.Dependency] + :ivar template_link: The URI referencing the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink + :ivar parameters: Deployment parameters. + :vartype parameters: object + :ivar parameters_link: The URI referencing the parameters. + :vartype parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values + include: "Incremental", "Complete". + :vartype mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeploymentExtended + :ivar template_hash: The hash produced for the template. + :vartype template_hash: str + :ivar output_resources: Array of provisioned resources. + :vartype output_resources: + list[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceReference] + :ivar validated_resources: Array of validated resources. + :vartype validated_resources: + list[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceReference] + :ivar error: The deployment error. + :vartype error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + 'correlation_id': {'readonly': True}, + 'timestamp': {'readonly': True}, + 'duration': {'readonly': True}, + 'outputs': {'readonly': True}, + 'providers': {'readonly': True}, + 'dependencies': {'readonly': True}, + 'template_link': {'readonly': True}, + 'parameters': {'readonly': True}, + 'parameters_link': {'readonly': True}, + 'mode': {'readonly': True}, + 'debug_setting': {'readonly': True}, + 'on_error_deployment': {'readonly': True}, + 'template_hash': {'readonly': True}, + 'output_resources': {'readonly': True}, + 'validated_resources': {'readonly': True}, + 'error': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'correlation_id': {'key': 'correlationId', 'type': 'str'}, + 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + 'duration': {'key': 'duration', 'type': 'str'}, + 'outputs': {'key': 'outputs', 'type': 'object'}, + 'providers': {'key': 'providers', 'type': '[Provider]'}, + 'dependencies': {'key': 'dependencies', 'type': '[Dependency]'}, + 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, + 'parameters': {'key': 'parameters', 'type': 'object'}, + 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, + 'mode': {'key': 'mode', 'type': 'str'}, + 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, + 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, + 'template_hash': {'key': 'templateHash', 'type': 'str'}, + 'output_resources': {'key': 'outputResources', 'type': '[ResourceReference]'}, + 'validated_resources': {'key': 'validatedResources', 'type': '[ResourceReference]'}, + 'error': {'key': 'error', 'type': 'ErrorResponse'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentPropertiesExtended, self).__init__(**kwargs) + self.provisioning_state = None + self.correlation_id = None + self.timestamp = None + self.duration = None + self.outputs = None + self.providers = None + self.dependencies = None + self.template_link = None + self.parameters = None + self.parameters_link = None + self.mode = None + self.debug_setting = None + self.on_error_deployment = None + self.template_hash = None + self.output_resources = None + self.validated_resources = None + self.error = None + + +class DeploymentValidateResult(msrest.serialization.Model): + """Information from validate template deployment response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar error: The deployment validation error. + :vartype error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse + :param properties: The template deployment properties. + :type properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentPropertiesExtended + """ + + _validation = { + 'error': {'readonly': True}, + } + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponse'}, + 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + } + + def __init__( + self, + *, + properties: Optional["DeploymentPropertiesExtended"] = None, + **kwargs + ): + super(DeploymentValidateResult, self).__init__(**kwargs) + self.error = None + self.properties = properties + + +class DeploymentWhatIf(msrest.serialization.Model): + """Deployment What-if operation parameters. + + All required parameters must be populated in order to send to Azure. + + :param location: The location to store the deployment data. + :type location: str + :param properties: Required. The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfProperties + """ + + _validation = { + 'properties': {'required': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'DeploymentWhatIfProperties'}, + } + + def __init__( + self, + *, + properties: "DeploymentWhatIfProperties", + location: Optional[str] = None, + **kwargs + ): + super(DeploymentWhatIf, self).__init__(**kwargs) + self.location = location + self.properties = properties + + +class DeploymentWhatIfProperties(DeploymentProperties): + """Deployment What-if properties. + + All required parameters must be populated in order to send to Azure. + + :param template: The template content. You use this element when you want to pass the template + syntax directly in the request rather than link to an existing template. It can be a JObject or + well-formed JSON string. Use either the templateLink property or the template property, but not + both. + :type template: object + :param template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :type template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink + :param parameters: Name and value pairs that define the deployment parameters for the template. + You use this element when you want to provide the parameter values directly in the request + rather than link to an existing parameter file. Use either the parametersLink property or the + parameters property, but not both. It can be a JObject or a well formed JSON string. + :type parameters: object + :param parameters_link: The URI of parameters file. You use this element to link to an existing + parameters file. Use either the parametersLink property or the parameters property, but not + both. + :type parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink + :param mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :type mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode + :param debug_setting: The debug setting of the deployment. + :type debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting + :param on_error_deployment: The deployment on error behavior. + :type on_error_deployment: ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeployment + :param expression_evaluation_options: Specifies whether template expressions are evaluated + within the scope of the parent template or nested template. Only applicable to nested + templates. If not specified, default value is outer. + :type expression_evaluation_options: + ~azure.mgmt.resource.resources.v2021_01_01.models.ExpressionEvaluationOptions + :param what_if_settings: Optional What-If operation settings. + :type what_if_settings: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfSettings + """ + + _validation = { + 'mode': {'required': True}, + } + + _attribute_map = { + 'template': {'key': 'template', 'type': 'object'}, + 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, + 'parameters': {'key': 'parameters', 'type': 'object'}, + 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, + 'mode': {'key': 'mode', 'type': 'str'}, + 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, + 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, + 'expression_evaluation_options': {'key': 'expressionEvaluationOptions', 'type': 'ExpressionEvaluationOptions'}, + 'what_if_settings': {'key': 'whatIfSettings', 'type': 'DeploymentWhatIfSettings'}, + } + + def __init__( + self, + *, + mode: Union[str, "DeploymentMode"], + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + debug_setting: Optional["DebugSetting"] = None, + on_error_deployment: Optional["OnErrorDeployment"] = None, + expression_evaluation_options: Optional["ExpressionEvaluationOptions"] = None, + what_if_settings: Optional["DeploymentWhatIfSettings"] = None, + **kwargs + ): + super(DeploymentWhatIfProperties, self).__init__(template=template, template_link=template_link, parameters=parameters, parameters_link=parameters_link, mode=mode, debug_setting=debug_setting, on_error_deployment=on_error_deployment, expression_evaluation_options=expression_evaluation_options, **kwargs) + self.what_if_settings = what_if_settings + + +class DeploymentWhatIfSettings(msrest.serialization.Model): + """Deployment What-If operation settings. + + :param result_format: The format of the What-If results. Possible values include: + "ResourceIdOnly", "FullResourcePayloads". + :type result_format: str or + ~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfResultFormat + """ + + _attribute_map = { + 'result_format': {'key': 'resultFormat', 'type': 'str'}, + } + + def __init__( + self, + *, + result_format: Optional[Union[str, "WhatIfResultFormat"]] = None, + **kwargs + ): + super(DeploymentWhatIfSettings, self).__init__(**kwargs) + self.result_format = result_format + + +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): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.resource.resources.v2021_01_01.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(ErrorResponse, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ExportTemplateRequest(msrest.serialization.Model): + """Export resource group template request parameters. + + :param resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :type resources: list[str] + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :type options: str + """ + + _attribute_map = { + 'resources': {'key': 'resources', 'type': '[str]'}, + 'options': {'key': 'options', 'type': 'str'}, + } + + def __init__( + self, + *, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ): + super(ExportTemplateRequest, self).__init__(**kwargs) + self.resources = resources + self.options = options + + +class ExpressionEvaluationOptions(msrest.serialization.Model): + """Specifies whether template expressions are evaluated within the scope of the parent template or nested template. + + :param scope: The scope to be used for evaluation of parameters, variables and functions in a + nested template. Possible values include: "NotSpecified", "Outer", "Inner". + :type scope: str or + ~azure.mgmt.resource.resources.v2021_01_01.models.ExpressionEvaluationOptionsScopeType + """ + + _attribute_map = { + 'scope': {'key': 'scope', 'type': 'str'}, + } + + def __init__( + self, + *, + scope: Optional[Union[str, "ExpressionEvaluationOptionsScopeType"]] = None, + **kwargs + ): + super(ExpressionEvaluationOptions, self).__init__(**kwargs) + self.scope = scope + + +class ExtendedLocation(msrest.serialization.Model): + """Resource extended location. + + :param type: The extended location type. Possible values include: "EdgeZone". + :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocationType + :param name: The extended location name. + :type name: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "ExtendedLocationType"]] = None, + name: Optional[str] = None, + **kwargs + ): + super(ExtendedLocation, self).__init__(**kwargs) + self.type = type + self.name = name + + +class Resource(msrest.serialization.Model): + """Specified resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param location: Resource location. + :type location: str + :param extended_location: Resource extended location. + :type extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation + :param tags: A set of tags. Resource tags. + :type tags: dict[str, 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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + extended_location: Optional["ExtendedLocation"] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.extended_location = extended_location + self.tags = tags + + +class GenericResource(Resource): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param location: Resource location. + :type location: str + :param extended_location: Resource extended location. + :type extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param plan: The plan of the resource. + :type plan: ~azure.mgmt.resource.resources.v2021_01_01.models.Plan + :param properties: The resource properties. + :type properties: object + :param kind: The kind of the resource. + :type kind: str + :param managed_by: ID of the resource that manages this resource. + :type managed_by: str + :param sku: The SKU of the resource. + :type sku: ~azure.mgmt.resource.resources.v2021_01_01.models.Sku + :param identity: The identity of the resource. + :type identity: ~azure.mgmt.resource.resources.v2021_01_01.models.Identity + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'plan': {'key': 'plan', 'type': 'Plan'}, + 'properties': {'key': 'properties', 'type': 'object'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + extended_location: Optional["ExtendedLocation"] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["Plan"] = None, + properties: Optional[object] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): + super(GenericResource, self).__init__(location=location, extended_location=extended_location, tags=tags, **kwargs) + self.plan = plan + self.properties = properties + self.kind = kind + self.managed_by = managed_by + self.sku = sku + self.identity = identity + + +class GenericResourceExpanded(GenericResource): + """Resource information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param location: Resource location. + :type location: str + :param extended_location: Resource extended location. + :type extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param plan: The plan of the resource. + :type plan: ~azure.mgmt.resource.resources.v2021_01_01.models.Plan + :param properties: The resource properties. + :type properties: object + :param kind: The kind of the resource. + :type kind: str + :param managed_by: ID of the resource that manages this resource. + :type managed_by: str + :param sku: The SKU of the resource. + :type sku: ~azure.mgmt.resource.resources.v2021_01_01.models.Sku + :param identity: The identity of the resource. + :type identity: ~azure.mgmt.resource.resources.v2021_01_01.models.Identity + :ivar created_time: The created time of the resource. This is only present if requested via the + $expand query parameter. + :vartype created_time: ~datetime.datetime + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. + :vartype provisioning_state: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + 'created_time': {'readonly': True}, + 'changed_time': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'plan': {'key': 'plan', 'type': 'Plan'}, + 'properties': {'key': 'properties', 'type': 'object'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, + 'changed_time': {'key': 'changedTime', 'type': 'iso-8601'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + extended_location: Optional["ExtendedLocation"] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["Plan"] = None, + properties: Optional[object] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): + super(GenericResourceExpanded, self).__init__(location=location, extended_location=extended_location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + self.created_time = None + self.changed_time = None + self.provisioning_state = None + + +class GenericResourceFilter(msrest.serialization.Model): + """Resource filter. + + :param resource_type: The resource type. + :type resource_type: str + :param tagname: The tag name. + :type tagname: str + :param tagvalue: The tag value. + :type tagvalue: str + """ + + _attribute_map = { + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'tagname': {'key': 'tagname', 'type': 'str'}, + 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, + } + + def __init__( + self, + *, + resource_type: Optional[str] = None, + tagname: Optional[str] = None, + tagvalue: Optional[str] = None, + **kwargs + ): + super(GenericResourceFilter, self).__init__(**kwargs) + self.resource_type = resource_type + self.tagname = tagname + self.tagvalue = tagvalue + + +class HttpMessage(msrest.serialization.Model): + """HTTP message. + + :param content: HTTP message content. + :type content: object + """ + + _attribute_map = { + 'content': {'key': 'content', 'type': 'object'}, + } + + def __init__( + self, + *, + content: Optional[object] = None, + **kwargs + ): + super(HttpMessage, self).__init__(**kwargs) + self.content = content + + +class Identity(msrest.serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceIdentityType + :param user_assigned_identities: The list of user identities associated with the resource. The + user identity dictionary key references will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :type user_assigned_identities: dict[str, + ~azure.mgmt.resource.resources.v2021_01_01.models.IdentityUserAssignedIdentitiesValue] + """ + + _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'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{IdentityUserAssignedIdentitiesValue}'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "IdentityUserAssignedIdentitiesValue"]] = None, + **kwargs + ): + super(Identity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class IdentityUserAssignedIdentitiesValue(msrest.serialization.Model): + """IdentityUserAssignedIdentitiesValue. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None + + +class OnErrorDeployment(msrest.serialization.Model): + """Deployment on error behavior. + + :param type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeploymentType + :param deployment_name: The deployment to be used on error case. + :type deployment_name: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + deployment_name: Optional[str] = None, + **kwargs + ): + super(OnErrorDeployment, self).__init__(**kwargs) + self.type = type + self.deployment_name = deployment_name + + +class OnErrorDeploymentExtended(msrest.serialization.Model): + """Deployment on error behavior with additional details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: The state of the provisioning for the on error deployment. + :vartype provisioning_state: str + :param type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeploymentType + :param deployment_name: The deployment to be used on error case. + :type deployment_name: str + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + deployment_name: Optional[str] = None, + **kwargs + ): + super(OnErrorDeploymentExtended, self).__init__(**kwargs) + self.provisioning_state = None + self.type = type + self.deployment_name = deployment_name + + +class Operation(msrest.serialization.Model): + """Microsoft.Resources operation. + + :param name: Operation name: {provider}/{resource}/{operation}. + :type name: str + :param display: The object that represents the operation. + :type display: ~azure.mgmt.resource.resources.v2021_01_01.models.OperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = name + self.display = display + + +class OperationDisplay(msrest.serialization.Model): + """The object that represents the operation. + + :param provider: Service provider: Microsoft.Resources. + :type provider: str + :param resource: Resource on which the operation is performed: Profile, endpoint, etc. + :type resource: str + :param operation: Operation type: Read, write, delete, etc. + :type operation: str + :param description: Description of the 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, + *, + 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 + + +class OperationListResult(msrest.serialization.Model): + """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. + + :param value: List of Microsoft.Resources operations. + :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.Operation] + :param next_link: URL to get the next set of operation list results if there are any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ParametersLink(msrest.serialization.Model): + """Entity representing the reference to the deployment parameters. + + All required parameters must be populated in order to send to Azure. + + :param uri: Required. The URI of the parameters file. + :type uri: str + :param content_version: If included, must match the ContentVersion in the template. + :type content_version: str + """ + + _validation = { + 'uri': {'required': True}, + } + + _attribute_map = { + 'uri': {'key': 'uri', 'type': 'str'}, + 'content_version': {'key': 'contentVersion', 'type': 'str'}, + } + + def __init__( + self, + *, + uri: str, + content_version: Optional[str] = None, + **kwargs + ): + super(ParametersLink, self).__init__(**kwargs) + self.uri = uri + self.content_version = content_version + + +class Plan(msrest.serialization.Model): + """Plan for the resource. + + :param name: The plan ID. + :type name: str + :param publisher: The publisher ID. + :type publisher: str + :param product: The offer ID. + :type product: str + :param promotion_code: The promotion code. + :type promotion_code: str + :param version: The plan's version. + :type version: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): + super(Plan, self).__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class Provider(msrest.serialization.Model): + """Resource provider information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The provider ID. + :vartype id: str + :param namespace: The namespace of the resource provider. + :type namespace: str + :ivar registration_state: The registration state of the resource provider. + :vartype registration_state: str + :ivar registration_policy: The registration policy of the resource provider. + :vartype registration_policy: str + :ivar resource_types: The collection of provider resource types. + :vartype resource_types: + list[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderResourceType] + """ + + _validation = { + 'id': {'readonly': True}, + 'registration_state': {'readonly': True}, + 'registration_policy': {'readonly': True}, + 'resource_types': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'namespace': {'key': 'namespace', 'type': 'str'}, + 'registration_state': {'key': 'registrationState', 'type': 'str'}, + 'registration_policy': {'key': 'registrationPolicy', 'type': 'str'}, + 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, + } + + def __init__( + self, + *, + namespace: Optional[str] = None, + **kwargs + ): + super(Provider, self).__init__(**kwargs) + self.id = None + self.namespace = namespace + self.registration_state = None + self.registration_policy = None + self.resource_types = None + + +class ProviderExtendedLocation(msrest.serialization.Model): + """The provider extended location. + + :param location: The azure location. + :type location: str + :param type: The extended location type. + :type type: str + :param extended_locations: The extended locations for the azure location. + :type extended_locations: list[str] + """ + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'extended_locations': {'key': 'extendedLocations', 'type': '[str]'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + type: Optional[str] = None, + extended_locations: Optional[List[str]] = None, + **kwargs + ): + super(ProviderExtendedLocation, self).__init__(**kwargs) + self.location = location + self.type = type + self.extended_locations = extended_locations + + +class ProviderListResult(msrest.serialization.Model): + """List of resource providers. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: An array of resource providers. + :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.Provider] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Provider]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Provider"]] = None, + **kwargs + ): + super(ProviderListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ProviderResourceType(msrest.serialization.Model): + """Resource type managed by the resource provider. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param resource_type: The resource type. + :type resource_type: str + :param locations: The collection of locations where this resource type can be created. + :type locations: list[str] + :param location_mappings: The location mappings that are supported by this resource type. + :type location_mappings: + list[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderExtendedLocation] + :param aliases: The aliases that are supported by this resource type. + :type aliases: list[~azure.mgmt.resource.resources.v2021_01_01.models.Alias] + :param api_versions: The API version. + :type api_versions: list[str] + :ivar default_api_version: The default API version. + :vartype default_api_version: str + :ivar api_profiles: The API profiles for the resource provider. + :vartype api_profiles: list[~azure.mgmt.resource.resources.v2021_01_01.models.ApiProfile] + :param capabilities: The additional capabilities offered by this resource type. + :type capabilities: str + :param properties: The properties. + :type properties: dict[str, str] + """ + + _validation = { + 'default_api_version': {'readonly': True}, + 'api_profiles': {'readonly': True}, + } + + _attribute_map = { + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'locations': {'key': 'locations', 'type': '[str]'}, + 'location_mappings': {'key': 'locationMappings', 'type': '[ProviderExtendedLocation]'}, + 'aliases': {'key': 'aliases', 'type': '[Alias]'}, + 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, + 'default_api_version': {'key': 'defaultApiVersion', 'type': 'str'}, + 'api_profiles': {'key': 'apiProfiles', 'type': '[ApiProfile]'}, + 'capabilities': {'key': 'capabilities', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + } + + def __init__( + self, + *, + resource_type: Optional[str] = None, + locations: Optional[List[str]] = None, + location_mappings: Optional[List["ProviderExtendedLocation"]] = None, + aliases: Optional[List["Alias"]] = None, + api_versions: Optional[List[str]] = None, + capabilities: Optional[str] = None, + properties: Optional[Dict[str, str]] = None, + **kwargs + ): + super(ProviderResourceType, self).__init__(**kwargs) + self.resource_type = resource_type + self.locations = locations + self.location_mappings = location_mappings + self.aliases = aliases + self.api_versions = api_versions + self.default_api_version = None + self.api_profiles = None + self.capabilities = capabilities + self.properties = properties + + +class ProviderResourceTypeListResult(msrest.serialization.Model): + """List of resource types of a resource provider. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: An array of resource types. + :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderResourceType] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ProviderResourceType]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ProviderResourceType"]] = None, + **kwargs + ): + super(ProviderResourceTypeListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ResourceGroup(msrest.serialization.Model): + """Resource group information. + + 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: The ID of the resource group. + :vartype id: str + :ivar name: The name of the resource group. + :vartype name: str + :ivar type: The type of the resource group. + :vartype type: str + :param properties: The resource group properties. + :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupProperties + :param location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :type location: str + :param managed_by: The ID of the resource that manages this resource group. + :type managed_by: str + :param tags: A set of tags. The tags attached to the resource group. + :type tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, + 'location': {'key': 'location', 'type': 'str'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + location: str, + properties: Optional["ResourceGroupProperties"] = None, + managed_by: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(ResourceGroup, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.properties = properties + self.location = location + self.managed_by = managed_by + self.tags = tags + + +class ResourceGroupExportResult(msrest.serialization.Model): + """Resource group export result. + + :param template: The template content. + :type template: object + :param error: The template export error. + :type error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse + """ + + _attribute_map = { + 'template': {'key': 'template', 'type': 'object'}, + 'error': {'key': 'error', 'type': 'ErrorResponse'}, + } + + def __init__( + self, + *, + template: Optional[object] = None, + error: Optional["ErrorResponse"] = None, + **kwargs + ): + super(ResourceGroupExportResult, self).__init__(**kwargs) + self.template = template + self.error = error + + +class ResourceGroupFilter(msrest.serialization.Model): + """Resource group filter. + + :param tag_name: The tag name. + :type tag_name: str + :param tag_value: The tag value. + :type tag_value: str + """ + + _attribute_map = { + 'tag_name': {'key': 'tagName', 'type': 'str'}, + 'tag_value': {'key': 'tagValue', 'type': 'str'}, + } + + def __init__( + self, + *, + tag_name: Optional[str] = None, + tag_value: Optional[str] = None, + **kwargs + ): + super(ResourceGroupFilter, self).__init__(**kwargs) + self.tag_name = tag_name + self.tag_value = tag_value + + +class ResourceGroupListResult(msrest.serialization.Model): + """List of resource groups. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: An array of resource groups. + :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ResourceGroup"]] = None, + **kwargs + ): + super(ResourceGroupListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ResourceGroupPatchable(msrest.serialization.Model): + """Resource group information. + + :param name: The name of the resource group. + :type name: str + :param properties: The resource group properties. + :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupProperties + :param managed_by: The ID of the resource that manages this resource group. + :type managed_by: str + :param tags: A set of tags. The tags attached to the resource group. + :type tags: dict[str, str] + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, + 'managed_by': {'key': 'managedBy', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["ResourceGroupProperties"] = None, + managed_by: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(ResourceGroupPatchable, self).__init__(**kwargs) + self.name = name + self.properties = properties + self.managed_by = managed_by + self.tags = tags + + +class ResourceGroupProperties(msrest.serialization.Model): + """The resource group properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceGroupProperties, self).__init__(**kwargs) + self.provisioning_state = None + + +class ResourceListResult(msrest.serialization.Model): + """List of resource groups. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: An array of resources. + :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResourceExpanded] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["GenericResourceExpanded"]] = None, + **kwargs + ): + super(ResourceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): + """Resource provider operation's display properties. + + :param publisher: Operation description. + :type publisher: str + :param provider: Operation provider. + :type provider: str + :param resource: Operation resource. + :type resource: str + :param operation: Resource provider operation. + :type operation: str + :param description: Operation description. + :type description: str + """ + + _attribute_map = { + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + publisher: Optional[str] = None, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) + self.publisher = publisher + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class ResourceReference(msrest.serialization.Model): + """The resource Id model. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The fully qualified resource Id. + :vartype id: str + """ + + _validation = { + 'id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceReference, self).__init__(**kwargs) + self.id = None + + +class ResourcesMoveInfo(msrest.serialization.Model): + """Parameters of move resources. + + :param resources: The IDs of the resources. + :type resources: list[str] + :param target_resource_group: The target resource group. + :type target_resource_group: str + """ + + _attribute_map = { + 'resources': {'key': 'resources', 'type': '[str]'}, + 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, + } + + def __init__( + self, + *, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ): + super(ResourcesMoveInfo, self).__init__(**kwargs) + self.resources = resources + self.target_resource_group = target_resource_group + + +class ScopedDeployment(msrest.serialization.Model): + """Deployment operation parameters. + + All required parameters must be populated in order to send to Azure. + + :param location: Required. The location to store the deployment data. + :type location: str + :param properties: Required. The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentProperties + :param tags: A set of tags. Deployment tags. + :type tags: dict[str, str] + """ + + _validation = { + 'location': {'required': True}, + 'properties': {'required': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + location: str, + properties: "DeploymentProperties", + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(ScopedDeployment, self).__init__(**kwargs) + self.location = location + self.properties = properties + self.tags = tags + + +class ScopedDeploymentWhatIf(msrest.serialization.Model): + """Deployment What-if operation parameters. + + All required parameters must be populated in order to send to Azure. + + :param location: Required. The location to store the deployment data. + :type location: str + :param properties: Required. The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfProperties + """ + + _validation = { + 'location': {'required': True}, + 'properties': {'required': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'DeploymentWhatIfProperties'}, + } + + def __init__( + self, + *, + location: str, + properties: "DeploymentWhatIfProperties", + **kwargs + ): + super(ScopedDeploymentWhatIf, self).__init__(**kwargs) + self.location = location + self.properties = properties + + +class Sku(msrest.serialization.Model): + """SKU for the resource. + + :param name: The SKU name. + :type name: str + :param tier: The SKU tier. + :type tier: str + :param size: The SKU size. + :type size: str + :param family: The SKU family. + :type family: str + :param model: The SKU model. + :type model: str + :param capacity: The SKU capacity. + :type capacity: int + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + 'size': {'key': 'size', 'type': 'str'}, + 'family': {'key': 'family', 'type': 'str'}, + 'model': {'key': 'model', 'type': 'str'}, + 'capacity': {'key': 'capacity', 'type': 'int'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): + super(Sku, self).__init__(**kwargs) + self.name = name + self.tier = tier + self.size = size + self.family = family + self.model = model + self.capacity = capacity + + +class StatusMessage(msrest.serialization.Model): + """Operation status message object. + + :param status: Status of the deployment operation. + :type status: str + :param error: The error reported by the operation. + :type error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse + """ + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'error': {'key': 'error', 'type': 'ErrorResponse'}, + } + + def __init__( + self, + *, + status: Optional[str] = None, + error: Optional["ErrorResponse"] = None, + **kwargs + ): + super(StatusMessage, self).__init__(**kwargs) + self.status = status + self.error = error + + +class SubResource(msrest.serialization.Model): + """Sub-resource. + + :param id: Resource ID. + :type id: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): + super(SubResource, self).__init__(**kwargs) + self.id = id + + +class TagCount(msrest.serialization.Model): + """Tag count. + + :param type: Type of count. + :type type: str + :param value: Value of count. + :type value: int + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'int'}, + } + + def __init__( + self, + *, + type: Optional[str] = None, + value: Optional[int] = None, + **kwargs + ): + super(TagCount, self).__init__(**kwargs) + self.type = type + self.value = value + + +class TagDetails(msrest.serialization.Model): + """Tag details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The tag name ID. + :vartype id: str + :param tag_name: The tag name. + :type tag_name: str + :param count: The total number of resources that use the resource tag. When a tag is initially + created and has no associated resources, the value is 0. + :type count: ~azure.mgmt.resource.resources.v2021_01_01.models.TagCount + :param values: The list of tag values. + :type values: list[~azure.mgmt.resource.resources.v2021_01_01.models.TagValue] + """ + + _validation = { + 'id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'tag_name': {'key': 'tagName', 'type': 'str'}, + 'count': {'key': 'count', 'type': 'TagCount'}, + 'values': {'key': 'values', 'type': '[TagValue]'}, + } + + def __init__( + self, + *, + tag_name: Optional[str] = None, + count: Optional["TagCount"] = None, + values: Optional[List["TagValue"]] = None, + **kwargs + ): + super(TagDetails, self).__init__(**kwargs) + self.id = None + self.tag_name = tag_name + self.count = count + self.values = values + + +class Tags(msrest.serialization.Model): + """A dictionary of name and value pairs. + + :param tags: A set of tags. Dictionary of :code:``. + :type tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(Tags, self).__init__(**kwargs) + self.tags = tags + + +class TagsListResult(msrest.serialization.Model): + """List of subscription tags. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: An array of tags. + :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.TagDetails] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["TagDetails"]] = None, + **kwargs + ): + super(TagsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class TagsPatchResource(msrest.serialization.Model): + """Wrapper resource for tags patch API request only. + + :param operation: The operation type for the patch API. Possible values include: "Replace", + "Merge", "Delete". + :type operation: str or ~azure.mgmt.resource.resources.v2021_01_01.models.TagsPatchOperation + :param properties: The set of tags. + :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.Tags + """ + + _attribute_map = { + 'operation': {'key': 'operation', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'Tags'}, + } + + def __init__( + self, + *, + operation: Optional[Union[str, "TagsPatchOperation"]] = None, + properties: Optional["Tags"] = None, + **kwargs + ): + super(TagsPatchResource, self).__init__(**kwargs) + self.operation = operation + self.properties = properties + + +class TagsResource(msrest.serialization.Model): + """Wrapper resource for tags API requests and responses. + + 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: The ID of the tags wrapper resource. + :vartype id: str + :ivar name: The name of the tags wrapper resource. + :vartype name: str + :ivar type: The type of the tags wrapper resource. + :vartype type: str + :param properties: Required. The set of tags. + :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.Tags + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'properties': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'Tags'}, + } + + def __init__( + self, + *, + properties: "Tags", + **kwargs + ): + super(TagsResource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.properties = properties + + +class TagValue(msrest.serialization.Model): + """Tag information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The tag value ID. + :vartype id: str + :param tag_value: The tag value. + :type tag_value: str + :param count: The tag value count. + :type count: ~azure.mgmt.resource.resources.v2021_01_01.models.TagCount + """ + + _validation = { + 'id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'tag_value': {'key': 'tagValue', 'type': 'str'}, + 'count': {'key': 'count', 'type': 'TagCount'}, + } + + def __init__( + self, + *, + tag_value: Optional[str] = None, + count: Optional["TagCount"] = None, + **kwargs + ): + super(TagValue, self).__init__(**kwargs) + self.id = None + self.tag_value = tag_value + self.count = count + + +class TargetResource(msrest.serialization.Model): + """Target resource. + + :param id: The ID of the resource. + :type id: str + :param resource_name: The name of the resource. + :type resource_name: str + :param resource_type: The type of the resource. + :type resource_type: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'resource_name': {'key': 'resourceName', 'type': 'str'}, + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + resource_name: Optional[str] = None, + resource_type: Optional[str] = None, + **kwargs + ): + super(TargetResource, self).__init__(**kwargs) + self.id = id + self.resource_name = resource_name + self.resource_type = resource_type + + +class TemplateHashResult(msrest.serialization.Model): + """Result of the request to calculate template hash. It contains a string of minified template and its hash. + + :param minified_template: The minified template string. + :type minified_template: str + :param template_hash: The template hash. + :type template_hash: str + """ + + _attribute_map = { + 'minified_template': {'key': 'minifiedTemplate', 'type': 'str'}, + 'template_hash': {'key': 'templateHash', 'type': 'str'}, + } + + def __init__( + self, + *, + minified_template: Optional[str] = None, + template_hash: Optional[str] = None, + **kwargs + ): + super(TemplateHashResult, self).__init__(**kwargs) + self.minified_template = minified_template + self.template_hash = template_hash + + +class TemplateLink(msrest.serialization.Model): + """Entity representing the reference to the template. + + :param uri: The URI of the template to deploy. Use either the uri or id property, but not both. + :type uri: str + :param id: The resource id of a Template Spec. Use either the id or uri property, but not both. + :type id: str + :param relative_path: The relativePath property can be used to deploy a linked template at a + location relative to the parent. If the parent template was linked with a TemplateSpec, this + will reference an artifact in the TemplateSpec. If the parent was linked with a URI, the child + deployment will be a combination of the parent and relativePath URIs. + :type relative_path: str + :param content_version: If included, must match the ContentVersion in the template. + :type content_version: str + :param query_string: The query string (for example, a SAS token) to be used with the + templateLink URI. + :type query_string: str + """ + + _attribute_map = { + 'uri': {'key': 'uri', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'relative_path': {'key': 'relativePath', 'type': 'str'}, + 'content_version': {'key': 'contentVersion', 'type': 'str'}, + 'query_string': {'key': 'queryString', 'type': 'str'}, + } + + def __init__( + self, + *, + uri: Optional[str] = None, + id: Optional[str] = None, + relative_path: Optional[str] = None, + content_version: Optional[str] = None, + query_string: Optional[str] = None, + **kwargs + ): + super(TemplateLink, self).__init__(**kwargs) + self.uri = uri + self.id = id + self.relative_path = relative_path + self.content_version = content_version + self.query_string = query_string + + +class WhatIfChange(msrest.serialization.Model): + """Information about a single resource change predicted by What-If operation. + + All required parameters must be populated in order to send to Azure. + + :param resource_id: Required. Resource ID. + :type resource_id: str + :param change_type: Required. Type of change that will be made to the resource when the + deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", + "NoChange", "Modify", "Unsupported". + :type change_type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ChangeType + :param unsupported_reason: The explanation about why the resource is unsupported by What-If. + :type unsupported_reason: str + :param before: The snapshot of the resource before the deployment is executed. + :type before: object + :param after: The predicted snapshot of the resource after the deployment is executed. + :type after: object + :param delta: The predicted changes to resource properties. + :type delta: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfPropertyChange] + """ + + _validation = { + 'resource_id': {'required': True}, + 'change_type': {'required': True}, + } + + _attribute_map = { + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + 'change_type': {'key': 'changeType', 'type': 'str'}, + 'unsupported_reason': {'key': 'unsupportedReason', 'type': 'str'}, + 'before': {'key': 'before', 'type': 'object'}, + 'after': {'key': 'after', 'type': 'object'}, + 'delta': {'key': 'delta', 'type': '[WhatIfPropertyChange]'}, + } + + def __init__( + self, + *, + resource_id: str, + change_type: Union[str, "ChangeType"], + unsupported_reason: Optional[str] = None, + before: Optional[object] = None, + after: Optional[object] = None, + delta: Optional[List["WhatIfPropertyChange"]] = None, + **kwargs + ): + super(WhatIfChange, self).__init__(**kwargs) + self.resource_id = resource_id + self.change_type = change_type + self.unsupported_reason = unsupported_reason + self.before = before + self.after = after + self.delta = delta + + +class WhatIfOperationResult(msrest.serialization.Model): + """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. + + :param status: Status of the What-If operation. + :type status: str + :param error: Error when What-If operation fails. + :type error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse + :param changes: List of resource changes predicted by What-If operation. + :type changes: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfChange] + """ + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'error': {'key': 'error', 'type': 'ErrorResponse'}, + 'changes': {'key': 'properties.changes', 'type': '[WhatIfChange]'}, + } + + def __init__( + self, + *, + status: Optional[str] = None, + error: Optional["ErrorResponse"] = None, + changes: Optional[List["WhatIfChange"]] = None, + **kwargs + ): + super(WhatIfOperationResult, self).__init__(**kwargs) + self.status = status + self.error = error + self.changes = changes + + +class WhatIfPropertyChange(msrest.serialization.Model): + """The predicted change to the resource property. + + All required parameters must be populated in order to send to Azure. + + :param path: Required. The path of the property. + :type path: str + :param property_change_type: Required. The type of property change. Possible values include: + "Create", "Delete", "Modify", "Array", "NoEffect". + :type property_change_type: str or + ~azure.mgmt.resource.resources.v2021_01_01.models.PropertyChangeType + :param before: The value of the property before the deployment is executed. + :type before: object + :param after: The value of the property after the deployment is executed. + :type after: object + :param children: Nested property changes. + :type children: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfPropertyChange] + """ + + _validation = { + 'path': {'required': True}, + 'property_change_type': {'required': True}, + } + + _attribute_map = { + 'path': {'key': 'path', 'type': 'str'}, + 'property_change_type': {'key': 'propertyChangeType', 'type': 'str'}, + 'before': {'key': 'before', 'type': 'object'}, + 'after': {'key': 'after', 'type': 'object'}, + 'children': {'key': 'children', 'type': '[WhatIfPropertyChange]'}, + } + + def __init__( + self, + *, + path: str, + property_change_type: Union[str, "PropertyChangeType"], + before: Optional[object] = None, + after: Optional[object] = None, + children: Optional[List["WhatIfPropertyChange"]] = None, + **kwargs + ): + super(WhatIfPropertyChange, self).__init__(**kwargs) + self.path = path + self.property_change_type = property_change_type + self.before = before + self.after = after + self.children = children diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_resource_management_client_enums.py new file mode 100644 index 0000000000000..de30896c2196a --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_resource_management_client_enums.py @@ -0,0 +1,225 @@ +# 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 enum import Enum, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class AliasPathAttributes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The attributes of the token that the alias path is referring to. + """ + + #: The token that the alias path is referring to has no attributes. + NONE = "None" + #: The token that the alias path is referring to is modifiable by policies with 'modify' effect. + MODIFIABLE = "Modifiable" + +class AliasPathTokenType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of the token that the alias path is referring to. + """ + + #: The token type is not specified. + NOT_SPECIFIED = "NotSpecified" + #: The token type can be anything. + ANY = "Any" + #: The token type is string. + STRING = "String" + #: The token type is object. + OBJECT = "Object" + #: The token type is array. + ARRAY = "Array" + #: The token type is integer. + INTEGER = "Integer" + #: The token type is number. + NUMBER = "Number" + #: The token type is boolean. + BOOLEAN = "Boolean" + +class AliasPatternType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of alias pattern + """ + + #: NotSpecified is not allowed. + NOT_SPECIFIED = "NotSpecified" + #: Extract is the only allowed value. + EXTRACT = "Extract" + +class AliasType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of the alias. + """ + + #: Alias type is unknown (same as not providing alias type). + NOT_SPECIFIED = "NotSpecified" + #: Alias value is not secret. + PLAIN_TEXT = "PlainText" + #: Alias value is secret. + MASK = "Mask" + +class ChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Type of change that will be made to the resource when the deployment is executed. + """ + + #: The resource does not exist in the current state but is present in the desired state. The + #: resource will be created when the deployment is executed. + CREATE = "Create" + #: The resource exists in the current state and is missing from the desired state. The resource + #: will be deleted when the deployment is executed. + DELETE = "Delete" + #: The resource exists in the current state and is missing from the desired state. The resource + #: will not be deployed or modified when the deployment is executed. + IGNORE = "Ignore" + #: The resource exists in the current state and the desired state and will be redeployed when the + #: deployment is executed. The properties of the resource may or may not change. + DEPLOY = "Deploy" + #: The resource exists in the current state and the desired state and will be redeployed when the + #: deployment is executed. The properties of the resource will not change. + NO_CHANGE = "NoChange" + #: The resource exists in the current state and the desired state and will be redeployed when the + #: deployment is executed. The properties of the resource will change. + MODIFY = "Modify" + #: The resource is not supported by What-If. + UNSUPPORTED = "Unsupported" + +class DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The mode that is used to deploy resources. This value can be either Incremental or Complete. In + Incremental mode, resources are deployed without deleting existing resources that are not + included in the template. In Complete mode, resources are deployed and existing resources in + the resource group that are not included in the template are deleted. Be careful when using + Complete mode as you may unintentionally delete resources. + """ + + INCREMENTAL = "Incremental" + COMPLETE = "Complete" + +class ExpressionEvaluationOptionsScopeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The scope to be used for evaluation of parameters, variables and functions in a nested + template. + """ + + NOT_SPECIFIED = "NotSpecified" + OUTER = "Outer" + INNER = "Inner" + +class ExtendedLocationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The extended location type. + """ + + EDGE_ZONE = "EdgeZone" + +class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. + """ + + LAST_SUCCESSFUL = "LastSuccessful" + SPECIFIC_DEPLOYMENT = "SpecificDeployment" + +class PropertyChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of property change. + """ + + #: The property does not exist in the current state but is present in the desired state. The + #: property will be created when the deployment is executed. + CREATE = "Create" + #: The property exists in the current state and is missing from the desired state. It will be + #: deleted when the deployment is executed. + DELETE = "Delete" + #: The property exists in both current and desired state and is different. The value of the + #: property will change when the deployment is executed. + MODIFY = "Modify" + #: The property is an array and contains nested changes. + ARRAY = "Array" + #: The property will not be set or updated. + NO_EFFECT = "NoEffect" + +class ProvisioningOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The name of the current provisioning operation. + """ + + #: The provisioning operation is not specified. + NOT_SPECIFIED = "NotSpecified" + #: The provisioning operation is create. + CREATE = "Create" + #: The provisioning operation is delete. + DELETE = "Delete" + #: The provisioning operation is waiting. + WAITING = "Waiting" + #: The provisioning operation is waiting Azure async operation. + AZURE_ASYNC_OPERATION_WAITING = "AzureAsyncOperationWaiting" + #: The provisioning operation is waiting for resource cache. + RESOURCE_CACHE_WAITING = "ResourceCacheWaiting" + #: The provisioning operation is action. + ACTION = "Action" + #: The provisioning operation is read. + READ = "Read" + #: The provisioning operation is evaluate output. + EVALUATE_DEPLOYMENT_OUTPUT = "EvaluateDeploymentOutput" + #: The provisioning operation is cleanup. This operation is part of the 'complete' mode + #: deployment. + DEPLOYMENT_CLEANUP = "DeploymentCleanup" + +class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Denotes the state of provisioning. + """ + + NOT_SPECIFIED = "NotSpecified" + ACCEPTED = "Accepted" + RUNNING = "Running" + READY = "Ready" + CREATING = "Creating" + CREATED = "Created" + DELETING = "Deleting" + DELETED = "Deleted" + CANCELED = "Canceled" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + UPDATING = "Updating" + +class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The identity type. + """ + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + NONE = "None" + +class TagsPatchOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The operation type for the patch API. + """ + + #: The 'replace' option replaces the entire set of existing tags with a new set. + REPLACE = "Replace" + #: The 'merge' option allows adding tags with new names and updating the values of tags with + #: existing names. + MERGE = "Merge" + #: The 'delete' option allows selectively deleting tags based on given names or name/value pairs. + DELETE = "Delete" + +class WhatIfResultFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The format of the What-If results + """ + + RESOURCE_ID_ONLY = "ResourceIdOnly" + FULL_RESOURCE_PAYLOADS = "FullResourcePayloads" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/__init__.py new file mode 100644 index 0000000000000..b5dcba5d6d4b2 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/__init__.py @@ -0,0 +1,27 @@ +# 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 ._operations import Operations +from ._deployments_operations import DeploymentsOperations +from ._providers_operations import ProvidersOperations +from ._provider_resource_types_operations import ProviderResourceTypesOperations +from ._resources_operations import ResourcesOperations +from ._resource_groups_operations import ResourceGroupsOperations +from ._tags_operations import TagsOperations +from ._deployment_operations_operations import DeploymentOperationsOperations + +__all__ = [ + 'Operations', + 'DeploymentsOperations', + 'ProvidersOperations', + 'ProviderResourceTypesOperations', + 'ResourcesOperations', + 'ResourceGroupsOperations', + 'TagsOperations', + 'DeploymentOperationsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_deployment_operations_operations.py new file mode 100644 index 0000000000000..b26f10985eb9b --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_deployment_operations_operations.py @@ -0,0 +1,739 @@ +# 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 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.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentOperationsOperations(object): + """DeploymentOperationsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2021_01_01.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 get_at_scope( + self, + scope, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.DeploymentOperation" + """Gets a deployments operation. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_scope( + self, + scope, # type: str + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param top: The number of results to return. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_at_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + + def get_at_tenant_scope( + self, + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.DeploymentOperation" + """Gets a deployments operation. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_tenant_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_tenant_scope( + self, + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param top: The number of results to return. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_at_tenant_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + + def get_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.DeploymentOperation" + """Gets a deployments operation. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_management_group_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param top: The number of results to return. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_at_management_group_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + + def get_at_subscription_scope( + self, + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.DeploymentOperation" + """Gets a deployments operation. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_subscription_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_subscription_scope( + self, + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param top: The number of results to return. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_at_subscription_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + + def get( + self, + resource_group_name, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.DeploymentOperation" + """Gets a deployments operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name, # type: str + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param top: The number of results to return. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_deployments_operations.py new file mode 100644 index 0000000000000..85ccc592249bf --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_deployments_operations.py @@ -0,0 +1,4010 @@ +# 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 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.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentsOperations(object): + """DeploymentsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2021_01_01.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 _delete_at_scope_initial( + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self._delete_at_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + 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 [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete_at_scope( + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Deletes a deployment from the deployment history. + + A template deployment that is currently running cannot be deleted. Deleting a template + deployment removes the associated deployment operations. This is an asynchronous operation that + returns a status of 202 until the template deployment is successfully deleted. The Location + response header contains the URI that is used to obtain the status of the process. While the + process is running, a call to the URI in the Location header returns a status of 202. When the + process finishes, the URI in the Location header returns a status of 204 on success. If the + asynchronous request failed, the URI in the Location header returns an error-level status code. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_at_scope_initial( + scope=scope, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def check_existence_at_scope( + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Checks whether the deployment exists. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.check_existence_at_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(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 [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def _create_or_update_at_scope_initial( + self, + scope, # type: str + deployment_name, # type: str + parameters, # type: "_models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> "_models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_at_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Deployment') + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_create_or_update_at_scope( + self, + scope, # type: str + deployment_name, # type: str + parameters, # type: "_models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.DeploymentExtended"] + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + 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_at_scope_initial( + scope=scope, + deployment_name=deployment_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('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def get_at_scope( + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.DeploymentExtended" + """Gets a deployment. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def cancel_at_scope( + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Cancels a currently running template deployment. + + You can cancel a deployment only if the provisioningState is Accepted or Running. After the + deployment is canceled, the provisioningState is set to Canceled. Canceling a template + deployment stops the currently running template deployment and leaves the resources partially + deployed. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.cancel_at_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + def _validate_at_scope_initial( + self, + scope, # type: str + deployment_name, # type: str + parameters, # type: "_models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.DeploymentValidateResult"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._validate_at_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Deployment') + body_content_kwargs['content'] = body_content + request = self._client.post(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, 202, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _validate_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + def begin_validate_at_scope( + self, + scope, # type: str + deployment_name, # type: str + parameters, # type: "_models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.DeploymentValidateResult"] + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to validate. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] + 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._validate_at_scope_initial( + scope=scope, + deployment_name=deployment_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('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + def export_template_at_scope( + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.DeploymentExportResult" + """Exports the template used for specified deployment. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.export_template_at_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_at_scope( + self, + scope, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.DeploymentListResult"] + """Get all the deployments at the given scope. + + :param scope: The resource scope. + :type scope: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :param top: The number of results to get. If null is passed, returns all deployments. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_at_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/'} # type: ignore + + def _delete_at_tenant_scope_initial( + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self._delete_at_tenant_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + 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 [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete_at_tenant_scope( + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Deletes a deployment from the deployment history. + + A template deployment that is currently running cannot be deleted. Deleting a template + deployment removes the associated deployment operations. This is an asynchronous operation that + returns a status of 202 until the template deployment is successfully deleted. The Location + response header contains the URI that is used to obtain the status of the process. While the + process is running, a call to the URI in the Location header returns a status of 202. When the + process finishes, the URI in the Location header returns a status of 204 on success. If the + asynchronous request failed, the URI in the Location header returns an error-level status code. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_at_tenant_scope_initial( + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def check_existence_at_tenant_scope( + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Checks whether the deployment exists. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.check_existence_at_tenant_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(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 [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def _create_or_update_at_tenant_scope_initial( + self, + deployment_name, # type: str + parameters, # type: "_models.ScopedDeployment" + **kwargs # type: Any + ): + # type: (...) -> "_models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_at_tenant_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ScopedDeployment') + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_create_or_update_at_tenant_scope( + self, + deployment_name, # type: str + parameters, # type: "_models.ScopedDeployment" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.DeploymentExtended"] + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + 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_at_tenant_scope_initial( + deployment_name=deployment_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('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def get_at_tenant_scope( + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.DeploymentExtended" + """Gets a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_tenant_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def cancel_at_tenant_scope( + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Cancels a currently running template deployment. + + You can cancel a deployment only if the provisioningState is Accepted or Running. After the + deployment is canceled, the provisioningState is set to Canceled. Canceling a template + deployment stops the currently running template deployment and leaves the resources partially + deployed. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.cancel_at_tenant_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + def _validate_at_tenant_scope_initial( + self, + deployment_name, # type: str + parameters, # type: "_models.ScopedDeployment" + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.DeploymentValidateResult"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._validate_at_tenant_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ScopedDeployment') + body_content_kwargs['content'] = body_content + request = self._client.post(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, 202, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _validate_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + def begin_validate_at_tenant_scope( + self, + deployment_name, # type: str + parameters, # type: "_models.ScopedDeployment" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.DeploymentValidateResult"] + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to validate. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] + 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._validate_at_tenant_scope_initial( + deployment_name=deployment_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('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + def _what_if_at_tenant_scope_initial( + self, + deployment_name, # type: str + parameters, # type: "_models.ScopedDeploymentWhatIf" + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.WhatIfOperationResult"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._what_if_at_tenant_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + body_content_kwargs['content'] = body_content + request = self._client.post(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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _what_if_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + def begin_what_if_at_tenant_scope( + self, + deployment_name, # type: str + parameters, # type: "_models.ScopedDeploymentWhatIf" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.WhatIfOperationResult"] + """Returns changes that will be made by the deployment if executed at the scope of the tenant + group. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to validate. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeploymentWhatIf + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] + 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._what_if_at_tenant_scope_initial( + deployment_name=deployment_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('WhatIfOperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **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_what_if_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + def export_template_at_tenant_scope( + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.DeploymentExportResult" + """Exports the template used for specified deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.export_template_at_tenant_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_at_tenant_scope( + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.DeploymentListResult"] + """Get all the deployments at the tenant scope. + + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :param top: The number of results to get. If null is passed, returns all deployments. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_at_tenant_scope.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/'} # type: ignore + + def _delete_at_management_group_scope_initial( + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self._delete_at_management_group_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + 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 [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Deletes a deployment from the deployment history. + + A template deployment that is currently running cannot be deleted. Deleting a template + deployment removes the associated deployment operations. This is an asynchronous operation that + returns a status of 202 until the template deployment is successfully deleted. The Location + response header contains the URI that is used to obtain the status of the process. While the + process is running, a call to the URI in the Location header returns a status of 202. When the + process finishes, the URI in the Location header returns a status of 204 on success. If the + asynchronous request failed, the URI in the Location header returns an error-level status code. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_at_management_group_scope_initial( + group_id=group_id, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def check_existence_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Checks whether the deployment exists. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.check_existence_at_management_group_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(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 [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def _create_or_update_at_management_group_scope_initial( + self, + group_id, # type: str + deployment_name, # type: str + parameters, # type: "_models.ScopedDeployment" + **kwargs # type: Any + ): + # type: (...) -> "_models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_at_management_group_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ScopedDeployment') + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_create_or_update_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + parameters, # type: "_models.ScopedDeployment" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.DeploymentExtended"] + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + 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_at_management_group_scope_initial( + group_id=group_id, + deployment_name=deployment_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('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def get_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.DeploymentExtended" + """Gets a deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_management_group_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def cancel_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Cancels a currently running template deployment. + + You can cancel a deployment only if the provisioningState is Accepted or Running. After the + deployment is canceled, the provisioningState is set to Canceled. Canceling a template + deployment stops the currently running template deployment and leaves the resources partially + deployed. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.cancel_at_management_group_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + def _validate_at_management_group_scope_initial( + self, + group_id, # type: str + deployment_name, # type: str + parameters, # type: "_models.ScopedDeployment" + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.DeploymentValidateResult"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._validate_at_management_group_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ScopedDeployment') + body_content_kwargs['content'] = body_content + request = self._client.post(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, 202, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _validate_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + def begin_validate_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + parameters, # type: "_models.ScopedDeployment" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.DeploymentValidateResult"] + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to validate. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] + 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._validate_at_management_group_scope_initial( + group_id=group_id, + deployment_name=deployment_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('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + def _what_if_at_management_group_scope_initial( + self, + group_id, # type: str + deployment_name, # type: str + parameters, # type: "_models.ScopedDeploymentWhatIf" + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.WhatIfOperationResult"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._what_if_at_management_group_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + body_content_kwargs['content'] = body_content + request = self._client.post(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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _what_if_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + def begin_what_if_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + parameters, # type: "_models.ScopedDeploymentWhatIf" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.WhatIfOperationResult"] + """Returns changes that will be made by the deployment if executed at the scope of the management + group. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to validate. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeploymentWhatIf + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] + 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._what_if_at_management_group_scope_initial( + group_id=group_id, + deployment_name=deployment_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('WhatIfOperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **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_what_if_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + def export_template_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.DeploymentExportResult" + """Exports the template used for specified deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.export_template_at_management_group_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_at_management_group_scope( + self, + group_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.DeploymentListResult"] + """Get all the deployments for a management group. + + :param group_id: The management group ID. + :type group_id: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :param top: The number of results to get. If null is passed, returns all deployments. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_at_management_group_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/'} # type: ignore + + def _delete_at_subscription_scope_initial( + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.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 [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete_at_subscription_scope( + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Deletes a deployment from the deployment history. + + A template deployment that is currently running cannot be deleted. Deleting a template + deployment removes the associated deployment operations. This is an asynchronous operation that + returns a status of 202 until the template deployment is successfully deleted. The Location + response header contains the URI that is used to obtain the status of the process. While the + process is running, a call to the URI in the Location header returns a status of 202. When the + process finishes, the URI in the Location header returns a status of 204 on success. If the + asynchronous request failed, the URI in the Location header returns an error-level status code. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_at_subscription_scope_initial( + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def check_existence_at_subscription_scope( + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Checks whether the deployment exists. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(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 [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def _create_or_update_at_subscription_scope_initial( + self, + deployment_name, # type: str + parameters, # type: "_models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> "_models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Deployment') + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_create_or_update_at_subscription_scope( + self, + deployment_name, # type: str + parameters, # type: "_models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.DeploymentExtended"] + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + 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_at_subscription_scope_initial( + deployment_name=deployment_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('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def get_at_subscription_scope( + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.DeploymentExtended" + """Gets a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_subscription_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def cancel_at_subscription_scope( + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Cancels a currently running template deployment. + + You can cancel a deployment only if the provisioningState is Accepted or Running. After the + deployment is canceled, the provisioningState is set to Canceled. Canceling a template + deployment stops the currently running template deployment and leaves the resources partially + deployed. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + def _validate_at_subscription_scope_initial( + self, + deployment_name, # type: str + parameters, # type: "_models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.DeploymentValidateResult"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._validate_at_subscription_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Deployment') + body_content_kwargs['content'] = body_content + request = self._client.post(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, 202, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _validate_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + def begin_validate_at_subscription_scope( + self, + deployment_name, # type: str + parameters, # type: "_models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.DeploymentValidateResult"] + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to validate. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] + 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._validate_at_subscription_scope_initial( + deployment_name=deployment_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('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + def _what_if_at_subscription_scope_initial( + self, + deployment_name, # type: str + parameters, # type: "_models.DeploymentWhatIf" + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.WhatIfOperationResult"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._what_if_at_subscription_scope_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'DeploymentWhatIf') + body_content_kwargs['content'] = body_content + request = self._client.post(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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _what_if_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + def begin_what_if_at_subscription_scope( + self, + deployment_name, # type: str + parameters, # type: "_models.DeploymentWhatIf" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.WhatIfOperationResult"] + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to What If. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIf + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] + 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._what_if_at_subscription_scope_initial( + deployment_name=deployment_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('WhatIfOperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **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_what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + def export_template_at_subscription_scope( + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.DeploymentExportResult" + """Exports the template used for specified deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_at_subscription_scope( + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.DeploymentListResult"] + """Get all the deployments for a subscription. + + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :param top: The number of results to get. If null is passed, returns all deployments. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_at_subscription_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/'} # type: ignore + + def _delete_initial( + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self._delete_initial.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\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.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 [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Deletes a deployment from the deployment history. + + A template deployment that is currently running cannot be deleted. Deleting a template + deployment removes the associated deployment operations. Deleting a template deployment does + not affect the state of the resource group. This is an asynchronous operation that returns a + status of 202 until the template deployment is successfully deleted. The Location response + header contains the URI that is used to obtain the status of the process. While the process is + running, a call to the URI in the Location header returns a status of 202. When the process + finishes, the URI in the Location header returns a status of 204 on success. If the + asynchronous request failed, the URI in the Location header returns an error-level status code. + + :param resource_group_name: The name of the resource group with the deployment to delete. The + name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def check_existence( + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Checks whether the deployment exists. + + :param resource_group_name: The name of the resource group with the deployment to check. The + name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.check_existence.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\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(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 [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name, # type: str + deployment_name, # type: str + parameters, # type: "_models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> "_models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.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\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Deployment') + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + deployment_name, # type: str + parameters, # type: "_models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.DeploymentExtended"] + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_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('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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.Resources/deployments/{deploymentName}'} # type: ignore + + def get( + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.DeploymentExtended" + """Gets a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def cancel( + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Cancels a currently running template deployment. + + You can cancel a deployment only if the provisioningState is Accepted or Running. After the + deployment is canceled, the provisioningState is set to Canceled. Canceling a template + deployment stops the currently running template deployment and leaves the resource group + partially deployed. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.cancel.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\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + def _validate_initial( + self, + resource_group_name, # type: str + deployment_name, # type: str + parameters, # type: "_models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.DeploymentValidateResult"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._validate_initial.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\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Deployment') + body_content_kwargs['content'] = body_content + request = self._client.post(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, 202, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _validate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + def begin_validate( + self, + resource_group_name, # type: str + deployment_name, # type: str + parameters, # type: "_models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.DeploymentValidateResult"] + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to validate. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] + 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._validate_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_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('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + def _what_if_initial( + self, + resource_group_name, # type: str + deployment_name, # type: str + parameters, # type: "_models.DeploymentWhatIf" + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.WhatIfOperationResult"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._what_if_initial.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\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'DeploymentWhatIf') + body_content_kwargs['content'] = body_content + request = self._client.post(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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _what_if_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + def begin_what_if( + self, + resource_group_name, # type: str + deployment_name, # type: str + parameters, # type: "_models.DeploymentWhatIf" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.WhatIfOperationResult"] + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to validate. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIf + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] + 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._what_if_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_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('WhatIfOperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **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_what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + def export_template( + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.DeploymentExportResult" + """Exports the template used for specified deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.export_template.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\._\(\)]+$'), + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.DeploymentListResult"] + """Get all the deployments for a resource group. + + :param resource_group_name: The name of the resource group with the deployments to get. The + name is case insensitive. + :type resource_group_name: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :param top: The number of results to get. If null is passed, returns all deployments. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeploymentListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.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'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + + def calculate_template_hash( + self, + template, # type: object + **kwargs # type: Any + ): + # type: (...) -> "_models.TemplateHashResult" + """Calculate the hash of the given template. + + :param template: The template provided to calculate hash. + :type template: object + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateHashResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateHashResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.calculate_template_hash.metadata['url'] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(template, 'object') + body_content_kwargs['content'] = body_content + request = self._client.post(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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TemplateHashResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_operations.py new file mode 100644 index 0000000000000..0fac2d4b51acd --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_operations.py @@ -0,0 +1,109 @@ +# 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 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.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class Operations(object): + """Operations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2021_01_01.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 list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.OperationListResult"] + """Lists all of the available Microsoft.Resources 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.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = 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('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_provider_resource_types_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_provider_resource_types_operations.py new file mode 100644 index 0000000000000..a14b8bef6b86e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_provider_resource_types_operations.py @@ -0,0 +1,106 @@ +# 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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ProviderResourceTypesOperations(object): + """ProviderResourceTypesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2021_01_01.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 list( + self, + resource_provider_namespace, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "_models.ProviderResourceTypeListResult" + """List the resource types for a specified resource provider. + + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ProviderResourceTypeListResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ProviderResourceTypeListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderResourceTypeListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ProviderResourceTypeListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_providers_operations.py new file mode 100644 index 0000000000000..e350642d052e2 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_providers_operations.py @@ -0,0 +1,486 @@ +# 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 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.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ProvidersOperations(object): + """ProvidersOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2021_01_01.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 unregister( + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.Provider" + """Unregisters a subscription from a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to unregister. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.unregister.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + def register_at_management_group_scope( + self, + resource_provider_namespace, # type: str + group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Registers a management group with a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to register. + :type resource_provider_namespace: str + :param group_id: The management group ID. + :type group_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.register_at_management_group_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, 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] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + register_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + def register( + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.Provider" + """Registers a subscription with a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to register. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.register.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + def list( + self, + top=None, # type: Optional[int] + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProviderListResult"] + """Gets all resource providers for a subscription. + + :param top: The number of results to return. If null is passed returns all deployments. + :type top: int + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + 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('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + + def list_at_tenant_scope( + self, + top=None, # type: Optional[int] + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ProviderListResult"] + """Gets all resource providers for the tenant. + + :param top: The number of results to return. If null is passed returns all providers. + :type top: int + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_at_tenant_scope.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + 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('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore + + def get( + self, + resource_provider_namespace, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "_models.Provider" + """Gets the specified resource provider. + + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + + def get_at_tenant_scope( + self, + resource_provider_namespace, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "_models.Provider" + """Gets the specified resource provider at the tenant level. + + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_tenant_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/{resourceProviderNamespace}'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_resource_groups_operations.py new file mode 100644 index 0000000000000..69ae66188b219 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_resource_groups_operations.py @@ -0,0 +1,602 @@ +# 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 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.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ResourceGroupsOperations(object): + """ResourceGroupsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2021_01_01.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 check_existence( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Checks whether a resource group exists. + + :param resource_group_name: The name of the resource group to check. 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: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.check_existence.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'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(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 [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + def create_or_update( + self, + resource_group_name, # type: str + parameters, # type: "_models.ResourceGroup" + **kwargs # type: Any + ): + # type: (...) -> "_models.ResourceGroup" + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + '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'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ResourceGroup') + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + def _delete_initial( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self._delete_initial.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'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Deletes a resource group. + + When you delete a resource group, all of its resources are also deleted. Deleting a resource + group deletes all of its template deployments and currently stored operations. + + :param resource_group_name: The name of the resource group to delete. 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_initial( + resource_group_name=resource_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + 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'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + def get( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.ResourceGroup" + """Gets a resource group. + + :param resource_group_name: The name of the resource group to get. 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: ResourceGroup, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + def update( + self, + resource_group_name, # type: str + parameters, # type: "_models.ResourceGroupPatchable" + **kwargs # type: Any + ): + # type: (...) -> "_models.ResourceGroup" + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.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'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + def _export_template_initial( + self, + resource_group_name, # type: str + parameters, # type: "_models.ExportTemplateRequest" + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.ResourceGroupExportResult"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ResourceGroupExportResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._export_template_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + '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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ExportTemplateRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _export_template_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + def begin_export_template( + self, + resource_group_name, # type: str + parameters, # type: "_models.ExportTemplateRequest" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.ResourceGroupExportResult"] + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ExportTemplateRequest + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] + 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._export_template_initial( + resource_group_name=resource_group_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('ResourceGroupExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **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_export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + def list( + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ResourceGroupListResult"] + """Gets all the resource groups for a subscription. + + :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by + tag names and values. For example, to filter for a tag name and value, use $filter=tagName eq + 'tag1' and tagValue eq 'Value1'. + :type filter: str + :param top: The number of results to return. If null is passed, returns all resource groups. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('ResourceGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_resources_operations.py new file mode 100644 index 0000000000000..52bbba01fc84d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_resources_operations.py @@ -0,0 +1,1553 @@ +# 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 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.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ResourcesOperations(object): + """ResourcesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2021_01_01.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 list_by_resource_group( + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + expand=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ResourceListResult"] + """Get all the resources for a resource group. + + :param resource_group_name: The resource group with the resources to get. + :type resource_group_name: str + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When you filter by a tag name and value, + the tags for each resource are not returned in the results.:code:`
`:code:`
`You can use + some properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :param top: The number of results to return. If null is passed, returns all resources. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.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'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore + + def _move_resources_initial( + self, + source_resource_group_name, # type: str + parameters, # type: "_models.ResourcesMoveInfo" + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._move_resources_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') + body_content_kwargs['content'] = body_content + request = self._client.post(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 [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + def begin_move_resources( + self, + source_resource_group_name, # type: str + parameters, # type: "_models.ResourcesMoveInfo" + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourcesMoveInfo + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._move_resources_initial( + source_resource_group_name=source_resource_group_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): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + def _validate_move_resources_initial( + self, + source_resource_group_name, # type: str + parameters, # type: "_models.ResourcesMoveInfo" + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._validate_move_resources_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') + body_content_kwargs['content'] = body_content + request = self._client.post(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 [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + def begin_validate_move_resources( + self, + source_resource_group_name, # type: str + parameters, # type: "_models.ResourcesMoveInfo" + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourcesMoveInfo + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._validate_move_resources_initial( + source_resource_group_name=source_resource_group_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): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + def list( + self, + filter=None, # type: Optional[str] + expand=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ResourceListResult"] + """Get all the resources in a subscription. + + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When you filter by a tag name and value, + the tags for each resource are not returned in the results.:code:`
`:code:`
`You can use + some properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :param top: The number of results to return. If null is passed, returns all resource groups. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + 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('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + + def check_existence( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + api_version, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Checks whether a resource exists. + + :param resource_group_name: The name of the resource group containing the resource to check. + The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. + :type resource_name: str + :param api_version: The API version to use for the operation. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + accept = "application/json" + + # Construct URL + url = self.check_existence.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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(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 [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def _delete_initial( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + api_version, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + accept = "application/json" + + # Construct URL + url = self._delete_initial.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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + api_version, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Deletes a resource. + + :param resource_group_name: The name of the resource group that contains the resource to + delete. The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource to delete. + :type resource_name: str + :param api_version: The API version to use for the operation. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + api_version, # type: str + parameters, # type: "_models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.GenericResource"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'GenericResource') + 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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + api_version, # type: str + parameters, # type: "_models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.GenericResource"] + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. + :type resource_type: str + :param resource_name: The name of the resource to create. + :type resource_name: str + :param api_version: The API version to use for the operation. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] + 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( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + 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('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def _update_initial( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + api_version, # type: str + parameters, # type: "_models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.GenericResource"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'GenericResource') + 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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_update( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + api_version, # type: str + parameters, # type: "_models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.GenericResource"] + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. + :type resource_type: str + :param resource_name: The name of the resource to update. + :type resource_name: str + :param api_version: The API version to use for the operation. + :type api_version: str + :param parameters: Parameters for updating the resource. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] + 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._update_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + 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('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def get( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + api_version, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.GenericResource" + """Gets a resource. + + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource. + :type resource_type: str + :param resource_name: The name of the resource to get. + :type resource_name: str + :param api_version: The API version to use for the operation. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def check_existence_by_id( + self, + resource_id, # type: str + api_version, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Checks by ID whether a resource exists. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param api_version: The API version to use for the operation. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + accept = "application/json" + + # Construct URL + url = self.check_existence_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(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 [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + def _delete_by_id_initial( + self, + resource_id, # type: str + api_version, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + accept = "application/json" + + # Construct URL + url = self._delete_by_id_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + def begin_delete_by_id( + self, + resource_id, # type: str + api_version, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Deletes a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param api_version: The API version to use for the operation. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._delete_by_id_initial( + resource_id=resource_id, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + def _create_or_update_by_id_initial( + self, + resource_id, # type: str + api_version, # type: str + parameters, # type: "_models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.GenericResource"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'GenericResource') + 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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + def begin_create_or_update_by_id( + self, + resource_id, # type: str + api_version, # type: str + parameters, # type: "_models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.GenericResource"] + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param api_version: The API version to use for the operation. + :type api_version: str + :param parameters: Create or update resource parameters. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] + 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_by_id_initial( + resource_id=resource_id, + api_version=api_version, + 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('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + def _update_by_id_initial( + self, + resource_id, # type: str + api_version, # type: str + parameters, # type: "_models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.GenericResource"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_by_id_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'GenericResource') + 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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + def begin_update_by_id( + self, + resource_id, # type: str + api_version, # type: str + parameters, # type: "_models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.GenericResource"] + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param api_version: The API version to use for the operation. + :type api_version: str + :param parameters: Update resource parameters. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] + 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._update_by_id_initial( + resource_id=resource_id, + api_version=api_version, + 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('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + def get_by_id( + self, + resource_id, # type: str + api_version, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.GenericResource" + """Gets a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param api_version: The API version to use for the operation. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + accept = "application/json" + + # Construct URL + url = self.get_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_tags_operations.py new file mode 100644 index 0000000000000..99f9f87384d15 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_tags_operations.py @@ -0,0 +1,607 @@ +# 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 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.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class TagsOperations(object): + """TagsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2021_01_01.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 delete_value( + self, + tag_name, # type: str + tag_value, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes a predefined tag value for a predefined tag name. + + This operation allows deleting a value from the list of predefined values for an existing + predefined tag name. The value being deleted must not be in use as a tag value for the given + tag name for any resource. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag to delete. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.delete_value.metadata['url'] # type: ignore + path_format_arguments = { + 'tagName': self._serialize.url("tag_name", tag_name, 'str'), + 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + def create_or_update_value( + self, + tag_name, # type: str + tag_value, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.TagValue" + """Creates a predefined value for a predefined tag name. + + This operation allows adding a value to the list of predefined values for an existing + predefined tag name. A tag value can have a maximum of 256 characters. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag to create. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagValue, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.create_or_update_value.metadata['url'] # type: ignore + path_format_arguments = { + 'tagName': self._serialize.url("tag_name", tag_name, 'str'), + 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.put(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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('TagValue', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + def create_or_update( + self, + tag_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.TagDetails" + """Creates a predefined tag name. + + This operation allows adding a name to the list of predefined tag names for the given + subscription. A tag name can have a maximum of 512 characters and is case-insensitive. Tag + names cannot have the following prefixes which are reserved for Azure use: 'microsoft', + 'azure', 'windows'. + + :param tag_name: The name of the tag to create. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDetails, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'tagName': self._serialize.url("tag_name", tag_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.put(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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + def delete( + self, + tag_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes a predefined tag name. + + This operation allows deleting a name from the list of predefined tag names for the given + subscription. The name being deleted must not be in use as a tag name for any resource. All + predefined values for the given name must have already been deleted. + + :param tag_name: The name of the tag. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'tagName': self._serialize.url("tag_name", tag_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.TagsListResult"] + """Gets a summary of tag usage under the subscription. + + This operation performs a union of predefined tags, resource tags, resource group tags and + subscription tags, and returns a summary of usage for each tag name and value under the given + subscription. In case of a large number of tags, this operation may return a previously cached + result. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TagsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.TagsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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('TagsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore + + def create_or_update_at_scope( + self, + scope, # type: str + parameters, # type: "_models.TagsResource" + **kwargs # type: Any + ): + # type: (...) -> "_models.TagsResource" + """Creates or updates the entire set of tags on a resource or subscription. + + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. + + :param scope: The resource scope. + :type scope: str + :param parameters: + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update_at_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'TagsResource') + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TagsResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + def update_at_scope( + self, + scope, # type: str + parameters, # type: "_models.TagsPatchResource" + **kwargs # type: Any + ): + # type: (...) -> "_models.TagsResource" + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The resource scope. + :type scope: str + :param parameters: + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsPatchResource + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update_at_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'TagsPatchResource') + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TagsResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + def get_at_scope( + self, + scope, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.TagsResource" + """Gets the entire set of tags on a resource or subscription. + + Gets the entire set of tags on a resource or subscription. + + :param scope: The resource scope. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource, or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TagsResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + def delete_at_scope( + self, + scope, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes the entire set of tags on a resource or subscription. + + Deletes the entire set of tags on a resource or subscription. + + :param scope: The resource scope. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.delete_at_scope.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/py.typed new file mode 100644 index 0000000000000..e5aff4f83af86 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_template_specs_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_template_specs_client.py index 498dbef172302..02f22f9f38e8a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_template_specs_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_template_specs_client.py @@ -55,7 +55,7 @@ class TemplateSpecsClient(MultiApiClientMixin, _SDKClient): :type profile: azure.profiles.KnownProfiles """ - DEFAULT_API_VERSION = '2019-06-01-preview' + DEFAULT_API_VERSION = '2021-03-01-preview' _PROFILE_TAG = "azure.mgmt.resource.templatespecs.TemplateSpecsClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -91,10 +91,14 @@ def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2019-06-01-preview: :mod:`v2019_06_01_preview.models` + * 2021-03-01-preview: :mod:`v2021_03_01_preview.models` """ if api_version == '2019-06-01-preview': from .v2019_06_01_preview import models return models + elif api_version == '2021-03-01-preview': + from .v2021_03_01_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -102,10 +106,13 @@ def template_spec_versions(self): """Instance depends on the API version: * 2019-06-01-preview: :class:`TemplateSpecVersionsOperations` + * 2021-03-01-preview: :class:`TemplateSpecVersionsOperations` """ api_version = self._get_api_version('template_spec_versions') if api_version == '2019-06-01-preview': from .v2019_06_01_preview.operations import TemplateSpecVersionsOperations as OperationClass + elif api_version == '2021-03-01-preview': + from .v2021_03_01_preview.operations import TemplateSpecVersionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'template_spec_versions'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -115,10 +122,13 @@ def template_specs(self): """Instance depends on the API version: * 2019-06-01-preview: :class:`TemplateSpecsOperations` + * 2021-03-01-preview: :class:`TemplateSpecsOperations` """ api_version = self._get_api_version('template_specs') if api_version == '2019-06-01-preview': from .v2019_06_01_preview.operations import TemplateSpecsOperations as OperationClass + elif api_version == '2021-03-01-preview': + from .v2021_03_01_preview.operations import TemplateSpecsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'template_specs'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/aio/_template_specs_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/aio/_template_specs_client.py index d16367cdb768b..dc02ef459f3de 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/aio/_template_specs_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/aio/_template_specs_client.py @@ -53,7 +53,7 @@ class TemplateSpecsClient(MultiApiClientMixin, _SDKClient): :type profile: azure.profiles.KnownProfiles """ - DEFAULT_API_VERSION = '2019-06-01-preview' + DEFAULT_API_VERSION = '2021-03-01-preview' _PROFILE_TAG = "azure.mgmt.resource.templatespecs.TemplateSpecsClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -89,10 +89,14 @@ def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2019-06-01-preview: :mod:`v2019_06_01_preview.models` + * 2021-03-01-preview: :mod:`v2021_03_01_preview.models` """ if api_version == '2019-06-01-preview': from ..v2019_06_01_preview import models return models + elif api_version == '2021-03-01-preview': + from ..v2021_03_01_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -100,10 +104,13 @@ def template_spec_versions(self): """Instance depends on the API version: * 2019-06-01-preview: :class:`TemplateSpecVersionsOperations` + * 2021-03-01-preview: :class:`TemplateSpecVersionsOperations` """ api_version = self._get_api_version('template_spec_versions') if api_version == '2019-06-01-preview': from ..v2019_06_01_preview.aio.operations import TemplateSpecVersionsOperations as OperationClass + elif api_version == '2021-03-01-preview': + from ..v2021_03_01_preview.aio.operations import TemplateSpecVersionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'template_spec_versions'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -113,10 +120,13 @@ def template_specs(self): """Instance depends on the API version: * 2019-06-01-preview: :class:`TemplateSpecsOperations` + * 2021-03-01-preview: :class:`TemplateSpecsOperations` """ api_version = self._get_api_version('template_specs') if api_version == '2019-06-01-preview': from ..v2019_06_01_preview.aio.operations import TemplateSpecsOperations as OperationClass + elif api_version == '2021-03-01-preview': + from ..v2021_03_01_preview.aio.operations import TemplateSpecsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'template_specs'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/models.py index 3f8a8bc41c1e5..8c0bdbea5456b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/models.py @@ -4,4 +4,4 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from .v2019_06_01_preview.models import * +from .v2021_03_01_preview.models import * diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_version.py index 7985a146bc0e5..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/__init__.py new file mode 100644 index 0000000000000..7c99491ce2da3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/__init__.py @@ -0,0 +1,19 @@ +# 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 ._template_specs_client import TemplateSpecsClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ['TemplateSpecsClient'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_configuration.py new file mode 100644 index 0000000000000..c6dd436112f24 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_configuration.py @@ -0,0 +1,71 @@ +# 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 + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import 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 TemplateSpecsClientConfiguration(Configuration): + """Configuration for TemplateSpecsClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Subscription Id which forms part of the URI for every service call. + :type subscription_id: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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(TemplateSpecsClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2021-03-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_metadata.json new file mode 100644 index 0000000000000..0bfe327effa39 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_metadata.json @@ -0,0 +1,104 @@ +{ + "chosen_version": "2021-03-01-preview", + "total_api_version_list": ["2021-03-01-preview"], + "client": { + "name": "TemplateSpecsClient", + "filename": "_template_specs_client", + "description": "The APIs listed in this specification can be used to manage Template Spec resources through the Azure Resource Manager.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": null, + "azure_arm": true, + "has_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "Subscription Id which forms part of the URI for every service call.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Subscription Id which forms part of the URI for every service call.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_default_policy_type": "BearerTokenCredentialPolicy", + "credential_default_policy_type_has_async_version": true, + "credential_key_header_name": null, + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "template_specs": "TemplateSpecsOperations", + "template_spec_versions": "TemplateSpecVersionsOperations" + } +} \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_template_specs_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_template_specs_client.py new file mode 100644 index 0000000000000..85e02c654387d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_template_specs_client.py @@ -0,0 +1,93 @@ +# 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 + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + from azure.core.pipeline.transport import HttpRequest, HttpResponse + +from ._configuration import TemplateSpecsClientConfiguration +from .operations import TemplateSpecsOperations +from .operations import TemplateSpecVersionsOperations +from . import models + + +class TemplateSpecsClient(object): + """The APIs listed in this specification can be used to manage Template Spec resources through the Azure Resource Manager. + + :ivar template_specs: TemplateSpecsOperations operations + :vartype template_specs: azure.mgmt.resource.templatespecs.v2021_03_01_preview.operations.TemplateSpecsOperations + :ivar template_spec_versions: TemplateSpecVersionsOperations operations + :vartype template_spec_versions: azure.mgmt.resource.templatespecs.v2021_03_01_preview.operations.TemplateSpecVersionsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Subscription Id which forms part of the URI for every service call. + :type subscription_id: str + :param str base_url: Service URL + """ + + 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 = TemplateSpecsClientConfiguration(credential, subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.template_specs = TemplateSpecsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.template_spec_versions = TemplateSpecVersionsOperations( + self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, http_request, **kwargs): + # type: (HttpRequest, Any) -> HttpResponse + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.HttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> TemplateSpecsClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_version.py new file mode 100644 index 0000000000000..e5754a47ce68f --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_version.py @@ -0,0 +1,9 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/__init__.py new file mode 100644 index 0000000000000..6520699c87dfb --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/__init__.py @@ -0,0 +1,10 @@ +# 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 ._template_specs_client import TemplateSpecsClient +__all__ = ['TemplateSpecsClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_configuration.py new file mode 100644 index 0000000000000..0df87dbe71f01 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_configuration.py @@ -0,0 +1,67 @@ +# 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, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class TemplateSpecsClientConfiguration(Configuration): + """Configuration for TemplateSpecsClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Subscription Id which forms part of the URI for every service call. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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(TemplateSpecsClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2021-03-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_template_specs_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_template_specs_client.py new file mode 100644 index 0000000000000..8f20ef06b85ef --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_template_specs_client.py @@ -0,0 +1,86 @@ +# 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.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration import TemplateSpecsClientConfiguration +from .operations import TemplateSpecsOperations +from .operations import TemplateSpecVersionsOperations +from .. import models + + +class TemplateSpecsClient(object): + """The APIs listed in this specification can be used to manage Template Spec resources through the Azure Resource Manager. + + :ivar template_specs: TemplateSpecsOperations operations + :vartype template_specs: azure.mgmt.resource.templatespecs.v2021_03_01_preview.aio.operations.TemplateSpecsOperations + :ivar template_spec_versions: TemplateSpecVersionsOperations operations + :vartype template_spec_versions: azure.mgmt.resource.templatespecs.v2021_03_01_preview.aio.operations.TemplateSpecVersionsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Subscription Id which forms part of the URI for every service call. + :type subscription_id: str + :param str base_url: Service URL + """ + + 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 = TemplateSpecsClientConfiguration(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._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.template_specs = TemplateSpecsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.template_spec_versions = TemplateSpecVersionsOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "TemplateSpecsClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/__init__.py new file mode 100644 index 0000000000000..6b00f8eb43d58 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/__init__.py @@ -0,0 +1,15 @@ +# 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 ._template_specs_operations import TemplateSpecsOperations +from ._template_spec_versions_operations import TemplateSpecVersionsOperations + +__all__ = [ + 'TemplateSpecsOperations', + 'TemplateSpecVersionsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/_template_spec_versions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/_template_spec_versions_operations.py new file mode 100644 index 0000000000000..553bdb16611af --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/_template_spec_versions_operations.py @@ -0,0 +1,391 @@ +# 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 ClientAuthenticationError, 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 as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TemplateSpecVersionsOperations: + """TemplateSpecVersionsOperations 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: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.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, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_model: "_models.TemplateSpecVersion", + **kwargs + ) -> "_models.TemplateSpecVersion": + """Creates or updates a Template Spec version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. + :type template_spec_version: str + :param template_spec_version_model: Template Spec Version supplied to the operation. + :type template_spec_version_model: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion, or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, '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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(template_spec_version_model, 'TemplateSpecVersion') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + async def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_update_model: Optional["_models.TemplateSpecVersionUpdateModel"] = None, + **kwargs + ) -> "_models.TemplateSpecVersion": + """Updates Template Spec Version tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. + :type template_spec_version: str + :param template_spec_version_update_model: Template Spec Version resource with the tags to be + updated. + :type template_spec_version_update_model: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersionUpdateModel + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion, or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, '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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if template_spec_version_update_model is not None: + body_content = self._serialize.body(template_spec_version_update_model, 'TemplateSpecVersionUpdateModel') + else: + body_content = None + 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.failsafe_deserialize(_models.TemplateSpecsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + async def get( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + **kwargs + ) -> "_models.TemplateSpecVersion": + """Gets a Template Spec version from a specific Template Spec. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. + :type template_spec_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion, or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, '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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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.TemplateSpecsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + **kwargs + ) -> None: + """Deletes a specific version from a Template Spec. When operation completes, status code 200 + returned without content. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. + :type template_spec_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, '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'] = self._serialize.header("accept", accept, 'str') + + 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.failsafe_deserialize(_models.TemplateSpecsError, 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.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + def list( + self, + resource_group_name: str, + template_spec_name: str, + **kwargs + ) -> AsyncIterable["_models.TemplateSpecVersionsListResult"]: + """Lists all the Template Spec versions in the specified Template Spec. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. + :type template_spec_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersionsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersionsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecName': self._serialize.url("template_spec_name", template_spec_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('TemplateSpecVersionsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or 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.failsafe_deserialize(_models.TemplateSpecsError, 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.Resources/templateSpecs/{templateSpecName}/versions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/_template_specs_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/_template_specs_operations.py new file mode 100644 index 0000000000000..f4dd1a561179b --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/_template_specs_operations.py @@ -0,0 +1,455 @@ +# 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 ClientAuthenticationError, 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 as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TemplateSpecsOperations: + """TemplateSpecsOperations 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: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.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, + resource_group_name: str, + template_spec_name: str, + template_spec: "_models.TemplateSpec", + **kwargs + ) -> "_models.TemplateSpec": + """Creates or updates a Template Spec. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. + :type template_spec_name: str + :param template_spec: Template Spec supplied to the operation. + :type template_spec: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec, or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecName': self._serialize.url("template_spec_name", template_spec_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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(template_spec, 'TemplateSpec') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('TemplateSpec', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TemplateSpec', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: Optional["_models.TemplateSpecUpdateModel"] = None, + **kwargs + ) -> "_models.TemplateSpec": + """Updates Template Spec tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. + :type template_spec_name: str + :param template_spec: Template Spec resource with the tags to be updated. + :type template_spec: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecUpdateModel + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec, or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecName': self._serialize.url("template_spec_name", template_spec_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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if template_spec is not None: + body_content = self._serialize.body(template_spec, 'TemplateSpecUpdateModel') + else: + body_content = None + 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.failsafe_deserialize(_models.TemplateSpecsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TemplateSpec', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + template_spec_name: str, + expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, + **kwargs + ) -> "_models.TemplateSpec": + """Gets a Template Spec with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. + :type template_spec_name: str + :param expand: Allows for expansion of additional Template Spec details in the response. + Optional. + :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec, or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecName': self._serialize.url("template_spec_name", template_spec_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] + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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.TemplateSpecsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TemplateSpec', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + template_spec_name: str, + **kwargs + ) -> None: + """Deletes a Template Spec by name. When operation completes, status code 200 returned without + content. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. + :type template_spec_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecName': self._serialize.url("template_spec_name", template_spec_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'] = self._serialize.header("accept", accept, 'str') + + 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.failsafe_deserialize(_models.TemplateSpecsError, 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.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + def list_by_subscription( + self, + expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, + **kwargs + ) -> AsyncIterable["_models.TemplateSpecsListResult"]: + """Lists all the Template Specs within the specified subscriptions. + + :param expand: Allows for expansion of additional Template Spec details in the response. + Optional. + :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TemplateSpecsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + 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('TemplateSpecsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or 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.failsafe_deserialize(_models.TemplateSpecsError, 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.Resources/templateSpecs/'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, + **kwargs + ) -> AsyncIterable["_models.TemplateSpecsListResult"]: + """Lists all the Template Specs within the specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param expand: Allows for expansion of additional Template Spec details in the response. + Optional. + :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TemplateSpecsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + '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] + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + 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('TemplateSpecsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or 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.failsafe_deserialize(_models.TemplateSpecsError, 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.Resources/templateSpecs/'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/__init__.py new file mode 100644 index 0000000000000..d3b7be376d1c6 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/__init__.py @@ -0,0 +1,59 @@ +# 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. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import AzureResourceBase + from ._models_py3 import ErrorAdditionalInfo + from ._models_py3 import ErrorResponse + from ._models_py3 import LinkedTemplateArtifact + from ._models_py3 import SystemData + from ._models_py3 import TemplateSpec + from ._models_py3 import TemplateSpecUpdateModel + from ._models_py3 import TemplateSpecVersion + from ._models_py3 import TemplateSpecVersionInfo + from ._models_py3 import TemplateSpecVersionUpdateModel + from ._models_py3 import TemplateSpecVersionsListResult + from ._models_py3 import TemplateSpecsError + from ._models_py3 import TemplateSpecsListResult +except (SyntaxError, ImportError): + from ._models import AzureResourceBase # type: ignore + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import LinkedTemplateArtifact # type: ignore + from ._models import SystemData # type: ignore + from ._models import TemplateSpec # type: ignore + from ._models import TemplateSpecUpdateModel # type: ignore + from ._models import TemplateSpecVersion # type: ignore + from ._models import TemplateSpecVersionInfo # type: ignore + from ._models import TemplateSpecVersionUpdateModel # type: ignore + from ._models import TemplateSpecVersionsListResult # type: ignore + from ._models import TemplateSpecsError # type: ignore + from ._models import TemplateSpecsListResult # type: ignore + +from ._template_specs_client_enums import ( + CreatedByType, + TemplateSpecExpandKind, +) + +__all__ = [ + 'AzureResourceBase', + 'ErrorAdditionalInfo', + 'ErrorResponse', + 'LinkedTemplateArtifact', + 'SystemData', + 'TemplateSpec', + 'TemplateSpecUpdateModel', + 'TemplateSpecVersion', + 'TemplateSpecVersionInfo', + 'TemplateSpecVersionUpdateModel', + 'TemplateSpecVersionsListResult', + 'TemplateSpecsError', + 'TemplateSpecsListResult', + 'CreatedByType', + 'TemplateSpecExpandKind', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_models.py new file mode 100644 index 0000000000000..0b13ac77043e4 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_models.py @@ -0,0 +1,540 @@ +# 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 AzureResourceBase(msrest.serialization.Model): + """Common properties for all Azure resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar name: Name of this resource. + :vartype name: str + :ivar type: Type of this resource. + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.SystemData + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + } + + def __init__( + self, + **kwargs + ): + super(AzureResourceBase, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = 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): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: + list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.ErrorResponse] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.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(ErrorResponse, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class LinkedTemplateArtifact(msrest.serialization.Model): + """Represents a Template Spec artifact containing an embedded Azure Resource Manager template for use as a linked template. + + All required parameters must be populated in order to send to Azure. + + :param path: Required. A filesystem safe relative path of the artifact. + :type path: str + :param template: Required. The Azure Resource Manager template. + :type template: object + """ + + _validation = { + 'path': {'required': True}, + 'template': {'required': True}, + } + + _attribute_map = { + 'path': {'key': 'path', 'type': 'str'}, + 'template': {'key': 'template', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + super(LinkedTemplateArtifact, self).__init__(**kwargs) + self.path = kwargs['path'] + self.template = kwargs['template'] + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :type created_by_type: str or + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: ~datetime.datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :type last_modified_by_type: str or + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.CreatedByType + :param last_modified_at: The timestamp of resource last modification (UTC). + :type last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + super(SystemData, self).__init__(**kwargs) + self.created_by = kwargs.get('created_by', None) + self.created_by_type = kwargs.get('created_by_type', None) + self.created_at = kwargs.get('created_at', None) + self.last_modified_by = kwargs.get('last_modified_by', None) + self.last_modified_by_type = kwargs.get('last_modified_by_type', None) + self.last_modified_at = kwargs.get('last_modified_at', None) + + +class TemplateSpec(AzureResourceBase): + """Template Spec object. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar name: Name of this resource. + :vartype name: str + :ivar type: Type of this resource. + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.SystemData + :param location: Required. The location of the Template Spec. It cannot be changed after + Template Spec creation. It must be one of the supported Azure locations. + :type location: str + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param description: Template Spec description. + :type description: str + :param display_name: Template Spec display name. + :type display_name: str + :param metadata: The Template Spec metadata. Metadata is an open-ended object and is typically + a collection of key-value pairs. + :type metadata: object + :ivar versions: High-level information about the versions within this Template Spec. The keys + are the version names. Only populated if the $expand query parameter is set to 'versions'. + :vartype versions: dict[str, + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersionInfo] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'location': {'required': True}, + 'description': {'max_length': 4096, 'min_length': 0}, + 'display_name': {'max_length': 64, 'min_length': 0}, + 'versions': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'metadata': {'key': 'properties.metadata', 'type': 'object'}, + 'versions': {'key': 'properties.versions', 'type': '{TemplateSpecVersionInfo}'}, + } + + def __init__( + self, + **kwargs + ): + super(TemplateSpec, self).__init__(**kwargs) + self.location = kwargs['location'] + self.tags = kwargs.get('tags', None) + self.description = kwargs.get('description', None) + self.display_name = kwargs.get('display_name', None) + self.metadata = kwargs.get('metadata', None) + self.versions = None + + +class TemplateSpecsError(msrest.serialization.Model): + """Template Specs error response. + + :param error: Common error response for all Azure Resource Manager APIs to return error details + for failed operations. (This also follows the OData error response format.). + :type error: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.ErrorResponse + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponse'}, + } + + def __init__( + self, + **kwargs + ): + super(TemplateSpecsError, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class TemplateSpecsListResult(msrest.serialization.Model): + """List of Template Specs. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: An array of Template Specs. + :type value: list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TemplateSpec]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TemplateSpecsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class TemplateSpecUpdateModel(AzureResourceBase): + """Template Spec properties to be updated (only tags are currently supported). + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar name: Name of this resource. + :vartype name: str + :ivar type: Type of this resource. + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.SystemData + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(TemplateSpecUpdateModel, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) + + +class TemplateSpecVersion(AzureResourceBase): + """Template Spec Version object. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar name: Name of this resource. + :vartype name: str + :ivar type: Type of this resource. + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.SystemData + :param location: Required. The location of the Template Spec Version. It must match the + location of the parent Template Spec. + :type location: str + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param description: Template Spec version description. + :type description: str + :param linked_templates: An array of linked template artifacts. + :type linked_templates: + list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.LinkedTemplateArtifact] + :param metadata: The version metadata. Metadata is an open-ended object and is typically a + collection of key-value pairs. + :type metadata: object + :param main_template: The main Azure Resource Manager template content. + :type main_template: object + :param ui_form_definition: The Azure Resource Manager template UI definition content. + :type ui_form_definition: object + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'location': {'required': True}, + 'description': {'max_length': 4096, 'min_length': 0}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'linked_templates': {'key': 'properties.linkedTemplates', 'type': '[LinkedTemplateArtifact]'}, + 'metadata': {'key': 'properties.metadata', 'type': 'object'}, + 'main_template': {'key': 'properties.mainTemplate', 'type': 'object'}, + 'ui_form_definition': {'key': 'properties.uiFormDefinition', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + super(TemplateSpecVersion, self).__init__(**kwargs) + self.location = kwargs['location'] + self.tags = kwargs.get('tags', None) + self.description = kwargs.get('description', None) + self.linked_templates = kwargs.get('linked_templates', None) + self.metadata = kwargs.get('metadata', None) + self.main_template = kwargs.get('main_template', None) + self.ui_form_definition = kwargs.get('ui_form_definition', None) + + +class TemplateSpecVersionInfo(msrest.serialization.Model): + """High-level information about a Template Spec version. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar description: Template Spec version description. + :vartype description: str + :ivar time_created: The timestamp of when the version was created. + :vartype time_created: ~datetime.datetime + :ivar time_modified: The timestamp of when the version was last modified. + :vartype time_modified: ~datetime.datetime + """ + + _validation = { + 'description': {'readonly': True}, + 'time_created': {'readonly': True}, + 'time_modified': {'readonly': True}, + } + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'time_created': {'key': 'timeCreated', 'type': 'iso-8601'}, + 'time_modified': {'key': 'timeModified', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + super(TemplateSpecVersionInfo, self).__init__(**kwargs) + self.description = None + self.time_created = None + self.time_modified = None + + +class TemplateSpecVersionsListResult(msrest.serialization.Model): + """List of Template Specs versions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: An array of Template Spec versions. + :type value: + list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TemplateSpecVersion]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TemplateSpecVersionsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class TemplateSpecVersionUpdateModel(AzureResourceBase): + """Template Spec Version properties to be updated (only tags are currently supported). + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar name: Name of this resource. + :vartype name: str + :ivar type: Type of this resource. + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.SystemData + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(TemplateSpecVersionUpdateModel, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_models_py3.py new file mode 100644 index 0000000000000..048f4c1d01d77 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_models_py3.py @@ -0,0 +1,579 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +from typing import Dict, List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._template_specs_client_enums import * + + +class AzureResourceBase(msrest.serialization.Model): + """Common properties for all Azure resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar name: Name of this resource. + :vartype name: str + :ivar type: Type of this resource. + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.SystemData + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + } + + def __init__( + self, + **kwargs + ): + super(AzureResourceBase, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = 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): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: + list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.ErrorResponse] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.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(ErrorResponse, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class LinkedTemplateArtifact(msrest.serialization.Model): + """Represents a Template Spec artifact containing an embedded Azure Resource Manager template for use as a linked template. + + All required parameters must be populated in order to send to Azure. + + :param path: Required. A filesystem safe relative path of the artifact. + :type path: str + :param template: Required. The Azure Resource Manager template. + :type template: object + """ + + _validation = { + 'path': {'required': True}, + 'template': {'required': True}, + } + + _attribute_map = { + 'path': {'key': 'path', 'type': 'str'}, + 'template': {'key': 'template', 'type': 'object'}, + } + + def __init__( + self, + *, + path: str, + template: object, + **kwargs + ): + super(LinkedTemplateArtifact, self).__init__(**kwargs) + self.path = path + self.template = template + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :type created_by_type: str or + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: ~datetime.datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :type last_modified_by_type: str or + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.CreatedByType + :param last_modified_at: The timestamp of resource last modification (UTC). + :type last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class TemplateSpec(AzureResourceBase): + """Template Spec object. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar name: Name of this resource. + :vartype name: str + :ivar type: Type of this resource. + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.SystemData + :param location: Required. The location of the Template Spec. It cannot be changed after + Template Spec creation. It must be one of the supported Azure locations. + :type location: str + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param description: Template Spec description. + :type description: str + :param display_name: Template Spec display name. + :type display_name: str + :param metadata: The Template Spec metadata. Metadata is an open-ended object and is typically + a collection of key-value pairs. + :type metadata: object + :ivar versions: High-level information about the versions within this Template Spec. The keys + are the version names. Only populated if the $expand query parameter is set to 'versions'. + :vartype versions: dict[str, + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersionInfo] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'location': {'required': True}, + 'description': {'max_length': 4096, 'min_length': 0}, + 'display_name': {'max_length': 64, 'min_length': 0}, + 'versions': {'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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'metadata': {'key': 'properties.metadata', 'type': 'object'}, + 'versions': {'key': 'properties.versions', 'type': '{TemplateSpecVersionInfo}'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + description: Optional[str] = None, + display_name: Optional[str] = None, + metadata: Optional[object] = None, + **kwargs + ): + super(TemplateSpec, self).__init__(**kwargs) + self.location = location + self.tags = tags + self.description = description + self.display_name = display_name + self.metadata = metadata + self.versions = None + + +class TemplateSpecsError(msrest.serialization.Model): + """Template Specs error response. + + :param error: Common error response for all Azure Resource Manager APIs to return error details + for failed operations. (This also follows the OData error response format.). + :type error: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.ErrorResponse + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponse'}, + } + + def __init__( + self, + *, + error: Optional["ErrorResponse"] = None, + **kwargs + ): + super(TemplateSpecsError, self).__init__(**kwargs) + self.error = error + + +class TemplateSpecsListResult(msrest.serialization.Model): + """List of Template Specs. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: An array of Template Specs. + :type value: list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TemplateSpec]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["TemplateSpec"]] = None, + **kwargs + ): + super(TemplateSpecsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class TemplateSpecUpdateModel(AzureResourceBase): + """Template Spec properties to be updated (only tags are currently supported). + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar name: Name of this resource. + :vartype name: str + :ivar type: Type of this resource. + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.SystemData + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(TemplateSpecUpdateModel, self).__init__(**kwargs) + self.tags = tags + + +class TemplateSpecVersion(AzureResourceBase): + """Template Spec Version object. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar name: Name of this resource. + :vartype name: str + :ivar type: Type of this resource. + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.SystemData + :param location: Required. The location of the Template Spec Version. It must match the + location of the parent Template Spec. + :type location: str + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param description: Template Spec version description. + :type description: str + :param linked_templates: An array of linked template artifacts. + :type linked_templates: + list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.LinkedTemplateArtifact] + :param metadata: The version metadata. Metadata is an open-ended object and is typically a + collection of key-value pairs. + :type metadata: object + :param main_template: The main Azure Resource Manager template content. + :type main_template: object + :param ui_form_definition: The Azure Resource Manager template UI definition content. + :type ui_form_definition: object + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'location': {'required': True}, + 'description': {'max_length': 4096, 'min_length': 0}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'linked_templates': {'key': 'properties.linkedTemplates', 'type': '[LinkedTemplateArtifact]'}, + 'metadata': {'key': 'properties.metadata', 'type': 'object'}, + 'main_template': {'key': 'properties.mainTemplate', 'type': 'object'}, + 'ui_form_definition': {'key': 'properties.uiFormDefinition', 'type': 'object'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + description: Optional[str] = None, + linked_templates: Optional[List["LinkedTemplateArtifact"]] = None, + metadata: Optional[object] = None, + main_template: Optional[object] = None, + ui_form_definition: Optional[object] = None, + **kwargs + ): + super(TemplateSpecVersion, self).__init__(**kwargs) + self.location = location + self.tags = tags + self.description = description + self.linked_templates = linked_templates + self.metadata = metadata + self.main_template = main_template + self.ui_form_definition = ui_form_definition + + +class TemplateSpecVersionInfo(msrest.serialization.Model): + """High-level information about a Template Spec version. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar description: Template Spec version description. + :vartype description: str + :ivar time_created: The timestamp of when the version was created. + :vartype time_created: ~datetime.datetime + :ivar time_modified: The timestamp of when the version was last modified. + :vartype time_modified: ~datetime.datetime + """ + + _validation = { + 'description': {'readonly': True}, + 'time_created': {'readonly': True}, + 'time_modified': {'readonly': True}, + } + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'time_created': {'key': 'timeCreated', 'type': 'iso-8601'}, + 'time_modified': {'key': 'timeModified', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + super(TemplateSpecVersionInfo, self).__init__(**kwargs) + self.description = None + self.time_created = None + self.time_modified = None + + +class TemplateSpecVersionsListResult(msrest.serialization.Model): + """List of Template Specs versions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: An array of Template Spec versions. + :type value: + list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TemplateSpecVersion]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["TemplateSpecVersion"]] = None, + **kwargs + ): + super(TemplateSpecVersionsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class TemplateSpecVersionUpdateModel(AzureResourceBase): + """Template Spec Version properties to be updated (only tags are currently supported). + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar name: Name of this resource. + :vartype name: str + :ivar type: Type of this resource. + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.SystemData + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(TemplateSpecVersionUpdateModel, self).__init__(**kwargs) + self.tags = tags diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_template_specs_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_template_specs_client_enums.py new file mode 100644 index 0000000000000..bb7f08d82324d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_template_specs_client_enums.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class TemplateSpecExpandKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + #: Includes version information with the Template Spec. + VERSIONS = "versions" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/__init__.py new file mode 100644 index 0000000000000..6b00f8eb43d58 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/__init__.py @@ -0,0 +1,15 @@ +# 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 ._template_specs_operations import TemplateSpecsOperations +from ._template_spec_versions_operations import TemplateSpecVersionsOperations + +__all__ = [ + 'TemplateSpecsOperations', + 'TemplateSpecVersionsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/_template_spec_versions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/_template_spec_versions_operations.py new file mode 100644 index 0000000000000..6c7342aef707d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/_template_spec_versions_operations.py @@ -0,0 +1,400 @@ +# 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 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.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class TemplateSpecVersionsOperations(object): + """TemplateSpecVersionsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.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, + resource_group_name, # type: str + template_spec_name, # type: str + template_spec_version, # type: str + template_spec_version_model, # type: "_models.TemplateSpecVersion" + **kwargs # type: Any + ): + # type: (...) -> "_models.TemplateSpecVersion" + """Creates or updates a Template Spec version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. + :type template_spec_version: str + :param template_spec_version_model: Template Spec Version supplied to the operation. + :type template_spec_version_model: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion, or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, '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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(template_spec_version_model, 'TemplateSpecVersion') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + def update( + self, + resource_group_name, # type: str + template_spec_name, # type: str + template_spec_version, # type: str + template_spec_version_update_model=None, # type: Optional["_models.TemplateSpecVersionUpdateModel"] + **kwargs # type: Any + ): + # type: (...) -> "_models.TemplateSpecVersion" + """Updates Template Spec Version tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. + :type template_spec_version: str + :param template_spec_version_update_model: Template Spec Version resource with the tags to be + updated. + :type template_spec_version_update_model: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersionUpdateModel + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion, or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, '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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if template_spec_version_update_model is not None: + body_content = self._serialize.body(template_spec_version_update_model, 'TemplateSpecVersionUpdateModel') + else: + body_content = None + 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.failsafe_deserialize(_models.TemplateSpecsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + def get( + self, + resource_group_name, # type: str + template_spec_name, # type: str + template_spec_version, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.TemplateSpecVersion" + """Gets a Template Spec version from a specific Template Spec. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. + :type template_spec_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion, or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, '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'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + def delete( + self, + resource_group_name, # type: str + template_spec_name, # type: str + template_spec_version, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes a specific version from a Template Spec. When operation completes, status code 200 + returned without content. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. + :type template_spec_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, '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'] = self._serialize.header("accept", accept, 'str') + + 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.failsafe_deserialize(_models.TemplateSpecsError, 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.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + def list( + self, + resource_group_name, # type: str + template_spec_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.TemplateSpecVersionsListResult"] + """Lists all the Template Spec versions in the specified Template Spec. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. + :type template_spec_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersionsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersionsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecName': self._serialize.url("template_spec_name", template_spec_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('TemplateSpecVersionsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or 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.failsafe_deserialize(_models.TemplateSpecsError, 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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/_template_specs_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/_template_specs_operations.py new file mode 100644 index 0000000000000..ab652c09da1fb --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/_template_specs_operations.py @@ -0,0 +1,465 @@ +# 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 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.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class TemplateSpecsOperations(object): + """TemplateSpecsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.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, + resource_group_name, # type: str + template_spec_name, # type: str + template_spec, # type: "_models.TemplateSpec" + **kwargs # type: Any + ): + # type: (...) -> "_models.TemplateSpec" + """Creates or updates a Template Spec. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. + :type template_spec_name: str + :param template_spec: Template Spec supplied to the operation. + :type template_spec: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec, or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecName': self._serialize.url("template_spec_name", template_spec_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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(template_spec, 'TemplateSpec') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('TemplateSpec', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TemplateSpec', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + def update( + self, + resource_group_name, # type: str + template_spec_name, # type: str + template_spec=None, # type: Optional["_models.TemplateSpecUpdateModel"] + **kwargs # type: Any + ): + # type: (...) -> "_models.TemplateSpec" + """Updates Template Spec tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. + :type template_spec_name: str + :param template_spec: Template Spec resource with the tags to be updated. + :type template_spec: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecUpdateModel + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec, or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecName': self._serialize.url("template_spec_name", template_spec_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'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if template_spec is not None: + body_content = self._serialize.body(template_spec, 'TemplateSpecUpdateModel') + else: + body_content = None + 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.failsafe_deserialize(_models.TemplateSpecsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TemplateSpec', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + def get( + self, + resource_group_name, # type: str + template_spec_name, # type: str + expand=None, # type: Optional[Union[str, "_models.TemplateSpecExpandKind"]] + **kwargs # type: Any + ): + # type: (...) -> "_models.TemplateSpec" + """Gets a Template Spec with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. + :type template_spec_name: str + :param expand: Allows for expansion of additional Template Spec details in the response. + Optional. + :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec, or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecName': self._serialize.url("template_spec_name", template_spec_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] + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TemplateSpec', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + def delete( + self, + resource_group_name, # type: str + template_spec_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes a Template Spec by name. When operation completes, status code 200 returned without + content. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. + :type template_spec_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'templateSpecName': self._serialize.url("template_spec_name", template_spec_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'] = self._serialize.header("accept", accept, 'str') + + 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.failsafe_deserialize(_models.TemplateSpecsError, 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.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + def list_by_subscription( + self, + expand=None, # type: Optional[Union[str, "_models.TemplateSpecExpandKind"]] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.TemplateSpecsListResult"] + """Lists all the Template Specs within the specified subscriptions. + + :param expand: Allows for expansion of additional Template Spec details in the response. + Optional. + :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TemplateSpecsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + 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('TemplateSpecsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or 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.failsafe_deserialize(_models.TemplateSpecsError, 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.Resources/templateSpecs/'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name, # type: str + expand=None, # type: Optional[Union[str, "_models.TemplateSpecExpandKind"]] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.TemplateSpecsListResult"] + """Lists all the Template Specs within the specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param expand: Allows for expansion of additional Template Spec details in the response. + Optional. + :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TemplateSpecsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-03-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + '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] + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + 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('TemplateSpecsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or 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.failsafe_deserialize(_models.TemplateSpecsError, 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.Resources/templateSpecs/'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/py.typed new file mode 100644 index 0000000000000..e5aff4f83af86 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file