From 0d2fd6ba2d06b9a64a0c60c3e1393996e40009db Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 11 Aug 2021 23:30:14 +0000 Subject: [PATCH] CodeGen from PR 15181 in Azure/azure-rest-api-specs Merge 8e60c3c5c3e24d492b4b497270f123c6dce88aaf into 70626b932d16a97361673e0bcba7570284fe0813 --- sdk/resources/azure-mgmt-resource/_meta.json | 2 +- .../v2019_10_01_preview/_version.py | 2 +- .../deploymentscripts/v2020_10_01/_version.py | 2 +- .../resource/features/v2015_12_01/_version.py | 2 +- .../resource/features/v2021_07_01/_version.py | 2 +- .../resource/links/v2016_09_01/_version.py | 2 +- .../resource/locks/v2015_01_01/_version.py | 2 +- .../resource/locks/v2016_09_01/_version.py | 2 +- .../resource/managedapplications/_version.py | 2 +- .../mgmt/resource/policy/_policy_client.py | 21 +- .../resource/policy/aio/_policy_client.py | 21 +- .../azure/mgmt/resource/policy/models.py | 2 +- .../policy/v2015_10_01_preview/_version.py | 2 +- .../resource/policy/v2016_04_01/_version.py | 2 +- .../resource/policy/v2016_12_01/_version.py | 2 +- .../policy/v2017_06_01_preview/_version.py | 2 +- .../resource/policy/v2018_03_01/_version.py | 2 +- .../resource/policy/v2018_05_01/_version.py | 2 +- .../resource/policy/v2019_01_01/_version.py | 2 +- .../resource/policy/v2019_06_01/_version.py | 2 +- .../resource/policy/v2019_09_01/_version.py | 2 +- .../resource/policy/v2020_09_01/_version.py | 2 +- .../resource/policy/v2021_06_01/__init__.py | 19 + .../policy/v2021_06_01/_configuration.py | 70 + .../policy/v2021_06_01/_metadata.json | 107 ++ .../policy/v2021_06_01/_policy_client.py | 108 ++ .../resource/policy/v2021_06_01/_version.py | 9 + .../policy/v2021_06_01/aio/__init__.py | 10 + .../policy/v2021_06_01/aio/_configuration.py | 66 + .../policy/v2021_06_01/aio/_policy_client.py | 101 ++ .../v2021_06_01/aio/operations/__init__.py | 21 + .../_data_policy_manifests_operations.py | 173 +++ .../_policy_assignments_operations.py | 1015 +++++++++++++ .../_policy_definitions_operations.py | 735 ++++++++++ .../_policy_exemptions_operations.py | 642 ++++++++ .../_policy_set_definitions_operations.py | 743 ++++++++++ .../policy/v2021_06_01/models/__init__.py | 123 ++ .../policy/v2021_06_01/models/_models.py | 1169 +++++++++++++++ .../policy/v2021_06_01/models/_models_py3.py | 1297 +++++++++++++++++ .../models/_policy_client_enums.py | 139 ++ .../policy/v2021_06_01/operations/__init__.py | 21 + .../_data_policy_manifests_operations.py | 179 +++ .../_policy_assignments_operations.py | 1031 +++++++++++++ .../_policy_definitions_operations.py | 749 ++++++++++ .../_policy_exemptions_operations.py | 653 +++++++++ .../_policy_set_definitions_operations.py | 757 ++++++++++ .../mgmt/resource/policy/v2021_06_01/py.typed | 1 + .../resources/v2016_02_01/_version.py | 2 +- .../resources/v2016_09_01/_version.py | 2 +- .../resources/v2017_05_10/_version.py | 2 +- .../resources/v2018_02_01/_version.py | 2 +- .../resources/v2018_05_01/_version.py | 2 +- .../resources/v2019_03_01/_version.py | 2 +- .../resources/v2019_05_01/_version.py | 2 +- .../resources/v2019_05_10/_version.py | 2 +- .../resources/v2019_07_01/_version.py | 2 +- .../resources/v2019_08_01/_version.py | 2 +- .../resources/v2019_10_01/_version.py | 2 +- .../resources/v2020_06_01/_version.py | 2 +- .../resources/v2020_10_01/_version.py | 2 +- .../resources/v2021_01_01/_version.py | 2 +- .../resources/v2021_04_01/_version.py | 2 +- .../aio/operations/_providers_operations.py | 10 - .../aio/operations/_resources_operations.py | 38 +- .../operations/_providers_operations.py | 10 - .../operations/_resources_operations.py | 38 +- .../subscriptions/_operations_mixin.py | 6 +- .../subscriptions/_subscription_client.py | 13 +- .../subscriptions/aio/_operations_mixin.py | 6 +- .../subscriptions/aio/_subscription_client.py | 13 +- .../mgmt/resource/subscriptions/models.py | 1 + .../subscriptions/v2016_06_01/_version.py | 2 +- .../subscriptions/v2018_06_01/_version.py | 2 +- .../subscriptions/v2019_06_01/_version.py | 2 +- .../subscriptions/v2019_11_01/_version.py | 2 +- .../subscriptions/v2021_01_01/__init__.py | 19 + .../v2021_01_01/_configuration.py | 65 + .../subscriptions/v2021_01_01/_metadata.json | 110 ++ .../v2021_01_01/_subscription_client.py | 88 ++ .../subscriptions/v2021_01_01/_version.py | 9 + .../subscriptions/v2021_01_01/aio/__init__.py | 10 + .../v2021_01_01/aio/_configuration.py | 61 + .../v2021_01_01/aio/_subscription_client.py | 81 + .../v2021_01_01/aio/operations/__init__.py | 17 + .../_subscription_client_operations.py | 82 ++ .../operations/_subscriptions_operations.py | 234 +++ .../aio/operations/_tenants_operations.py | 104 ++ .../v2021_01_01/models/__init__.py | 81 + .../v2021_01_01/models/_models.py | 654 +++++++++ .../v2021_01_01/models/_models_py3.py | 693 +++++++++ .../models/_subscription_client_enums.py | 82 ++ .../v2021_01_01/operations/__init__.py | 17 + .../_subscription_client_operations.py | 87 ++ .../operations/_subscriptions_operations.py | 241 +++ .../operations/_tenants_operations.py | 109 ++ .../subscriptions/v2021_01_01/py.typed | 1 + .../v2019_06_01_preview/_version.py | 2 +- .../v2021_03_01_preview/_version.py | 2 +- .../templatespecs/v2021_05_01/_version.py | 2 +- 99 files changed, 12946 insertions(+), 98 deletions(-) create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_configuration.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_policy_client.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_configuration.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_policy_client.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_data_policy_manifests_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_assignments_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_definitions_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_exemptions_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_set_definitions_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_models.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_models_py3.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_policy_client_enums.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_data_policy_manifests_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_assignments_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_definitions_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_exemptions_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_set_definitions_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/py.typed create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_configuration.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_subscription_client.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_configuration.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_subscription_client.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_subscription_client_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_subscriptions_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_tenants_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_models.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_models_py3.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_subscription_client_enums.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_subscription_client_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_subscriptions_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_tenants_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/py.typed diff --git a/sdk/resources/azure-mgmt-resource/_meta.json b/sdk/resources/azure-mgmt-resource/_meta.json index 52b673e96e02..2c9a3d96539a 100644 --- a/sdk/resources/azure-mgmt-resource/_meta.json +++ b/sdk/resources/azure-mgmt-resource/_meta.json @@ -4,7 +4,7 @@ "@autorest/python@5.8.4", "@autorest/modelerfour@4.19.2" ], - "commit": "19707b7e63b29c7b89335f832a4eea104c64aebf", + "commit": "ef22ce087df2b04ed1b871b01471e106174e3570", "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.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", "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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_version.py index 232662316d4d..e5754a47ce68 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_policy_client.py index 6f0f5fa0dd99..b94a696cce82 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_policy_client.py @@ -55,7 +55,7 @@ class PolicyClient(MultiApiClientMixin, _SDKClient): :type profile: azure.profiles.KnownProfiles """ - DEFAULT_API_VERSION = '2020-09-01' + DEFAULT_API_VERSION = '2021-06-01' _PROFILE_TAG = "azure.mgmt.resource.policy.PolicyClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -100,6 +100,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2019-06-01: :mod:`v2019_06_01.models` * 2019-09-01: :mod:`v2019_09_01.models` * 2020-09-01: :mod:`v2020_09_01.models` + * 2021-06-01: :mod:`v2021_06_01.models` """ if api_version == '2015-10-01-preview': from .v2015_10_01_preview import models @@ -131,6 +132,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2020-09-01': from .v2020_09_01 import models return models + elif api_version == '2021-06-01': + from .v2021_06_01 import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -138,10 +142,13 @@ def data_policy_manifests(self): """Instance depends on the API version: * 2020-09-01: :class:`DataPolicyManifestsOperations` + * 2021-06-01: :class:`DataPolicyManifestsOperations` """ api_version = self._get_api_version('data_policy_manifests') if api_version == '2020-09-01': from .v2020_09_01.operations import DataPolicyManifestsOperations as OperationClass + elif api_version == '2021-06-01': + from .v2021_06_01.operations import DataPolicyManifestsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'data_policy_manifests'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -160,6 +167,7 @@ def policy_assignments(self): * 2019-06-01: :class:`PolicyAssignmentsOperations` * 2019-09-01: :class:`PolicyAssignmentsOperations` * 2020-09-01: :class:`PolicyAssignmentsOperations` + * 2021-06-01: :class:`PolicyAssignmentsOperations` """ api_version = self._get_api_version('policy_assignments') if api_version == '2015-10-01-preview': @@ -182,6 +190,8 @@ def policy_assignments(self): from .v2019_09_01.operations import PolicyAssignmentsOperations as OperationClass elif api_version == '2020-09-01': from .v2020_09_01.operations import PolicyAssignmentsOperations as OperationClass + elif api_version == '2021-06-01': + from .v2021_06_01.operations import PolicyAssignmentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'policy_assignments'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -200,6 +210,7 @@ def policy_definitions(self): * 2019-06-01: :class:`PolicyDefinitionsOperations` * 2019-09-01: :class:`PolicyDefinitionsOperations` * 2020-09-01: :class:`PolicyDefinitionsOperations` + * 2021-06-01: :class:`PolicyDefinitionsOperations` """ api_version = self._get_api_version('policy_definitions') if api_version == '2015-10-01-preview': @@ -222,6 +233,8 @@ def policy_definitions(self): from .v2019_09_01.operations import PolicyDefinitionsOperations as OperationClass elif api_version == '2020-09-01': from .v2020_09_01.operations import PolicyDefinitionsOperations as OperationClass + elif api_version == '2021-06-01': + from .v2021_06_01.operations import PolicyDefinitionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'policy_definitions'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -231,10 +244,13 @@ def policy_exemptions(self): """Instance depends on the API version: * 2020-09-01: :class:`PolicyExemptionsOperations` + * 2021-06-01: :class:`PolicyExemptionsOperations` """ api_version = self._get_api_version('policy_exemptions') if api_version == '2020-09-01': from .v2020_09_01.operations import PolicyExemptionsOperations as OperationClass + elif api_version == '2021-06-01': + from .v2021_06_01.operations import PolicyExemptionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'policy_exemptions'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -250,6 +266,7 @@ def policy_set_definitions(self): * 2019-06-01: :class:`PolicySetDefinitionsOperations` * 2019-09-01: :class:`PolicySetDefinitionsOperations` * 2020-09-01: :class:`PolicySetDefinitionsOperations` + * 2021-06-01: :class:`PolicySetDefinitionsOperations` """ api_version = self._get_api_version('policy_set_definitions') if api_version == '2017-06-01-preview': @@ -266,6 +283,8 @@ def policy_set_definitions(self): from .v2019_09_01.operations import PolicySetDefinitionsOperations as OperationClass elif api_version == '2020-09-01': from .v2020_09_01.operations import PolicySetDefinitionsOperations as OperationClass + elif api_version == '2021-06-01': + from .v2021_06_01.operations import PolicySetDefinitionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'policy_set_definitions'".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/policy/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/aio/_policy_client.py index eb824621e730..e40fa39b47e1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/aio/_policy_client.py @@ -53,7 +53,7 @@ class PolicyClient(MultiApiClientMixin, _SDKClient): :type profile: azure.profiles.KnownProfiles """ - DEFAULT_API_VERSION = '2020-09-01' + DEFAULT_API_VERSION = '2021-06-01' _PROFILE_TAG = "azure.mgmt.resource.policy.PolicyClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -98,6 +98,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2019-06-01: :mod:`v2019_06_01.models` * 2019-09-01: :mod:`v2019_09_01.models` * 2020-09-01: :mod:`v2020_09_01.models` + * 2021-06-01: :mod:`v2021_06_01.models` """ if api_version == '2015-10-01-preview': from ..v2015_10_01_preview import models @@ -129,6 +130,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2020-09-01': from ..v2020_09_01 import models return models + elif api_version == '2021-06-01': + from ..v2021_06_01 import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -136,10 +140,13 @@ def data_policy_manifests(self): """Instance depends on the API version: * 2020-09-01: :class:`DataPolicyManifestsOperations` + * 2021-06-01: :class:`DataPolicyManifestsOperations` """ api_version = self._get_api_version('data_policy_manifests') if api_version == '2020-09-01': from ..v2020_09_01.aio.operations import DataPolicyManifestsOperations as OperationClass + elif api_version == '2021-06-01': + from ..v2021_06_01.aio.operations import DataPolicyManifestsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'data_policy_manifests'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -158,6 +165,7 @@ def policy_assignments(self): * 2019-06-01: :class:`PolicyAssignmentsOperations` * 2019-09-01: :class:`PolicyAssignmentsOperations` * 2020-09-01: :class:`PolicyAssignmentsOperations` + * 2021-06-01: :class:`PolicyAssignmentsOperations` """ api_version = self._get_api_version('policy_assignments') if api_version == '2015-10-01-preview': @@ -180,6 +188,8 @@ def policy_assignments(self): from ..v2019_09_01.aio.operations import PolicyAssignmentsOperations as OperationClass elif api_version == '2020-09-01': from ..v2020_09_01.aio.operations import PolicyAssignmentsOperations as OperationClass + elif api_version == '2021-06-01': + from ..v2021_06_01.aio.operations import PolicyAssignmentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'policy_assignments'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -198,6 +208,7 @@ def policy_definitions(self): * 2019-06-01: :class:`PolicyDefinitionsOperations` * 2019-09-01: :class:`PolicyDefinitionsOperations` * 2020-09-01: :class:`PolicyDefinitionsOperations` + * 2021-06-01: :class:`PolicyDefinitionsOperations` """ api_version = self._get_api_version('policy_definitions') if api_version == '2015-10-01-preview': @@ -220,6 +231,8 @@ def policy_definitions(self): from ..v2019_09_01.aio.operations import PolicyDefinitionsOperations as OperationClass elif api_version == '2020-09-01': from ..v2020_09_01.aio.operations import PolicyDefinitionsOperations as OperationClass + elif api_version == '2021-06-01': + from ..v2021_06_01.aio.operations import PolicyDefinitionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'policy_definitions'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -229,10 +242,13 @@ def policy_exemptions(self): """Instance depends on the API version: * 2020-09-01: :class:`PolicyExemptionsOperations` + * 2021-06-01: :class:`PolicyExemptionsOperations` """ api_version = self._get_api_version('policy_exemptions') if api_version == '2020-09-01': from ..v2020_09_01.aio.operations import PolicyExemptionsOperations as OperationClass + elif api_version == '2021-06-01': + from ..v2021_06_01.aio.operations import PolicyExemptionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'policy_exemptions'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -248,6 +264,7 @@ def policy_set_definitions(self): * 2019-06-01: :class:`PolicySetDefinitionsOperations` * 2019-09-01: :class:`PolicySetDefinitionsOperations` * 2020-09-01: :class:`PolicySetDefinitionsOperations` + * 2021-06-01: :class:`PolicySetDefinitionsOperations` """ api_version = self._get_api_version('policy_set_definitions') if api_version == '2017-06-01-preview': @@ -264,6 +281,8 @@ def policy_set_definitions(self): from ..v2019_09_01.aio.operations import PolicySetDefinitionsOperations as OperationClass elif api_version == '2020-09-01': from ..v2020_09_01.aio.operations import PolicySetDefinitionsOperations as OperationClass + elif api_version == '2021-06-01': + from ..v2021_06_01.aio.operations import PolicySetDefinitionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'policy_set_definitions'".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/policy/models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/models.py index 5ed8fbe3db24..686564761a27 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/models.py @@ -4,4 +4,4 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from .v2020_09_01.models import * +from .v2021_06_01.models import * 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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/__init__.py new file mode 100644 index 000000000000..97237226e124 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_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 ._policy_client import PolicyClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ['PolicyClient'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_configuration.py new file mode 100644 index 000000000000..d9235f9db71a --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_configuration.py @@ -0,0 +1,70 @@ +# 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 PolicyClientConfiguration(Configuration): + """Configuration for PolicyClient. + + 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(PolicyClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + 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/policy/v2021_06_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_metadata.json new file mode 100644 index 000000000000..42940ef72f18 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_metadata.json @@ -0,0 +1,107 @@ +{ + "chosen_version": "2021-06-01", + "total_api_version_list": ["2020-07-01-preview", "2020-09-01", "2021-06-01"], + "client": { + "name": "PolicyClient", + "filename": "_policy_client", + "description": "To manage and control access to your resources, you can define customized policies and assign them at a scope.", + "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\": [\"PolicyClientConfiguration\"]}}, \"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\": [\"PolicyClientConfiguration\"]}}, \"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": { + "data_policy_manifests": "DataPolicyManifestsOperations", + "policy_assignments": "PolicyAssignmentsOperations", + "policy_definitions": "PolicyDefinitionsOperations", + "policy_set_definitions": "PolicySetDefinitionsOperations", + "policy_exemptions": "PolicyExemptionsOperations" + } +} \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_policy_client.py new file mode 100644 index 000000000000..1410395d86ba --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_policy_client.py @@ -0,0 +1,108 @@ +# 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 PolicyClientConfiguration +from .operations import DataPolicyManifestsOperations +from .operations import PolicyAssignmentsOperations +from .operations import PolicyDefinitionsOperations +from .operations import PolicySetDefinitionsOperations +from .operations import PolicyExemptionsOperations +from . import models + + +class PolicyClient(object): + """To manage and control access to your resources, you can define customized policies and assign them at a scope. + + :ivar data_policy_manifests: DataPolicyManifestsOperations operations + :vartype data_policy_manifests: azure.mgmt.resource.policy.v2021_06_01.operations.DataPolicyManifestsOperations + :ivar policy_assignments: PolicyAssignmentsOperations operations + :vartype policy_assignments: azure.mgmt.resource.policy.v2021_06_01.operations.PolicyAssignmentsOperations + :ivar policy_definitions: PolicyDefinitionsOperations operations + :vartype policy_definitions: azure.mgmt.resource.policy.v2021_06_01.operations.PolicyDefinitionsOperations + :ivar policy_set_definitions: PolicySetDefinitionsOperations operations + :vartype policy_set_definitions: azure.mgmt.resource.policy.v2021_06_01.operations.PolicySetDefinitionsOperations + :ivar policy_exemptions: PolicyExemptionsOperations operations + :vartype policy_exemptions: azure.mgmt.resource.policy.v2021_06_01.operations.PolicyExemptionsOperations + :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 + """ + + 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 = PolicyClientConfiguration(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.data_policy_manifests = DataPolicyManifestsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.policy_set_definitions = PolicySetDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.policy_exemptions = PolicyExemptionsOperations( + 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: () -> PolicyClient + 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/policy/v2021_06_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_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/policy/v2021_06_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/__init__.py new file mode 100644 index 000000000000..63f5892fe30b --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_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 ._policy_client import PolicyClient +__all__ = ['PolicyClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_configuration.py new file mode 100644 index 000000000000..cd61c80f5dd7 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_configuration.py @@ -0,0 +1,66 @@ +# 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 PolicyClientConfiguration(Configuration): + """Configuration for PolicyClient. + + 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(PolicyClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + 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/policy/v2021_06_01/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_policy_client.py new file mode 100644 index 000000000000..3a5c4f828de1 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_policy_client.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, 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 PolicyClientConfiguration +from .operations import DataPolicyManifestsOperations +from .operations import PolicyAssignmentsOperations +from .operations import PolicyDefinitionsOperations +from .operations import PolicySetDefinitionsOperations +from .operations import PolicyExemptionsOperations +from .. import models + + +class PolicyClient(object): + """To manage and control access to your resources, you can define customized policies and assign them at a scope. + + :ivar data_policy_manifests: DataPolicyManifestsOperations operations + :vartype data_policy_manifests: azure.mgmt.resource.policy.v2021_06_01.aio.operations.DataPolicyManifestsOperations + :ivar policy_assignments: PolicyAssignmentsOperations operations + :vartype policy_assignments: azure.mgmt.resource.policy.v2021_06_01.aio.operations.PolicyAssignmentsOperations + :ivar policy_definitions: PolicyDefinitionsOperations operations + :vartype policy_definitions: azure.mgmt.resource.policy.v2021_06_01.aio.operations.PolicyDefinitionsOperations + :ivar policy_set_definitions: PolicySetDefinitionsOperations operations + :vartype policy_set_definitions: azure.mgmt.resource.policy.v2021_06_01.aio.operations.PolicySetDefinitionsOperations + :ivar policy_exemptions: PolicyExemptionsOperations operations + :vartype policy_exemptions: azure.mgmt.resource.policy.v2021_06_01.aio.operations.PolicyExemptionsOperations + :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 + """ + + 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 = PolicyClientConfiguration(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.data_policy_manifests = DataPolicyManifestsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.policy_set_definitions = PolicySetDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.policy_exemptions = PolicyExemptionsOperations( + 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) -> "PolicyClient": + 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/policy/v2021_06_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/__init__.py new file mode 100644 index 000000000000..a39cae740704 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/__init__.py @@ -0,0 +1,21 @@ +# 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 ._data_policy_manifests_operations import DataPolicyManifestsOperations +from ._policy_assignments_operations import PolicyAssignmentsOperations +from ._policy_definitions_operations import PolicyDefinitionsOperations +from ._policy_set_definitions_operations import PolicySetDefinitionsOperations +from ._policy_exemptions_operations import PolicyExemptionsOperations + +__all__ = [ + 'DataPolicyManifestsOperations', + 'PolicyAssignmentsOperations', + 'PolicyDefinitionsOperations', + 'PolicySetDefinitionsOperations', + 'PolicyExemptionsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_data_policy_manifests_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_data_policy_manifests_operations.py new file mode 100644 index 000000000000..1f4850dfd109 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_data_policy_manifests_operations.py @@ -0,0 +1,173 @@ +# 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 DataPolicyManifestsOperations: + """DataPolicyManifestsOperations 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.policy.v2021_06_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_by_policy_mode( + self, + policy_mode: str, + **kwargs: Any + ) -> "_models.DataPolicyManifest": + """Retrieves a data policy manifest. + + This operation retrieves the data policy manifest with the given policy mode. + + :param policy_mode: The policy mode of the data policy manifest to get. + :type policy_mode: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataPolicyManifest, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.DataPolicyManifest + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DataPolicyManifest"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + accept = "application/json" + + # Construct URL + url = self.get_by_policy_mode.metadata['url'] # type: ignore + path_format_arguments = { + 'policyMode': self._serialize.url("policy_mode", policy_mode, '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('DataPolicyManifest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_policy_mode.metadata = {'url': '/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.DataPolicyManifestListResult"]: + """Retrieves data policy manifests. + + This operation retrieves a list of all the data policy manifests that match the optional given + $filter. Valid values for $filter are: "$filter=namespace eq '{0}'". If $filter is not + provided, the unfiltered list includes all data policy manifests for data resource types. If + $filter=namespace is provided, the returned list only includes all data policy manifests that + have a namespace matching the provided value. + + :param filter: The filter to apply on the operation. Valid values for $filter are: "namespace + eq '{value}'". If $filter is not provided, no filtering is performed. If $filter=namespace eq + '{value}' is provided, the returned list only includes all data policy manifests that have a + namespace matching the provided value. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DataPolicyManifestListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.DataPolicyManifestListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DataPolicyManifestListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-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') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) + + 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('DataPolicyManifestListResult', 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.Authorization/dataPolicyManifests'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_assignments_operations.py new file mode 100644 index 000000000000..a043621e741b --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_assignments_operations.py @@ -0,0 +1,1015 @@ +# 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 PolicyAssignmentsOperations: + """PolicyAssignmentsOperations 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.policy.v2021_06_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( + self, + scope: str, + policy_assignment_name: str, + **kwargs: Any + ) -> Optional["_models.PolicyAssignment"]: + """Deletes a policy assignment. + + This operation deletes a policy assignment, given its name and the scope it was created in. The + scope of a policy assignment is the part of its ID preceding + '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment to delete. + :type policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.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) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + async def create( + self, + scope: str, + policy_assignment_name: str, + parameters: "_models.PolicyAssignment", + **kwargs: Any + ) -> "_models.PolicyAssignment": + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'PolicyAssignment') + 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 [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + async def get( + self, + scope: str, + policy_assignment_name: str, + **kwargs: Any + ) -> "_models.PolicyAssignment": + """Retrieves a policy assignment. + + This operation retrieves a single policy assignment, given its name and the scope it was + created at. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment to get. + :type policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + async def update( + self, + scope: str, + policy_assignment_name: str, + parameters: "_models.PolicyAssignmentUpdate", + **kwargs: Any + ) -> "_models.PolicyAssignment": + """Updates a policy assignment. + + This operation updates a policy assignment with the given scope and name. Policy assignments + apply to all resources contained within their scope. For example, when you assign a policy at + resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. + :type policy_assignment_name: str + :param parameters: Parameters for policy assignment patch request. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'PolicyAssignmentUpdate') + 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('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + def list_for_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + """Retrieves all policy assignments that apply to a resource group. + + This operation retrieves the list of all policy assignments associated with the given resource + group in the given subscription that match the optional given $filter. Valid values for $filter + are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not + provided, the unfiltered list includes all policy assignments associated with the resource + group, including those that apply directly or apply from containing scopes, as well as any + applied to resources contained within the resource group. If $filter=atScope() is provided, the + returned list includes all policy assignments that apply to the resource group, which is + everything in the unfiltered list except those applied to resources contained within the + resource group. If $filter=atExactScope() is provided, the returned list only includes all + policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is + provided, the returned list includes all policy assignments of the policy definition whose id + is {value} that apply to the resource group. + + :param resource_group_name: The name of the resource group that contains policy assignments. + :type resource_group_name: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', + 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering + is performed. If $filter=atScope() is provided, the returned list only includes all policy + assignments that apply to the scope, which is everything in the unfiltered list except those + applied to sub scopes contained within the given scope. If $filter=atExactScope() is provided, + the returned list only includes all policy assignments that at the given scope. If + $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy + assignments of the policy definition whose id is {value}. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. + :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 PolicyAssignmentListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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_for_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', skip_quote=True) + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + 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('PolicyAssignmentListResult', 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_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + + def list_for_resource( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + """Retrieves all policy assignments that apply to a resource. + + This operation retrieves the list of all policy assignments associated with the specified + resource in the given resource group and subscription that match the optional given $filter. + Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq + '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments + associated with the resource, including those that apply directly or from all containing + scopes, as well as any applied to resources contained within the resource. If $filter=atScope() + is provided, the returned list includes all policy assignments that apply to the resource, + which is everything in the unfiltered list except those applied to resources contained within + the resource. If $filter=atExactScope() is provided, the returned list only includes all policy + assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, + the returned list includes all policy assignments of the policy definition whose id is {value} + that apply to the resource. Three parameters plus the resource name are used to identify a + specific resource. If the resource is not part of a parent resource (the more common case), the + parent resource path should not be provided (or provided as ''). For example a web app could be + specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', + {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent + resource, then all parameters should be provided. For example a virtual machine DNS name could + be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == + 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == + 'MyComputerName'). A convenient alternative to providing the namespace and type name separately + is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', + {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == + 'MyWebApp'). + + :param resource_group_name: The name of the resource group containing the resource. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. For example, the + namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource path. Use empty string if there is none. + :type parent_resource_path: str + :param resource_type: The resource type name. For example the type name of a web app is 'sites' + (from Microsoft.Web/sites). + :type resource_type: str + :param resource_name: The name of the resource. + :type resource_name: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', + 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering + is performed. If $filter=atScope() is provided, the returned list only includes all policy + assignments that apply to the scope, which is everything in the unfiltered list except those + applied to sub scopes contained within the given scope. If $filter=atExactScope() is provided, + the returned list only includes all policy assignments that at the given scope. If + $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy + assignments of the policy definition whose id is {value}. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. + :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 PolicyAssignmentListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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_for_resource.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] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + 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('PolicyAssignmentListResult', 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_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + + def list_for_management_group( + self, + management_group_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + """Retrieves all policy assignments that apply to a management group. + + This operation retrieves the list of all policy assignments applicable to the management group + that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or + 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes + all policy assignments that are assigned to the management group or the management group's + ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy + assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is + provided, the returned list includes all policy assignments of the policy definition whose id + is {value} that apply to the management group. + + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', + 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering + is performed. If $filter=atScope() is provided, the returned list only includes all policy + assignments that apply to the scope, which is everything in the unfiltered list except those + applied to sub scopes contained within the given scope. If $filter=atExactScope() is provided, + the returned list only includes all policy assignments that at the given scope. If + $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy + assignments of the policy definition whose id is {value}. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. + :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 PolicyAssignmentListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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_for_management_group.metadata['url'] # type: ignore + path_format_arguments = { + 'managementGroupId': self._serialize.url("management_group_id", management_group_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', skip_quote=True) + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + 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('PolicyAssignmentListResult', 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_for_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + """Retrieves all policy assignments that apply to a subscription. + + This operation retrieves the list of all policy assignments associated with the given + subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', + 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the + unfiltered list includes all policy assignments associated with the subscription, including + those that apply directly or from management groups that contain the given subscription, as + well as any applied to objects contained within the subscription. If $filter=atScope() is + provided, the returned list includes all policy assignments that apply to the subscription, + which is everything in the unfiltered list except those applied to objects contained within the + subscription. If $filter=atExactScope() is provided, the returned list only includes all policy + assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, + the returned list includes all policy assignments of the policy definition whose id is {value}. + + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', + 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering + is performed. If $filter=atScope() is provided, the returned list only includes all policy + assignments that apply to the scope, which is everything in the unfiltered list except those + applied to sub scopes contained within the given scope. If $filter=atExactScope() is provided, + the returned list only includes all policy assignments that at the given scope. If + $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy + assignments of the policy definition whose id is {value}. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. + :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 PolicyAssignmentListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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', skip_quote=True) + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + 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('PolicyAssignmentListResult', 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/Microsoft.Authorization/policyAssignments'} # type: ignore + + async def delete_by_id( + self, + policy_assignment_id: str, + **kwargs: Any + ) -> Optional["_models.PolicyAssignment"]: + """Deletes a policy assignment. + + This operation deletes the policy with the given ID. Policy assignment IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' + (management group), '/subscriptions/{subscriptionId}' (subscription), + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + (resource). + + :param policy_assignment_id: The ID of the policy assignment to delete. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + accept = "application/json" + + # Construct URL + url = self.delete_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_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, 204]: + 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('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + async def create_by_id( + self, + policy_assignment_id: str, + parameters: "_models.PolicyAssignment", + **kwargs: Any + ) -> "_models.PolicyAssignment": + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_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, 'PolicyAssignment') + 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 [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + async def get_by_id( + self, + policy_assignment_id: str, + **kwargs: Any + ) -> "_models.PolicyAssignment": + """Retrieves the policy assignment with the given ID. + + The operation retrieves the policy assignment with the given ID. Policy assignment IDs have + this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to get. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + accept = "application/json" + + # Construct URL + url = self.get_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_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('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + async def update_by_id( + self, + policy_assignment_id: str, + parameters: "_models.PolicyAssignmentUpdate", + **kwargs: Any + ) -> "_models.PolicyAssignment": + """Updates a policy assignment. + + This operation updates the policy assignment with the given ID. Policy assignments made on a + scope apply to all resources contained in that scope. For example, when you assign a policy to + a resource group that policy applies to all resources in the group. Policy assignment IDs have + this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to update. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment patch request. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_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, 'PolicyAssignmentUpdate') + 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('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_definitions_operations.py new file mode 100644 index 000000000000..f8a957737542 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_definitions_operations.py @@ -0,0 +1,735 @@ +# 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 PolicyDefinitionsOperations: + """PolicyDefinitionsOperations 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.policy.v2021_06_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 create_or_update( + self, + policy_definition_name: str, + parameters: "_models.PolicyDefinition", + **kwargs: Any + ) -> "_models.PolicyDefinition": + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. + :type policy_definition_name: str + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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 = { + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_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, 'PolicyDefinition') + 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 [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def delete( + self, + policy_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes a policy definition in a subscription. + + This operation deletes the policy definition in the given subscription with the given name. + + :param policy_definition_name: The name of the policy definition to delete. + :type policy_definition_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-06-01" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_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}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get( + self, + policy_definition_name: str, + **kwargs: Any + ) -> "_models.PolicyDefinition": + """Retrieves a policy definition in a subscription. + + This operation retrieves the policy definition in the given subscription with the given name. + + :param policy_definition_name: The name of the policy definition to get. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_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('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get_built_in( + self, + policy_definition_name: str, + **kwargs: Any + ) -> "_models.PolicyDefinition": + """Retrieves a built-in policy definition. + + This operation retrieves the built-in policy definition with the given name. + + :param policy_definition_name: The name of the built-in policy definition to get. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + accept = "application/json" + + # Construct URL + url = self.get_built_in.metadata['url'] # type: ignore + path_format_arguments = { + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: "_models.PolicyDefinition", + **kwargs: Any + ) -> "_models.PolicyDefinition": + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + + :param policy_definition_name: The name of the policy definition to create. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update_at_management_group.metadata['url'] # type: ignore + path_format_arguments = { + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), + 'managementGroupId': self._serialize.url("management_group_id", management_group_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, 'PolicyDefinition') + 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 [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def delete_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + **kwargs: Any + ) -> None: + """Deletes a policy definition in a management group. + + This operation deletes the policy definition in the given management group with the given name. + + :param policy_definition_name: The name of the policy definition to delete. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. + :type management_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-06-01" + accept = "application/json" + + # Construct URL + url = self.delete_at_management_group.metadata['url'] # type: ignore + path_format_arguments = { + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), + 'managementGroupId': self._serialize.url("management_group_id", management_group_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_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + **kwargs: Any + ) -> "_models.PolicyDefinition": + """Retrieve a policy definition in a management group. + + This operation retrieves the policy definition in the given management group with the given + name. + + :param policy_definition_name: The name of the policy definition to get. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. + :type management_group_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + accept = "application/json" + + # Construct URL + url = self.get_at_management_group.metadata['url'] # type: ignore + path_format_arguments = { + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), + 'managementGroupId': self._serialize.url("management_group_id", management_group_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('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + """Retrieves policy definitions in a subscription. + + This operation retrieves a list of all the policy definitions in a given subscription that + match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType + -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list + includes all policy definitions associated with the subscription, including those that apply + directly or from management groups that contain the given subscription. If + $filter=atExactScope() is provided, the returned list only includes all policy definitions that + at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list + only includes all policy definitions whose type match the {value}. Possible policyType values + are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, + the returned list only includes all policy definitions whose category match the {value}. + + :param filter: The filter to apply on the operation. Valid values for $filter are: + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy definitions whose type match + the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy + definitions whose category match the {value}. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. + :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 PolicyDefinitionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + + 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('PolicyDefinitionListResult', 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/Microsoft.Authorization/policyDefinitions'} # type: ignore + + def list_built_in( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + """Retrieve built-in policy definitions. + + This operation retrieves a list of all the built-in policy definitions that match the optional + given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes + all built-in policy definitions whose type match the {value}. Possible policyType values are + NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the + returned list only includes all built-in policy definitions whose category match the {value}. + + :param filter: The filter to apply on the operation. Valid values for $filter are: + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy definitions whose type match + the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy + definitions whose category match the {value}. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. + :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 PolicyDefinitionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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_built_in.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + + 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('PolicyDefinitionListResult', 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_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + + def list_by_management_group( + self, + management_group_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + """Retrieve policy definitions in a management group. + + This operation retrieves a list of all the policy definitions in a given management group that + match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType + -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list + includes all policy definitions associated with the management group, including those that + apply directly or from management groups that contain the given management group. If + $filter=atExactScope() is provided, the returned list only includes all policy definitions that + at the given management group. If $filter='policyType -eq {value}' is provided, the returned + list only includes all policy definitions whose type match the {value}. Possible policyType + values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is + provided, the returned list only includes all policy definitions whose category match the + {value}. + + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param filter: The filter to apply on the operation. Valid values for $filter are: + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy definitions whose type match + the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy + definitions whose category match the {value}. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. + :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 PolicyDefinitionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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_management_group.metadata['url'] # type: ignore + path_format_arguments = { + 'managementGroupId': self._serialize.url("management_group_id", management_group_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') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + + 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('PolicyDefinitionListResult', 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_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_exemptions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_exemptions_operations.py new file mode 100644 index 000000000000..ae6dd8ff815f --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_exemptions_operations.py @@ -0,0 +1,642 @@ +# 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 PolicyExemptionsOperations: + """PolicyExemptionsOperations 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.policy.v2021_06_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( + self, + scope: str, + policy_exemption_name: str, + **kwargs: Any + ) -> None: + """Deletes a policy exemption. + + This operation deletes a policy exemption, given its name and the scope it was created in. The + scope of a policy exemption is the part of its ID preceding + '/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'. + + :param scope: The scope of the policy exemption. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_exemption_name: The name of the policy exemption to delete. + :type policy_exemption_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 = "2020-07-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'policyExemptionName': self._serialize.url("policy_exemption_name", policy_exemption_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.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': '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'} # type: ignore + + async def create_or_update( + self, + scope: str, + policy_exemption_name: str, + parameters: "_models.PolicyExemption", + **kwargs: Any + ) -> "_models.PolicyExemption": + """Creates or updates a policy exemption. + + This operation creates or updates a policy exemption with the given scope and name. Policy + exemptions apply to all resources contained within their scope. For example, when you create a + policy exemption at resource group scope for a policy assignment at the same or above level, + the exemption exempts to all applicable resources in the resource group. + + :param scope: The scope of the policy exemption. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_exemption_name: The name of the policy exemption to delete. + :type policy_exemption_name: str + :param parameters: Parameters for the policy exemption. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyExemption, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemption"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-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 = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'policyExemptionName': self._serialize.url("policy_exemption_name", policy_exemption_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'PolicyExemption') + 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('PolicyExemption', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PolicyExemption', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'} # type: ignore + + async def get( + self, + scope: str, + policy_exemption_name: str, + **kwargs: Any + ) -> "_models.PolicyExemption": + """Retrieves a policy exemption. + + This operation retrieves a single policy exemption, given its name and the scope it was created + at. + + :param scope: The scope of the policy exemption. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_exemption_name: The name of the policy exemption to delete. + :type policy_exemption_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyExemption, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemption"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'policyExemptionName': self._serialize.url("policy_exemption_name", policy_exemption_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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('PolicyExemption', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.PolicyExemptionListResult"]: + """Retrieves all policy exemptions that apply to a subscription. + + This operation retrieves the list of all policy exemptions associated with the given + subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', + 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not + provided, the unfiltered list includes all policy exemptions associated with the subscription, + including those that apply directly or from management groups that contain the given + subscription, as well as any applied to objects contained within the subscription. + + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', + 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter is not provided, the unfiltered list includes + all policy exemptions associated with the scope, including those that apply directly or apply + from containing scopes. If $filter=atScope() is provided, the returned list only includes all + policy exemptions that apply to the scope, which is everything in the unfiltered list except + those applied to sub scopes contained within the given scope. If $filter=atExactScope() is + provided, the returned list only includes all policy exemptions that at the given scope. If + $filter=excludeExpired() is provided, the returned list only includes all policy exemptions + that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId eq + '{value}' is provided. the returned list only includes all policy exemptions that are + associated with the give policyAssignmentId. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-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'), + } + 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', skip_quote=True) + 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('PolicyExemptionListResult', 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/Microsoft.Authorization/policyExemptions'} # type: ignore + + def list_for_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.PolicyExemptionListResult"]: + """Retrieves all policy exemptions that apply to a resource group. + + This operation retrieves the list of all policy exemptions associated with the given resource + group in the given subscription that match the optional given $filter. Valid values for $filter + are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If + $filter is not provided, the unfiltered list includes all policy exemptions associated with the + resource group, including those that apply directly or apply from containing scopes, as well as + any applied to resources contained within the resource group. + + :param resource_group_name: The name of the resource group containing the resource. + :type resource_group_name: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', + 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter is not provided, the unfiltered list includes + all policy exemptions associated with the scope, including those that apply directly or apply + from containing scopes. If $filter=atScope() is provided, the returned list only includes all + policy exemptions that apply to the scope, which is everything in the unfiltered list except + those applied to sub scopes contained within the given scope. If $filter=atExactScope() is + provided, the returned list only includes all policy exemptions that at the given scope. If + $filter=excludeExpired() is provided, the returned list only includes all policy exemptions + that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId eq + '{value}' is provided. the returned list only includes all policy exemptions that are + associated with the give policyAssignmentId. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-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_for_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 filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) + 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('PolicyExemptionListResult', 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_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions'} # type: ignore + + def list_for_resource( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.PolicyExemptionListResult"]: + """Retrieves all policy exemptions that apply to a resource. + + This operation retrieves the list of all policy exemptions associated with the specified + resource in the given resource group and subscription that match the optional given $filter. + Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or + 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all + policy exemptions associated with the resource, including those that apply directly or from all + containing scopes, as well as any applied to resources contained within the resource. Three + parameters plus the resource name are used to identify a specific resource. If the resource is + not part of a parent resource (the more common case), the parent resource path should not be + provided (or provided as ''). For example a web app could be specified as + ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == + 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all + parameters should be provided. For example a virtual machine DNS name could be specified as + ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == + 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == + 'MyComputerName'). A convenient alternative to providing the namespace and type name separately + is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', + {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == + 'MyWebApp'). + + :param resource_group_name: The name of the resource group containing the resource. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. For example, the + namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource path. Use empty string if there is none. + :type parent_resource_path: str + :param resource_type: The resource type name. For example the type name of a web app is 'sites' + (from Microsoft.Web/sites). + :type resource_type: str + :param resource_name: The name of the resource. + :type resource_name: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', + 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter is not provided, the unfiltered list includes + all policy exemptions associated with the scope, including those that apply directly or apply + from containing scopes. If $filter=atScope() is provided, the returned list only includes all + policy exemptions that apply to the scope, which is everything in the unfiltered list except + those applied to sub scopes contained within the given scope. If $filter=atExactScope() is + provided, the returned list only includes all policy exemptions that at the given scope. If + $filter=excludeExpired() is provided, the returned list only includes all policy exemptions + that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId eq + '{value}' is provided. the returned list only includes all policy exemptions that are + associated with the give policyAssignmentId. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-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_for_resource.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\._\(\)]+$'), + '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'), + } + 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', skip_quote=True) + 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('PolicyExemptionListResult', 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_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions'} # type: ignore + + def list_for_management_group( + self, + management_group_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.PolicyExemptionListResult"]: + """Retrieves all policy exemptions that apply to a management group. + + This operation retrieves the list of all policy exemptions applicable to the management group + that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', + 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter=atScope() is provided, the + returned list includes all policy exemptions that are assigned to the management group or the + management group's ancestors. + + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', + 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter is not provided, the unfiltered list includes + all policy exemptions associated with the scope, including those that apply directly or apply + from containing scopes. If $filter=atScope() is provided, the returned list only includes all + policy exemptions that apply to the scope, which is everything in the unfiltered list except + those applied to sub scopes contained within the given scope. If $filter=atExactScope() is + provided, the returned list only includes all policy exemptions that at the given scope. If + $filter=excludeExpired() is provided, the returned list only includes all policy exemptions + that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId eq + '{value}' is provided. the returned list only includes all policy exemptions that are + associated with the give policyAssignmentId. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-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_for_management_group.metadata['url'] # type: ignore + path_format_arguments = { + 'managementGroupId': self._serialize.url("management_group_id", management_group_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', skip_quote=True) + 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('PolicyExemptionListResult', 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_for_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyExemptions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_set_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_set_definitions_operations.py new file mode 100644 index 000000000000..7be7e86ccd31 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_set_definitions_operations.py @@ -0,0 +1,743 @@ +# 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 PolicySetDefinitionsOperations: + """PolicySetDefinitionsOperations 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.policy.v2021_06_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 create_or_update( + self, + policy_set_definition_name: str, + parameters: "_models.PolicySetDefinition", + **kwargs: Any + ) -> "_models.PolicySetDefinition": + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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 = { + 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_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, 'PolicySetDefinition') + 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('PolicySetDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def delete( + self, + policy_set_definition_name: str, + **kwargs: Any + ) -> None: + """Deletes a policy set definition. + + This operation deletes the policy set definition in the given subscription with the given name. + + :param policy_set_definition_name: The name of the policy set definition to delete. + :type policy_set_definition_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-06-01" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_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}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def get( + self, + policy_set_definition_name: str, + **kwargs: Any + ) -> "_models.PolicySetDefinition": + """Retrieves a policy set definition. + + This operation retrieves the policy set definition in the given subscription with the given + name. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_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('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def get_built_in( + self, + policy_set_definition_name: str, + **kwargs: Any + ) -> "_models.PolicySetDefinition": + """Retrieves a built in policy set definition. + + This operation retrieves the built-in policy set definition with the given name. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + accept = "application/json" + + # Construct URL + url = self.get_built_in.metadata['url'] # type: ignore + path_format_arguments = { + 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + """Retrieves the policy set definitions for a subscription. + + This operation retrieves a list of all the policy set definitions in a given subscription that + match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType + -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list + includes all policy set definitions associated with the subscription, including those that + apply directly or from management groups that contain the given subscription. If + $filter=atExactScope() is provided, the returned list only includes all policy set definitions + that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned + list only includes all policy set definitions whose type match the {value}. Possible policyType + values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the + returned list only includes all policy set definitions whose category match the {value}. + + :param filter: The filter to apply on the operation. Valid values for $filter are: + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy set definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy set definitions whose type + match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy set + definitions whose category match the {value}. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. + :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 PolicySetDefinitionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + + 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('PolicySetDefinitionListResult', 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/Microsoft.Authorization/policySetDefinitions'} # type: ignore + + def list_built_in( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + """Retrieves built-in policy set definitions. + + This operation retrieves a list of all the built-in policy set definitions that match the + optional given $filter. If $filter='category -eq {value}' is provided, the returned list only + includes all built-in policy set definitions whose category match the {value}. + + :param filter: The filter to apply on the operation. Valid values for $filter are: + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy set definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy set definitions whose type + match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy set + definitions whose category match the {value}. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. + :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 PolicySetDefinitionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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_built_in.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + + 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('PolicySetDefinitionListResult', 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_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: "_models.PolicySetDefinition", + **kwargs: Any + ) -> "_models.PolicySetDefinition": + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param parameters: The policy set definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update_at_management_group.metadata['url'] # type: ignore + path_format_arguments = { + 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), + 'managementGroupId': self._serialize.url("management_group_id", management_group_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, 'PolicySetDefinition') + 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('PolicySetDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def delete_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + **kwargs: Any + ) -> None: + """Deletes a policy set definition. + + This operation deletes the policy set definition in the given management group with the given + name. + + :param policy_set_definition_name: The name of the policy set definition to delete. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. + :type management_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-06-01" + accept = "application/json" + + # Construct URL + url = self.delete_at_management_group.metadata['url'] # type: ignore + path_format_arguments = { + 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), + 'managementGroupId': self._serialize.url("management_group_id", management_group_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_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def get_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + **kwargs: Any + ) -> "_models.PolicySetDefinition": + """Retrieves a policy set definition. + + This operation retrieves the policy set definition in the given management group with the given + name. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. + :type management_group_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + accept = "application/json" + + # Construct URL + url = self.get_at_management_group.metadata['url'] # type: ignore + path_format_arguments = { + 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), + 'managementGroupId': self._serialize.url("management_group_id", management_group_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('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + def list_by_management_group( + self, + management_group_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + """Retrieves all policy set definitions in management group. + + This operation retrieves a list of all the policy set definitions in a given management group + that match the optional given $filter. Valid values for $filter are: 'atExactScope()', + 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered + list includes all policy set definitions associated with the management group, including those + that apply directly or from management groups that contain the given management group. If + $filter=atExactScope() is provided, the returned list only includes all policy set definitions + that at the given management group. If $filter='policyType -eq {value}' is provided, the + returned list only includes all policy set definitions whose type match the {value}. Possible + policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is + provided, the returned list only includes all policy set definitions whose category match the + {value}. + + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param filter: The filter to apply on the operation. Valid values for $filter are: + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy set definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy set definitions whose type + match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy set + definitions whose category match the {value}. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. + :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 PolicySetDefinitionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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_management_group.metadata['url'] # type: ignore + path_format_arguments = { + 'managementGroupId': self._serialize.url("management_group_id", management_group_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') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + + 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('PolicySetDefinitionListResult', 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_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/__init__.py new file mode 100644 index 000000000000..9db31b58e637 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/__init__.py @@ -0,0 +1,123 @@ +# 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 DataEffect + from ._models_py3 import DataManifestCustomResourceFunctionDefinition + from ._models_py3 import DataPolicyManifest + from ._models_py3 import DataPolicyManifestListResult + from ._models_py3 import ErrorAdditionalInfo + from ._models_py3 import ErrorResponse + from ._models_py3 import Identity + from ._models_py3 import NonComplianceMessage + from ._models_py3 import ParameterDefinitionsValue + from ._models_py3 import ParameterDefinitionsValueMetadata + from ._models_py3 import ParameterValuesValue + from ._models_py3 import PolicyAssignment + from ._models_py3 import PolicyAssignmentListResult + from ._models_py3 import PolicyAssignmentUpdate + from ._models_py3 import PolicyDefinition + from ._models_py3 import PolicyDefinitionGroup + from ._models_py3 import PolicyDefinitionListResult + from ._models_py3 import PolicyDefinitionReference + from ._models_py3 import PolicyExemption + from ._models_py3 import PolicyExemptionListResult + from ._models_py3 import PolicySetDefinition + from ._models_py3 import PolicySetDefinitionListResult + from ._models_py3 import ResourceTypeAliases + from ._models_py3 import SystemData + from ._models_py3 import UserAssignedIdentitiesValue +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 DataEffect # type: ignore + from ._models import DataManifestCustomResourceFunctionDefinition # type: ignore + from ._models import DataPolicyManifest # type: ignore + from ._models import DataPolicyManifestListResult # type: ignore + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import Identity # type: ignore + from ._models import NonComplianceMessage # type: ignore + from ._models import ParameterDefinitionsValue # type: ignore + from ._models import ParameterDefinitionsValueMetadata # type: ignore + from ._models import ParameterValuesValue # type: ignore + from ._models import PolicyAssignment # type: ignore + from ._models import PolicyAssignmentListResult # type: ignore + from ._models import PolicyAssignmentUpdate # type: ignore + from ._models import PolicyDefinition # type: ignore + from ._models import PolicyDefinitionGroup # type: ignore + from ._models import PolicyDefinitionListResult # type: ignore + from ._models import PolicyDefinitionReference # type: ignore + from ._models import PolicyExemption # type: ignore + from ._models import PolicyExemptionListResult # type: ignore + from ._models import PolicySetDefinition # type: ignore + from ._models import PolicySetDefinitionListResult # type: ignore + from ._models import ResourceTypeAliases # type: ignore + from ._models import SystemData # type: ignore + from ._models import UserAssignedIdentitiesValue # type: ignore + +from ._policy_client_enums import ( + AliasPathAttributes, + AliasPathTokenType, + AliasPatternType, + AliasType, + CreatedByType, + EnforcementMode, + ExemptionCategory, + ParameterType, + PolicyType, + ResourceIdentityType, +) + +__all__ = [ + 'Alias', + 'AliasPath', + 'AliasPathMetadata', + 'AliasPattern', + 'DataEffect', + 'DataManifestCustomResourceFunctionDefinition', + 'DataPolicyManifest', + 'DataPolicyManifestListResult', + 'ErrorAdditionalInfo', + 'ErrorResponse', + 'Identity', + 'NonComplianceMessage', + 'ParameterDefinitionsValue', + 'ParameterDefinitionsValueMetadata', + 'ParameterValuesValue', + 'PolicyAssignment', + 'PolicyAssignmentListResult', + 'PolicyAssignmentUpdate', + 'PolicyDefinition', + 'PolicyDefinitionGroup', + 'PolicyDefinitionListResult', + 'PolicyDefinitionReference', + 'PolicyExemption', + 'PolicyExemptionListResult', + 'PolicySetDefinition', + 'PolicySetDefinitionListResult', + 'ResourceTypeAliases', + 'SystemData', + 'UserAssignedIdentitiesValue', + 'AliasPathAttributes', + 'AliasPathTokenType', + 'AliasPatternType', + 'AliasType', + 'CreatedByType', + 'EnforcementMode', + 'ExemptionCategory', + 'ParameterType', + 'PolicyType', + 'ResourceIdentityType', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_models.py new file mode 100644 index 000000000000..0d6a84886d19 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_models.py @@ -0,0 +1,1169 @@ +# 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.policy.v2021_06_01.models.AliasPath] + :param type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + "Mask". + :type type: str or ~azure.mgmt.resource.policy.v2021_06_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.policy.v2021_06_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.policy.v2021_06_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.policy.v2021_06_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.policy.v2021_06_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.policy.v2021_06_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.policy.v2021_06_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.policy.v2021_06_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 DataEffect(msrest.serialization.Model): + """The data effect definition. + + :param name: The data effect name. + :type name: str + :param details_schema: The data effect details schema. + :type details_schema: any + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'details_schema': {'key': 'detailsSchema', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + super(DataEffect, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.details_schema = kwargs.get('details_schema', None) + + +class DataManifestCustomResourceFunctionDefinition(msrest.serialization.Model): + """The custom resource function definition. + + :param name: The function name as it will appear in the policy rule. eg - 'vault'. + :type name: str + :param fully_qualified_resource_type: The fully qualified control plane resource type that this + function represents. eg - 'Microsoft.KeyVault/vaults'. + :type fully_qualified_resource_type: str + :param default_properties: The top-level properties that can be selected on the function's + output. eg - [ "name", "location" ] if vault().name and vault().location are supported. + :type default_properties: list[str] + :param allow_custom_properties: A value indicating whether the custom properties within the + property bag are allowed. Needs api-version to be specified in the policy rule eg - + vault('2019-06-01'). + :type allow_custom_properties: bool + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'fully_qualified_resource_type': {'key': 'fullyQualifiedResourceType', 'type': 'str'}, + 'default_properties': {'key': 'defaultProperties', 'type': '[str]'}, + 'allow_custom_properties': {'key': 'allowCustomProperties', 'type': 'bool'}, + } + + def __init__( + self, + **kwargs + ): + super(DataManifestCustomResourceFunctionDefinition, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.fully_qualified_resource_type = kwargs.get('fully_qualified_resource_type', None) + self.default_properties = kwargs.get('default_properties', None) + self.allow_custom_properties = kwargs.get('allow_custom_properties', None) + + +class DataPolicyManifest(msrest.serialization.Model): + """The data policy manifest. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the data policy manifest. + :vartype id: str + :ivar name: The name of the data policy manifest (it's the same as the Policy Mode). + :vartype name: str + :ivar type: The type of the resource (Microsoft.Authorization/dataPolicyManifests). + :vartype type: str + :param namespaces: The list of namespaces for the data policy manifest. + :type namespaces: list[str] + :param policy_mode: The policy mode of the data policy manifest. + :type policy_mode: str + :param is_built_in_only: A value indicating whether policy mode is allowed only in built-in + definitions. + :type is_built_in_only: bool + :param resource_type_aliases: An array of resource type aliases. + :type resource_type_aliases: + list[~azure.mgmt.resource.policy.v2021_06_01.models.ResourceTypeAliases] + :param effects: The effect definition. + :type effects: list[~azure.mgmt.resource.policy.v2021_06_01.models.DataEffect] + :param field_values: The non-alias field accessor values that can be used in the policy rule. + :type field_values: list[str] + :param standard: The standard resource functions (subscription and/or resourceGroup). + :type standard: list[str] + :param custom: An array of data manifest custom resource definition. + :type custom: + list[~azure.mgmt.resource.policy.v2021_06_01.models.DataManifestCustomResourceFunctionDefinition] + """ + + _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'}, + 'namespaces': {'key': 'properties.namespaces', 'type': '[str]'}, + 'policy_mode': {'key': 'properties.policyMode', 'type': 'str'}, + 'is_built_in_only': {'key': 'properties.isBuiltInOnly', 'type': 'bool'}, + 'resource_type_aliases': {'key': 'properties.resourceTypeAliases', 'type': '[ResourceTypeAliases]'}, + 'effects': {'key': 'properties.effects', 'type': '[DataEffect]'}, + 'field_values': {'key': 'properties.fieldValues', 'type': '[str]'}, + 'standard': {'key': 'properties.resourceFunctions.standard', 'type': '[str]'}, + 'custom': {'key': 'properties.resourceFunctions.custom', 'type': '[DataManifestCustomResourceFunctionDefinition]'}, + } + + def __init__( + self, + **kwargs + ): + super(DataPolicyManifest, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.namespaces = kwargs.get('namespaces', None) + self.policy_mode = kwargs.get('policy_mode', None) + self.is_built_in_only = kwargs.get('is_built_in_only', None) + self.resource_type_aliases = kwargs.get('resource_type_aliases', None) + self.effects = kwargs.get('effects', None) + self.field_values = kwargs.get('field_values', None) + self.standard = kwargs.get('standard', None) + self.custom = kwargs.get('custom', None) + + +class DataPolicyManifestListResult(msrest.serialization.Model): + """List of data policy manifests. + + :param value: An array of data policy manifests. + :type value: list[~azure.mgmt.resource.policy.v2021_06_01.models.DataPolicyManifest] + :param next_link: The URL to use for getting the next set of results. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DataPolicyManifest]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DataPolicyManifestListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', 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: any + """ + + _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.policy.v2021_06_01.models.ErrorResponse] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.resource.policy.v2021_06_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 Identity(msrest.serialization.Model): + """Identity for the resource. Policy assignments support a maximum of one identity. That is either a system assigned identity or a single user assigned identity. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of the resource identity. This property will only be + provided for a system assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of the resource identity. This property will only be provided + for a system assigned identity. + :vartype tenant_id: str + :param type: The identity type. This is the only required field when adding a system or user + assigned identity to a resource. Possible values include: "SystemAssigned", "UserAssigned", + "None". + :type type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ResourceIdentityType + :param user_assigned_identities: The user identity associated with the policy. 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.policy.v2021_06_01.models.UserAssignedIdentitiesValue] + """ + + _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': '{UserAssignedIdentitiesValue}'}, + } + + 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 NonComplianceMessage(msrest.serialization.Model): + """A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' error messages and on resource's non-compliant compliance results. + + All required parameters must be populated in order to send to Azure. + + :param message: Required. A message that describes why a resource is non-compliant with the + policy. This is shown in 'deny' error messages and on resource's non-compliant compliance + results. + :type message: str + :param policy_definition_reference_id: The policy definition reference ID within a policy set + definition the message is intended for. This is only applicable if the policy assignment + assigns a policy set definition. If this is not provided the message applies to all policies + assigned by this policy assignment. + :type policy_definition_reference_id: str + """ + + _validation = { + 'message': {'required': True}, + } + + _attribute_map = { + 'message': {'key': 'message', 'type': 'str'}, + 'policy_definition_reference_id': {'key': 'policyDefinitionReferenceId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(NonComplianceMessage, self).__init__(**kwargs) + self.message = kwargs['message'] + self.policy_definition_reference_id = kwargs.get('policy_definition_reference_id', None) + + +class ParameterDefinitionsValue(msrest.serialization.Model): + """The definition of a parameter that can be provided to the policy. + + :param type: The data type of the parameter. Possible values include: "String", "Array", + "Object", "Boolean", "Integer", "Float", "DateTime". + :type type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterType + :param allowed_values: The allowed values for the parameter. + :type allowed_values: list[any] + :param default_value: The default value for the parameter if no value is provided. + :type default_value: any + :param metadata: General metadata for the parameter. + :type metadata: + ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterDefinitionsValueMetadata + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'allowed_values': {'key': 'allowedValues', 'type': '[object]'}, + 'default_value': {'key': 'defaultValue', 'type': 'object'}, + 'metadata': {'key': 'metadata', 'type': 'ParameterDefinitionsValueMetadata'}, + } + + def __init__( + self, + **kwargs + ): + super(ParameterDefinitionsValue, self).__init__(**kwargs) + self.type = kwargs.get('type', None) + self.allowed_values = kwargs.get('allowed_values', None) + self.default_value = kwargs.get('default_value', None) + self.metadata = kwargs.get('metadata', None) + + +class ParameterDefinitionsValueMetadata(msrest.serialization.Model): + """General metadata for the parameter. + + :param additional_properties: Unmatched properties from the message are deserialized to this + collection. + :type additional_properties: dict[str, any] + :param display_name: The display name for the parameter. + :type display_name: str + :param description: The description of the parameter. + :type description: str + :param strong_type: Used when assigning the policy definition through the portal. Provides a + context aware list of values for the user to choose from. + :type strong_type: str + :param assign_permissions: Set to true to have Azure portal create role assignments on the + resource ID or resource scope value of this parameter during policy assignment. This property + is useful in case you wish to assign permissions outside the assignment scope. + :type assign_permissions: bool + """ + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'strong_type': {'key': 'strongType', 'type': 'str'}, + 'assign_permissions': {'key': 'assignPermissions', 'type': 'bool'}, + } + + def __init__( + self, + **kwargs + ): + super(ParameterDefinitionsValueMetadata, self).__init__(**kwargs) + self.additional_properties = kwargs.get('additional_properties', None) + self.display_name = kwargs.get('display_name', None) + self.description = kwargs.get('description', None) + self.strong_type = kwargs.get('strong_type', None) + self.assign_permissions = kwargs.get('assign_permissions', None) + + +class ParameterValuesValue(msrest.serialization.Model): + """The value of a parameter. + + :param value: The value of the parameter. + :type value: any + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + super(ParameterValuesValue, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + + +class PolicyAssignment(msrest.serialization.Model): + """The policy assignment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the policy assignment. + :vartype id: str + :ivar type: The type of the policy assignment. + :vartype type: str + :ivar name: The name of the policy assignment. + :vartype name: str + :param location: The location of the policy assignment. Only required when utilizing managed + identity. + :type location: str + :param identity: The managed identity associated with the policy assignment. + :type identity: ~azure.mgmt.resource.policy.v2021_06_01.models.Identity + :ivar system_data: The system metadata relating to this resource. + :vartype system_data: ~azure.mgmt.resource.policy.v2021_06_01.models.SystemData + :param display_name: The display name of the policy assignment. + :type display_name: str + :param policy_definition_id: The ID of the policy definition or policy set definition being + assigned. + :type policy_definition_id: str + :ivar scope: The scope for the policy assignment. + :vartype scope: str + :param not_scopes: The policy's excluded scopes. + :type not_scopes: list[str] + :param parameters: The parameter values for the assigned policy rule. The keys are the + parameter names. + :type parameters: dict[str, + ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterValuesValue] + :param description: This message will be part of response in case of policy violation. + :type description: str + :param metadata: The policy assignment metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :type metadata: any + :param enforcement_mode: The policy assignment enforcement mode. Possible values are Default + and DoNotEnforce. Possible values include: "Default", "DoNotEnforce". Default value: "Default". + :type enforcement_mode: str or ~azure.mgmt.resource.policy.v2021_06_01.models.EnforcementMode + :param non_compliance_messages: The messages that describe why a resource is non-compliant with + the policy. + :type non_compliance_messages: + list[~azure.mgmt.resource.policy.v2021_06_01.models.NonComplianceMessage] + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'system_data': {'readonly': True}, + 'scope': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'str'}, + 'not_scopes': {'key': 'properties.notScopes', 'type': '[str]'}, + 'parameters': {'key': 'properties.parameters', 'type': '{ParameterValuesValue}'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'metadata': {'key': 'properties.metadata', 'type': 'object'}, + 'enforcement_mode': {'key': 'properties.enforcementMode', 'type': 'str'}, + 'non_compliance_messages': {'key': 'properties.nonComplianceMessages', 'type': '[NonComplianceMessage]'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyAssignment, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.location = kwargs.get('location', None) + self.identity = kwargs.get('identity', None) + self.system_data = None + self.display_name = kwargs.get('display_name', None) + self.policy_definition_id = kwargs.get('policy_definition_id', None) + self.scope = None + self.not_scopes = kwargs.get('not_scopes', None) + self.parameters = kwargs.get('parameters', None) + self.description = kwargs.get('description', None) + self.metadata = kwargs.get('metadata', None) + self.enforcement_mode = kwargs.get('enforcement_mode', "Default") + self.non_compliance_messages = kwargs.get('non_compliance_messages', None) + + +class PolicyAssignmentListResult(msrest.serialization.Model): + """List of policy assignments. + + :param value: An array of policy assignments. + :type value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment] + :param next_link: The URL to use for getting the next set of results. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyAssignmentListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicyAssignmentUpdate(msrest.serialization.Model): + """PolicyAssignmentUpdate. + + :param location: The location of the policy assignment. Only required when utilizing managed + identity. + :type location: str + :param identity: The managed identity associated with the policy assignment. + :type identity: ~azure.mgmt.resource.policy.v2021_06_01.models.Identity + """ + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyAssignmentUpdate, self).__init__(**kwargs) + self.location = kwargs.get('location', None) + self.identity = kwargs.get('identity', None) + + +class PolicyDefinition(msrest.serialization.Model): + """The policy definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the policy definition. + :vartype id: str + :ivar name: The name of the policy definition. + :vartype name: str + :ivar type: The type of the resource (Microsoft.Authorization/policyDefinitions). + :vartype type: str + :ivar system_data: The system metadata relating to this resource. + :vartype system_data: ~azure.mgmt.resource.policy.v2021_06_01.models.SystemData + :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + :type policy_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyType + :param mode: The policy definition mode. Some examples are All, Indexed, + Microsoft.KeyVault.Data. + :type mode: str + :param display_name: The display name of the policy definition. + :type display_name: str + :param description: The policy definition description. + :type description: str + :param policy_rule: The policy rule. + :type policy_rule: any + :param metadata: The policy definition metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :type metadata: any + :param parameters: The parameter definitions for parameters used in the policy rule. The keys + are the parameter names. + :type parameters: dict[str, + ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterDefinitionsValue] + """ + + _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'}, + 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, + 'mode': {'key': 'properties.mode', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, + 'metadata': {'key': 'properties.metadata', 'type': 'object'}, + 'parameters': {'key': 'properties.parameters', 'type': '{ParameterDefinitionsValue}'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + self.policy_type = kwargs.get('policy_type', None) + self.mode = kwargs.get('mode', "Indexed") + self.display_name = kwargs.get('display_name', None) + self.description = kwargs.get('description', None) + self.policy_rule = kwargs.get('policy_rule', None) + self.metadata = kwargs.get('metadata', None) + self.parameters = kwargs.get('parameters', None) + + +class PolicyDefinitionGroup(msrest.serialization.Model): + """The policy definition group. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The name of the group. + :type name: str + :param display_name: The group's display name. + :type display_name: str + :param category: The group's category. + :type category: str + :param description: The group's description. + :type description: str + :param additional_metadata_id: A resource ID of a resource that contains additional metadata + about the group. + :type additional_metadata_id: str + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'category': {'key': 'category', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'additional_metadata_id': {'key': 'additionalMetadataId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyDefinitionGroup, self).__init__(**kwargs) + self.name = kwargs['name'] + self.display_name = kwargs.get('display_name', None) + self.category = kwargs.get('category', None) + self.description = kwargs.get('description', None) + self.additional_metadata_id = kwargs.get('additional_metadata_id', None) + + +class PolicyDefinitionListResult(msrest.serialization.Model): + """List of policy definitions. + + :param value: An array of policy definitions. + :type value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition] + :param next_link: The URL to use for getting the next set of results. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyDefinitionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicyDefinitionReference(msrest.serialization.Model): + """The policy definition reference. + + All required parameters must be populated in order to send to Azure. + + :param policy_definition_id: Required. The ID of the policy definition or policy set + definition. + :type policy_definition_id: str + :param parameters: The parameter values for the referenced policy rule. The keys are the + parameter names. + :type parameters: dict[str, + ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterValuesValue] + :param policy_definition_reference_id: A unique id (within the policy set definition) for this + policy definition reference. + :type policy_definition_reference_id: str + :param group_names: The name of the groups that this policy definition reference belongs to. + :type group_names: list[str] + """ + + _validation = { + 'policy_definition_id': {'required': True}, + } + + _attribute_map = { + 'policy_definition_id': {'key': 'policyDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': '{ParameterValuesValue}'}, + 'policy_definition_reference_id': {'key': 'policyDefinitionReferenceId', 'type': 'str'}, + 'group_names': {'key': 'groupNames', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyDefinitionReference, self).__init__(**kwargs) + self.policy_definition_id = kwargs['policy_definition_id'] + self.parameters = kwargs.get('parameters', None) + self.policy_definition_reference_id = kwargs.get('policy_definition_reference_id', None) + self.group_names = kwargs.get('group_names', None) + + +class PolicyExemption(msrest.serialization.Model): + """The policy exemption. + + 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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resource.policy.v2021_06_01.models.SystemData + :ivar id: The ID of the policy exemption. + :vartype id: str + :ivar name: The name of the policy exemption. + :vartype name: str + :ivar type: The type of the resource (Microsoft.Authorization/policyExemptions). + :vartype type: str + :param policy_assignment_id: Required. The ID of the policy assignment that is being exempted. + :type policy_assignment_id: str + :param policy_definition_reference_ids: The policy definition reference ID list when the + associated policy assignment is an assignment of a policy set definition. + :type policy_definition_reference_ids: list[str] + :param exemption_category: Required. The policy exemption category. Possible values are Waiver + and Mitigated. Possible values include: "Waiver", "Mitigated". + :type exemption_category: str or + ~azure.mgmt.resource.policy.v2021_06_01.models.ExemptionCategory + :param expires_on: The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) + of the policy exemption. + :type expires_on: ~datetime.datetime + :param display_name: The display name of the policy exemption. + :type display_name: str + :param description: The description of the policy exemption. + :type description: str + :param metadata: The policy exemption metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :type metadata: any + """ + + _validation = { + 'system_data': {'readonly': True}, + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'policy_assignment_id': {'required': True}, + 'exemption_category': {'required': True}, + } + + _attribute_map = { + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'policy_assignment_id': {'key': 'properties.policyAssignmentId', 'type': 'str'}, + 'policy_definition_reference_ids': {'key': 'properties.policyDefinitionReferenceIds', 'type': '[str]'}, + 'exemption_category': {'key': 'properties.exemptionCategory', 'type': 'str'}, + 'expires_on': {'key': 'properties.expiresOn', 'type': 'iso-8601'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'metadata': {'key': 'properties.metadata', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyExemption, self).__init__(**kwargs) + self.system_data = None + self.id = None + self.name = None + self.type = None + self.policy_assignment_id = kwargs['policy_assignment_id'] + self.policy_definition_reference_ids = kwargs.get('policy_definition_reference_ids', None) + self.exemption_category = kwargs['exemption_category'] + self.expires_on = kwargs.get('expires_on', None) + self.display_name = kwargs.get('display_name', None) + self.description = kwargs.get('description', None) + self.metadata = kwargs.get('metadata', None) + + +class PolicyExemptionListResult(msrest.serialization.Model): + """List of policy exemptions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: An array of policy exemptions. + :type value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption] + :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': '[PolicyExemption]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyExemptionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class PolicySetDefinition(msrest.serialization.Model): + """The policy set definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the policy set definition. + :vartype id: str + :ivar name: The name of the policy set definition. + :vartype name: str + :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). + :vartype type: str + :ivar system_data: The system metadata relating to this resource. + :vartype system_data: ~azure.mgmt.resource.policy.v2021_06_01.models.SystemData + :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + :type policy_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyType + :param display_name: The display name of the policy set definition. + :type display_name: str + :param description: The policy set definition description. + :type description: str + :param metadata: The policy set definition metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :type metadata: any + :param parameters: The policy set definition parameters that can be used in policy definition + references. + :type parameters: dict[str, + ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterDefinitionsValue] + :param policy_definitions: An array of policy definition references. + :type policy_definitions: + list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionReference] + :param policy_definition_groups: The metadata describing groups of policy definition references + within the policy set definition. + :type policy_definition_groups: + list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionGroup] + """ + + _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'}, + 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'metadata': {'key': 'properties.metadata', 'type': 'object'}, + 'parameters': {'key': 'properties.parameters', 'type': '{ParameterDefinitionsValue}'}, + 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, + 'policy_definition_groups': {'key': 'properties.policyDefinitionGroups', 'type': '[PolicyDefinitionGroup]'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicySetDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + self.policy_type = kwargs.get('policy_type', None) + self.display_name = kwargs.get('display_name', None) + self.description = kwargs.get('description', None) + self.metadata = kwargs.get('metadata', None) + self.parameters = kwargs.get('parameters', None) + self.policy_definitions = kwargs.get('policy_definitions', None) + self.policy_definition_groups = kwargs.get('policy_definition_groups', None) + + +class PolicySetDefinitionListResult(msrest.serialization.Model): + """List of policy set definitions. + + :param value: An array of policy set definitions. + :type value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition] + :param next_link: The URL to use for getting the next set of results. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicySetDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicySetDefinitionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class ResourceTypeAliases(msrest.serialization.Model): + """The resource type aliases definition. + + :param resource_type: The resource type name. + :type resource_type: str + :param aliases: The aliases for property names. + :type aliases: list[~azure.mgmt.resource.policy.v2021_06_01.models.Alias] + """ + + _attribute_map = { + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'aliases': {'key': 'aliases', 'type': '[Alias]'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceTypeAliases, self).__init__(**kwargs) + self.resource_type = kwargs.get('resource_type', None) + self.aliases = kwargs.get('aliases', None) + + +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.policy.v2021_06_01.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.policy.v2021_06_01.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 UserAssignedIdentitiesValue(msrest.serialization.Model): + """UserAssignedIdentitiesValue. + + 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(UserAssignedIdentitiesValue, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_models_py3.py new file mode 100644 index 000000000000..c376b7acdcb6 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_models_py3.py @@ -0,0 +1,1297 @@ +# 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 Any, Dict, List, Optional, Union + +import msrest.serialization + +from ._policy_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.policy.v2021_06_01.models.AliasPath] + :param type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + "Mask". + :type type: str or ~azure.mgmt.resource.policy.v2021_06_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.policy.v2021_06_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.policy.v2021_06_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.policy.v2021_06_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.policy.v2021_06_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.policy.v2021_06_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.policy.v2021_06_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.policy.v2021_06_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 DataEffect(msrest.serialization.Model): + """The data effect definition. + + :param name: The data effect name. + :type name: str + :param details_schema: The data effect details schema. + :type details_schema: any + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'details_schema': {'key': 'detailsSchema', 'type': 'object'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + details_schema: Optional[Any] = None, + **kwargs + ): + super(DataEffect, self).__init__(**kwargs) + self.name = name + self.details_schema = details_schema + + +class DataManifestCustomResourceFunctionDefinition(msrest.serialization.Model): + """The custom resource function definition. + + :param name: The function name as it will appear in the policy rule. eg - 'vault'. + :type name: str + :param fully_qualified_resource_type: The fully qualified control plane resource type that this + function represents. eg - 'Microsoft.KeyVault/vaults'. + :type fully_qualified_resource_type: str + :param default_properties: The top-level properties that can be selected on the function's + output. eg - [ "name", "location" ] if vault().name and vault().location are supported. + :type default_properties: list[str] + :param allow_custom_properties: A value indicating whether the custom properties within the + property bag are allowed. Needs api-version to be specified in the policy rule eg - + vault('2019-06-01'). + :type allow_custom_properties: bool + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'fully_qualified_resource_type': {'key': 'fullyQualifiedResourceType', 'type': 'str'}, + 'default_properties': {'key': 'defaultProperties', 'type': '[str]'}, + 'allow_custom_properties': {'key': 'allowCustomProperties', 'type': 'bool'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + fully_qualified_resource_type: Optional[str] = None, + default_properties: Optional[List[str]] = None, + allow_custom_properties: Optional[bool] = None, + **kwargs + ): + super(DataManifestCustomResourceFunctionDefinition, self).__init__(**kwargs) + self.name = name + self.fully_qualified_resource_type = fully_qualified_resource_type + self.default_properties = default_properties + self.allow_custom_properties = allow_custom_properties + + +class DataPolicyManifest(msrest.serialization.Model): + """The data policy manifest. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the data policy manifest. + :vartype id: str + :ivar name: The name of the data policy manifest (it's the same as the Policy Mode). + :vartype name: str + :ivar type: The type of the resource (Microsoft.Authorization/dataPolicyManifests). + :vartype type: str + :param namespaces: The list of namespaces for the data policy manifest. + :type namespaces: list[str] + :param policy_mode: The policy mode of the data policy manifest. + :type policy_mode: str + :param is_built_in_only: A value indicating whether policy mode is allowed only in built-in + definitions. + :type is_built_in_only: bool + :param resource_type_aliases: An array of resource type aliases. + :type resource_type_aliases: + list[~azure.mgmt.resource.policy.v2021_06_01.models.ResourceTypeAliases] + :param effects: The effect definition. + :type effects: list[~azure.mgmt.resource.policy.v2021_06_01.models.DataEffect] + :param field_values: The non-alias field accessor values that can be used in the policy rule. + :type field_values: list[str] + :param standard: The standard resource functions (subscription and/or resourceGroup). + :type standard: list[str] + :param custom: An array of data manifest custom resource definition. + :type custom: + list[~azure.mgmt.resource.policy.v2021_06_01.models.DataManifestCustomResourceFunctionDefinition] + """ + + _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'}, + 'namespaces': {'key': 'properties.namespaces', 'type': '[str]'}, + 'policy_mode': {'key': 'properties.policyMode', 'type': 'str'}, + 'is_built_in_only': {'key': 'properties.isBuiltInOnly', 'type': 'bool'}, + 'resource_type_aliases': {'key': 'properties.resourceTypeAliases', 'type': '[ResourceTypeAliases]'}, + 'effects': {'key': 'properties.effects', 'type': '[DataEffect]'}, + 'field_values': {'key': 'properties.fieldValues', 'type': '[str]'}, + 'standard': {'key': 'properties.resourceFunctions.standard', 'type': '[str]'}, + 'custom': {'key': 'properties.resourceFunctions.custom', 'type': '[DataManifestCustomResourceFunctionDefinition]'}, + } + + def __init__( + self, + *, + namespaces: Optional[List[str]] = None, + policy_mode: Optional[str] = None, + is_built_in_only: Optional[bool] = None, + resource_type_aliases: Optional[List["ResourceTypeAliases"]] = None, + effects: Optional[List["DataEffect"]] = None, + field_values: Optional[List[str]] = None, + standard: Optional[List[str]] = None, + custom: Optional[List["DataManifestCustomResourceFunctionDefinition"]] = None, + **kwargs + ): + super(DataPolicyManifest, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.namespaces = namespaces + self.policy_mode = policy_mode + self.is_built_in_only = is_built_in_only + self.resource_type_aliases = resource_type_aliases + self.effects = effects + self.field_values = field_values + self.standard = standard + self.custom = custom + + +class DataPolicyManifestListResult(msrest.serialization.Model): + """List of data policy manifests. + + :param value: An array of data policy manifests. + :type value: list[~azure.mgmt.resource.policy.v2021_06_01.models.DataPolicyManifest] + :param next_link: The URL to use for getting the next set of results. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DataPolicyManifest]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DataPolicyManifest"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(DataPolicyManifestListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +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: any + """ + + _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.policy.v2021_06_01.models.ErrorResponse] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.resource.policy.v2021_06_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 Identity(msrest.serialization.Model): + """Identity for the resource. Policy assignments support a maximum of one identity. That is either a system assigned identity or a single user assigned identity. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of the resource identity. This property will only be + provided for a system assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of the resource identity. This property will only be provided + for a system assigned identity. + :vartype tenant_id: str + :param type: The identity type. This is the only required field when adding a system or user + assigned identity to a resource. Possible values include: "SystemAssigned", "UserAssigned", + "None". + :type type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ResourceIdentityType + :param user_assigned_identities: The user identity associated with the policy. 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.policy.v2021_06_01.models.UserAssignedIdentitiesValue] + """ + + _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': '{UserAssignedIdentitiesValue}'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "UserAssignedIdentitiesValue"]] = 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 NonComplianceMessage(msrest.serialization.Model): + """A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' error messages and on resource's non-compliant compliance results. + + All required parameters must be populated in order to send to Azure. + + :param message: Required. A message that describes why a resource is non-compliant with the + policy. This is shown in 'deny' error messages and on resource's non-compliant compliance + results. + :type message: str + :param policy_definition_reference_id: The policy definition reference ID within a policy set + definition the message is intended for. This is only applicable if the policy assignment + assigns a policy set definition. If this is not provided the message applies to all policies + assigned by this policy assignment. + :type policy_definition_reference_id: str + """ + + _validation = { + 'message': {'required': True}, + } + + _attribute_map = { + 'message': {'key': 'message', 'type': 'str'}, + 'policy_definition_reference_id': {'key': 'policyDefinitionReferenceId', 'type': 'str'}, + } + + def __init__( + self, + *, + message: str, + policy_definition_reference_id: Optional[str] = None, + **kwargs + ): + super(NonComplianceMessage, self).__init__(**kwargs) + self.message = message + self.policy_definition_reference_id = policy_definition_reference_id + + +class ParameterDefinitionsValue(msrest.serialization.Model): + """The definition of a parameter that can be provided to the policy. + + :param type: The data type of the parameter. Possible values include: "String", "Array", + "Object", "Boolean", "Integer", "Float", "DateTime". + :type type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterType + :param allowed_values: The allowed values for the parameter. + :type allowed_values: list[any] + :param default_value: The default value for the parameter if no value is provided. + :type default_value: any + :param metadata: General metadata for the parameter. + :type metadata: + ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterDefinitionsValueMetadata + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'allowed_values': {'key': 'allowedValues', 'type': '[object]'}, + 'default_value': {'key': 'defaultValue', 'type': 'object'}, + 'metadata': {'key': 'metadata', 'type': 'ParameterDefinitionsValueMetadata'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "ParameterType"]] = None, + allowed_values: Optional[List[Any]] = None, + default_value: Optional[Any] = None, + metadata: Optional["ParameterDefinitionsValueMetadata"] = None, + **kwargs + ): + super(ParameterDefinitionsValue, self).__init__(**kwargs) + self.type = type + self.allowed_values = allowed_values + self.default_value = default_value + self.metadata = metadata + + +class ParameterDefinitionsValueMetadata(msrest.serialization.Model): + """General metadata for the parameter. + + :param additional_properties: Unmatched properties from the message are deserialized to this + collection. + :type additional_properties: dict[str, any] + :param display_name: The display name for the parameter. + :type display_name: str + :param description: The description of the parameter. + :type description: str + :param strong_type: Used when assigning the policy definition through the portal. Provides a + context aware list of values for the user to choose from. + :type strong_type: str + :param assign_permissions: Set to true to have Azure portal create role assignments on the + resource ID or resource scope value of this parameter during policy assignment. This property + is useful in case you wish to assign permissions outside the assignment scope. + :type assign_permissions: bool + """ + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'strong_type': {'key': 'strongType', 'type': 'str'}, + 'assign_permissions': {'key': 'assignPermissions', 'type': 'bool'}, + } + + def __init__( + self, + *, + additional_properties: Optional[Dict[str, Any]] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + strong_type: Optional[str] = None, + assign_permissions: Optional[bool] = None, + **kwargs + ): + super(ParameterDefinitionsValueMetadata, self).__init__(**kwargs) + self.additional_properties = additional_properties + self.display_name = display_name + self.description = description + self.strong_type = strong_type + self.assign_permissions = assign_permissions + + +class ParameterValuesValue(msrest.serialization.Model): + """The value of a parameter. + + :param value: The value of the parameter. + :type value: any + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': 'object'}, + } + + def __init__( + self, + *, + value: Optional[Any] = None, + **kwargs + ): + super(ParameterValuesValue, self).__init__(**kwargs) + self.value = value + + +class PolicyAssignment(msrest.serialization.Model): + """The policy assignment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the policy assignment. + :vartype id: str + :ivar type: The type of the policy assignment. + :vartype type: str + :ivar name: The name of the policy assignment. + :vartype name: str + :param location: The location of the policy assignment. Only required when utilizing managed + identity. + :type location: str + :param identity: The managed identity associated with the policy assignment. + :type identity: ~azure.mgmt.resource.policy.v2021_06_01.models.Identity + :ivar system_data: The system metadata relating to this resource. + :vartype system_data: ~azure.mgmt.resource.policy.v2021_06_01.models.SystemData + :param display_name: The display name of the policy assignment. + :type display_name: str + :param policy_definition_id: The ID of the policy definition or policy set definition being + assigned. + :type policy_definition_id: str + :ivar scope: The scope for the policy assignment. + :vartype scope: str + :param not_scopes: The policy's excluded scopes. + :type not_scopes: list[str] + :param parameters: The parameter values for the assigned policy rule. The keys are the + parameter names. + :type parameters: dict[str, + ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterValuesValue] + :param description: This message will be part of response in case of policy violation. + :type description: str + :param metadata: The policy assignment metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :type metadata: any + :param enforcement_mode: The policy assignment enforcement mode. Possible values are Default + and DoNotEnforce. Possible values include: "Default", "DoNotEnforce". Default value: "Default". + :type enforcement_mode: str or ~azure.mgmt.resource.policy.v2021_06_01.models.EnforcementMode + :param non_compliance_messages: The messages that describe why a resource is non-compliant with + the policy. + :type non_compliance_messages: + list[~azure.mgmt.resource.policy.v2021_06_01.models.NonComplianceMessage] + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'system_data': {'readonly': True}, + 'scope': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'str'}, + 'not_scopes': {'key': 'properties.notScopes', 'type': '[str]'}, + 'parameters': {'key': 'properties.parameters', 'type': '{ParameterValuesValue}'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'metadata': {'key': 'properties.metadata', 'type': 'object'}, + 'enforcement_mode': {'key': 'properties.enforcementMode', 'type': 'str'}, + 'non_compliance_messages': {'key': 'properties.nonComplianceMessages', 'type': '[NonComplianceMessage]'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + identity: Optional["Identity"] = None, + display_name: Optional[str] = None, + policy_definition_id: Optional[str] = None, + not_scopes: Optional[List[str]] = None, + parameters: Optional[Dict[str, "ParameterValuesValue"]] = None, + description: Optional[str] = None, + metadata: Optional[Any] = None, + enforcement_mode: Optional[Union[str, "EnforcementMode"]] = "Default", + non_compliance_messages: Optional[List["NonComplianceMessage"]] = None, + **kwargs + ): + super(PolicyAssignment, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.location = location + self.identity = identity + self.system_data = None + self.display_name = display_name + self.policy_definition_id = policy_definition_id + self.scope = None + self.not_scopes = not_scopes + self.parameters = parameters + self.description = description + self.metadata = metadata + self.enforcement_mode = enforcement_mode + self.non_compliance_messages = non_compliance_messages + + +class PolicyAssignmentListResult(msrest.serialization.Model): + """List of policy assignments. + + :param value: An array of policy assignments. + :type value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment] + :param next_link: The URL to use for getting the next set of results. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicyAssignment"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicyAssignmentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicyAssignmentUpdate(msrest.serialization.Model): + """PolicyAssignmentUpdate. + + :param location: The location of the policy assignment. Only required when utilizing managed + identity. + :type location: str + :param identity: The managed identity associated with the policy assignment. + :type identity: ~azure.mgmt.resource.policy.v2021_06_01.models.Identity + """ + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + identity: Optional["Identity"] = None, + **kwargs + ): + super(PolicyAssignmentUpdate, self).__init__(**kwargs) + self.location = location + self.identity = identity + + +class PolicyDefinition(msrest.serialization.Model): + """The policy definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the policy definition. + :vartype id: str + :ivar name: The name of the policy definition. + :vartype name: str + :ivar type: The type of the resource (Microsoft.Authorization/policyDefinitions). + :vartype type: str + :ivar system_data: The system metadata relating to this resource. + :vartype system_data: ~azure.mgmt.resource.policy.v2021_06_01.models.SystemData + :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + :type policy_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyType + :param mode: The policy definition mode. Some examples are All, Indexed, + Microsoft.KeyVault.Data. + :type mode: str + :param display_name: The display name of the policy definition. + :type display_name: str + :param description: The policy definition description. + :type description: str + :param policy_rule: The policy rule. + :type policy_rule: any + :param metadata: The policy definition metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :type metadata: any + :param parameters: The parameter definitions for parameters used in the policy rule. The keys + are the parameter names. + :type parameters: dict[str, + ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterDefinitionsValue] + """ + + _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'}, + 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, + 'mode': {'key': 'properties.mode', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, + 'metadata': {'key': 'properties.metadata', 'type': 'object'}, + 'parameters': {'key': 'properties.parameters', 'type': '{ParameterDefinitionsValue}'}, + } + + def __init__( + self, + *, + policy_type: Optional[Union[str, "PolicyType"]] = None, + mode: Optional[str] = "Indexed", + display_name: Optional[str] = None, + description: Optional[str] = None, + policy_rule: Optional[Any] = None, + metadata: Optional[Any] = None, + parameters: Optional[Dict[str, "ParameterDefinitionsValue"]] = None, + **kwargs + ): + super(PolicyDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + self.policy_type = policy_type + self.mode = mode + self.display_name = display_name + self.description = description + self.policy_rule = policy_rule + self.metadata = metadata + self.parameters = parameters + + +class PolicyDefinitionGroup(msrest.serialization.Model): + """The policy definition group. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The name of the group. + :type name: str + :param display_name: The group's display name. + :type display_name: str + :param category: The group's category. + :type category: str + :param description: The group's description. + :type description: str + :param additional_metadata_id: A resource ID of a resource that contains additional metadata + about the group. + :type additional_metadata_id: str + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'category': {'key': 'category', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'additional_metadata_id': {'key': 'additionalMetadataId', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + display_name: Optional[str] = None, + category: Optional[str] = None, + description: Optional[str] = None, + additional_metadata_id: Optional[str] = None, + **kwargs + ): + super(PolicyDefinitionGroup, self).__init__(**kwargs) + self.name = name + self.display_name = display_name + self.category = category + self.description = description + self.additional_metadata_id = additional_metadata_id + + +class PolicyDefinitionListResult(msrest.serialization.Model): + """List of policy definitions. + + :param value: An array of policy definitions. + :type value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition] + :param next_link: The URL to use for getting the next set of results. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicyDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicyDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicyDefinitionReference(msrest.serialization.Model): + """The policy definition reference. + + All required parameters must be populated in order to send to Azure. + + :param policy_definition_id: Required. The ID of the policy definition or policy set + definition. + :type policy_definition_id: str + :param parameters: The parameter values for the referenced policy rule. The keys are the + parameter names. + :type parameters: dict[str, + ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterValuesValue] + :param policy_definition_reference_id: A unique id (within the policy set definition) for this + policy definition reference. + :type policy_definition_reference_id: str + :param group_names: The name of the groups that this policy definition reference belongs to. + :type group_names: list[str] + """ + + _validation = { + 'policy_definition_id': {'required': True}, + } + + _attribute_map = { + 'policy_definition_id': {'key': 'policyDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': '{ParameterValuesValue}'}, + 'policy_definition_reference_id': {'key': 'policyDefinitionReferenceId', 'type': 'str'}, + 'group_names': {'key': 'groupNames', 'type': '[str]'}, + } + + def __init__( + self, + *, + policy_definition_id: str, + parameters: Optional[Dict[str, "ParameterValuesValue"]] = None, + policy_definition_reference_id: Optional[str] = None, + group_names: Optional[List[str]] = None, + **kwargs + ): + super(PolicyDefinitionReference, self).__init__(**kwargs) + self.policy_definition_id = policy_definition_id + self.parameters = parameters + self.policy_definition_reference_id = policy_definition_reference_id + self.group_names = group_names + + +class PolicyExemption(msrest.serialization.Model): + """The policy exemption. + + 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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resource.policy.v2021_06_01.models.SystemData + :ivar id: The ID of the policy exemption. + :vartype id: str + :ivar name: The name of the policy exemption. + :vartype name: str + :ivar type: The type of the resource (Microsoft.Authorization/policyExemptions). + :vartype type: str + :param policy_assignment_id: Required. The ID of the policy assignment that is being exempted. + :type policy_assignment_id: str + :param policy_definition_reference_ids: The policy definition reference ID list when the + associated policy assignment is an assignment of a policy set definition. + :type policy_definition_reference_ids: list[str] + :param exemption_category: Required. The policy exemption category. Possible values are Waiver + and Mitigated. Possible values include: "Waiver", "Mitigated". + :type exemption_category: str or + ~azure.mgmt.resource.policy.v2021_06_01.models.ExemptionCategory + :param expires_on: The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) + of the policy exemption. + :type expires_on: ~datetime.datetime + :param display_name: The display name of the policy exemption. + :type display_name: str + :param description: The description of the policy exemption. + :type description: str + :param metadata: The policy exemption metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :type metadata: any + """ + + _validation = { + 'system_data': {'readonly': True}, + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'policy_assignment_id': {'required': True}, + 'exemption_category': {'required': True}, + } + + _attribute_map = { + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'policy_assignment_id': {'key': 'properties.policyAssignmentId', 'type': 'str'}, + 'policy_definition_reference_ids': {'key': 'properties.policyDefinitionReferenceIds', 'type': '[str]'}, + 'exemption_category': {'key': 'properties.exemptionCategory', 'type': 'str'}, + 'expires_on': {'key': 'properties.expiresOn', 'type': 'iso-8601'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'metadata': {'key': 'properties.metadata', 'type': 'object'}, + } + + def __init__( + self, + *, + policy_assignment_id: str, + exemption_category: Union[str, "ExemptionCategory"], + policy_definition_reference_ids: Optional[List[str]] = None, + expires_on: Optional[datetime.datetime] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + metadata: Optional[Any] = None, + **kwargs + ): + super(PolicyExemption, self).__init__(**kwargs) + self.system_data = None + self.id = None + self.name = None + self.type = None + self.policy_assignment_id = policy_assignment_id + self.policy_definition_reference_ids = policy_definition_reference_ids + self.exemption_category = exemption_category + self.expires_on = expires_on + self.display_name = display_name + self.description = description + self.metadata = metadata + + +class PolicyExemptionListResult(msrest.serialization.Model): + """List of policy exemptions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: An array of policy exemptions. + :type value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption] + :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': '[PolicyExemption]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicyExemption"]] = None, + **kwargs + ): + super(PolicyExemptionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class PolicySetDefinition(msrest.serialization.Model): + """The policy set definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the policy set definition. + :vartype id: str + :ivar name: The name of the policy set definition. + :vartype name: str + :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). + :vartype type: str + :ivar system_data: The system metadata relating to this resource. + :vartype system_data: ~azure.mgmt.resource.policy.v2021_06_01.models.SystemData + :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + :type policy_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyType + :param display_name: The display name of the policy set definition. + :type display_name: str + :param description: The policy set definition description. + :type description: str + :param metadata: The policy set definition metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :type metadata: any + :param parameters: The policy set definition parameters that can be used in policy definition + references. + :type parameters: dict[str, + ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterDefinitionsValue] + :param policy_definitions: An array of policy definition references. + :type policy_definitions: + list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionReference] + :param policy_definition_groups: The metadata describing groups of policy definition references + within the policy set definition. + :type policy_definition_groups: + list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionGroup] + """ + + _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'}, + 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'metadata': {'key': 'properties.metadata', 'type': 'object'}, + 'parameters': {'key': 'properties.parameters', 'type': '{ParameterDefinitionsValue}'}, + 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, + 'policy_definition_groups': {'key': 'properties.policyDefinitionGroups', 'type': '[PolicyDefinitionGroup]'}, + } + + def __init__( + self, + *, + policy_type: Optional[Union[str, "PolicyType"]] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + metadata: Optional[Any] = None, + parameters: Optional[Dict[str, "ParameterDefinitionsValue"]] = None, + policy_definitions: Optional[List["PolicyDefinitionReference"]] = None, + policy_definition_groups: Optional[List["PolicyDefinitionGroup"]] = None, + **kwargs + ): + super(PolicySetDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + self.policy_type = policy_type + self.display_name = display_name + self.description = description + self.metadata = metadata + self.parameters = parameters + self.policy_definitions = policy_definitions + self.policy_definition_groups = policy_definition_groups + + +class PolicySetDefinitionListResult(msrest.serialization.Model): + """List of policy set definitions. + + :param value: An array of policy set definitions. + :type value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition] + :param next_link: The URL to use for getting the next set of results. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicySetDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicySetDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicySetDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ResourceTypeAliases(msrest.serialization.Model): + """The resource type aliases definition. + + :param resource_type: The resource type name. + :type resource_type: str + :param aliases: The aliases for property names. + :type aliases: list[~azure.mgmt.resource.policy.v2021_06_01.models.Alias] + """ + + _attribute_map = { + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'aliases': {'key': 'aliases', 'type': '[Alias]'}, + } + + def __init__( + self, + *, + resource_type: Optional[str] = None, + aliases: Optional[List["Alias"]] = None, + **kwargs + ): + super(ResourceTypeAliases, self).__init__(**kwargs) + self.resource_type = resource_type + self.aliases = aliases + + +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.policy.v2021_06_01.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.policy.v2021_06_01.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 UserAssignedIdentitiesValue(msrest.serialization.Model): + """UserAssignedIdentitiesValue. + + 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(UserAssignedIdentitiesValue, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_policy_client_enums.py new file mode 100644 index 000000000000..fb61288e515e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_policy_client_enums.py @@ -0,0 +1,139 @@ +# 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 CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class EnforcementMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The policy assignment enforcement mode. Possible values are Default and DoNotEnforce. + """ + + #: The policy effect is enforced during resource creation or update. + DEFAULT = "Default" + #: The policy effect is not enforced during resource creation or update. + DO_NOT_ENFORCE = "DoNotEnforce" + +class ExemptionCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The policy exemption category. Possible values are Waiver and Mitigated. + """ + + #: This category of exemptions usually means the scope is not applicable for the policy. + WAIVER = "Waiver" + #: This category of exemptions usually means the mitigation actions have been applied to the + #: scope. + MITIGATED = "Mitigated" + +class ParameterType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The data type of the parameter. + """ + + STRING = "String" + ARRAY = "Array" + OBJECT = "Object" + BOOLEAN = "Boolean" + INTEGER = "Integer" + FLOAT = "Float" + DATE_TIME = "DateTime" + +class PolicyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. + """ + + NOT_SPECIFIED = "NotSpecified" + BUILT_IN = "BuiltIn" + CUSTOM = "Custom" + STATIC = "Static" + +class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The identity type. This is the only required field when adding a system or user assigned + identity to a resource. + """ + + #: Indicates that a system assigned identity is associated with the resource. + SYSTEM_ASSIGNED = "SystemAssigned" + #: Indicates that a system assigned identity is associated with the resource. + USER_ASSIGNED = "UserAssigned" + #: Indicates that no identity is associated with the resource or that the existing identity should + #: be removed. + NONE = "None" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/__init__.py new file mode 100644 index 000000000000..a39cae740704 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/__init__.py @@ -0,0 +1,21 @@ +# 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 ._data_policy_manifests_operations import DataPolicyManifestsOperations +from ._policy_assignments_operations import PolicyAssignmentsOperations +from ._policy_definitions_operations import PolicyDefinitionsOperations +from ._policy_set_definitions_operations import PolicySetDefinitionsOperations +from ._policy_exemptions_operations import PolicyExemptionsOperations + +__all__ = [ + 'DataPolicyManifestsOperations', + 'PolicyAssignmentsOperations', + 'PolicyDefinitionsOperations', + 'PolicySetDefinitionsOperations', + 'PolicyExemptionsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_data_policy_manifests_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_data_policy_manifests_operations.py new file mode 100644 index 000000000000..a47b59e91a38 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_data_policy_manifests_operations.py @@ -0,0 +1,179 @@ +# 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 DataPolicyManifestsOperations(object): + """DataPolicyManifestsOperations 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.policy.v2021_06_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_by_policy_mode( + self, + policy_mode, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.DataPolicyManifest" + """Retrieves a data policy manifest. + + This operation retrieves the data policy manifest with the given policy mode. + + :param policy_mode: The policy mode of the data policy manifest to get. + :type policy_mode: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataPolicyManifest, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.DataPolicyManifest + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DataPolicyManifest"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + accept = "application/json" + + # Construct URL + url = self.get_by_policy_mode.metadata['url'] # type: ignore + path_format_arguments = { + 'policyMode': self._serialize.url("policy_mode", policy_mode, '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('DataPolicyManifest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_policy_mode.metadata = {'url': '/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}'} # type: ignore + + def list( + self, + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.DataPolicyManifestListResult"] + """Retrieves data policy manifests. + + This operation retrieves a list of all the data policy manifests that match the optional given + $filter. Valid values for $filter are: "$filter=namespace eq '{0}'". If $filter is not + provided, the unfiltered list includes all data policy manifests for data resource types. If + $filter=namespace is provided, the returned list only includes all data policy manifests that + have a namespace matching the provided value. + + :param filter: The filter to apply on the operation. Valid values for $filter are: "namespace + eq '{value}'". If $filter is not provided, no filtering is performed. If $filter=namespace eq + '{value}' is provided, the returned list only includes all data policy manifests that have a + namespace matching the provided value. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DataPolicyManifestListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.DataPolicyManifestListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DataPolicyManifestListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-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') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) + + 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('DataPolicyManifestListResult', 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.Authorization/dataPolicyManifests'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_assignments_operations.py new file mode 100644 index 000000000000..eb4386ba399f --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_assignments_operations.py @@ -0,0 +1,1031 @@ +# 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 PolicyAssignmentsOperations(object): + """PolicyAssignmentsOperations 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.policy.v2021_06_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( + self, + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.PolicyAssignment"] + """Deletes a policy assignment. + + This operation deletes a policy assignment, given its name and the scope it was created in. The + scope of a policy assignment is the part of its ID preceding + '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment to delete. + :type policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.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) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + def create( + self, + scope, # type: str + policy_assignment_name, # type: str + parameters, # type: "_models.PolicyAssignment" + **kwargs # type: Any + ): + # type: (...) -> "_models.PolicyAssignment" + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'PolicyAssignment') + 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 [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + def get( + self, + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.PolicyAssignment" + """Retrieves a policy assignment. + + This operation retrieves a single policy assignment, given its name and the scope it was + created at. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment to get. + :type policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = 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('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + def update( + self, + scope, # type: str + policy_assignment_name, # type: str + parameters, # type: "_models.PolicyAssignmentUpdate" + **kwargs # type: Any + ): + # type: (...) -> "_models.PolicyAssignment" + """Updates a policy assignment. + + This operation updates a policy assignment with the given scope and name. Policy assignments + apply to all resources contained within their scope. For example, when you assign a policy at + resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. + :type policy_assignment_name: str + :param parameters: Parameters for policy assignment patch request. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'PolicyAssignmentUpdate') + 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('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + def list_for_resource_group( + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.PolicyAssignmentListResult"] + """Retrieves all policy assignments that apply to a resource group. + + This operation retrieves the list of all policy assignments associated with the given resource + group in the given subscription that match the optional given $filter. Valid values for $filter + are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not + provided, the unfiltered list includes all policy assignments associated with the resource + group, including those that apply directly or apply from containing scopes, as well as any + applied to resources contained within the resource group. If $filter=atScope() is provided, the + returned list includes all policy assignments that apply to the resource group, which is + everything in the unfiltered list except those applied to resources contained within the + resource group. If $filter=atExactScope() is provided, the returned list only includes all + policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is + provided, the returned list includes all policy assignments of the policy definition whose id + is {value} that apply to the resource group. + + :param resource_group_name: The name of the resource group that contains policy assignments. + :type resource_group_name: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', + 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering + is performed. If $filter=atScope() is provided, the returned list only includes all policy + assignments that apply to the scope, which is everything in the unfiltered list except those + applied to sub scopes contained within the given scope. If $filter=atExactScope() is provided, + the returned list only includes all policy assignments that at the given scope. If + $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy + assignments of the policy definition whose id is {value}. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. + :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 PolicyAssignmentListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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_for_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', skip_quote=True) + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + 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('PolicyAssignmentListResult', 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_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + + def list_for_resource( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.PolicyAssignmentListResult"] + """Retrieves all policy assignments that apply to a resource. + + This operation retrieves the list of all policy assignments associated with the specified + resource in the given resource group and subscription that match the optional given $filter. + Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq + '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments + associated with the resource, including those that apply directly or from all containing + scopes, as well as any applied to resources contained within the resource. If $filter=atScope() + is provided, the returned list includes all policy assignments that apply to the resource, + which is everything in the unfiltered list except those applied to resources contained within + the resource. If $filter=atExactScope() is provided, the returned list only includes all policy + assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, + the returned list includes all policy assignments of the policy definition whose id is {value} + that apply to the resource. Three parameters plus the resource name are used to identify a + specific resource. If the resource is not part of a parent resource (the more common case), the + parent resource path should not be provided (or provided as ''). For example a web app could be + specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', + {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent + resource, then all parameters should be provided. For example a virtual machine DNS name could + be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == + 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == + 'MyComputerName'). A convenient alternative to providing the namespace and type name separately + is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', + {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == + 'MyWebApp'). + + :param resource_group_name: The name of the resource group containing the resource. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. For example, the + namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource path. Use empty string if there is none. + :type parent_resource_path: str + :param resource_type: The resource type name. For example the type name of a web app is 'sites' + (from Microsoft.Web/sites). + :type resource_type: str + :param resource_name: The name of the resource. + :type resource_name: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', + 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering + is performed. If $filter=atScope() is provided, the returned list only includes all policy + assignments that apply to the scope, which is everything in the unfiltered list except those + applied to sub scopes contained within the given scope. If $filter=atExactScope() is provided, + the returned list only includes all policy assignments that at the given scope. If + $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy + assignments of the policy definition whose id is {value}. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. + :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 PolicyAssignmentListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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_for_resource.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] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + 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('PolicyAssignmentListResult', 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_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + + def list_for_management_group( + self, + management_group_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.PolicyAssignmentListResult"] + """Retrieves all policy assignments that apply to a management group. + + This operation retrieves the list of all policy assignments applicable to the management group + that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or + 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes + all policy assignments that are assigned to the management group or the management group's + ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy + assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is + provided, the returned list includes all policy assignments of the policy definition whose id + is {value} that apply to the management group. + + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', + 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering + is performed. If $filter=atScope() is provided, the returned list only includes all policy + assignments that apply to the scope, which is everything in the unfiltered list except those + applied to sub scopes contained within the given scope. If $filter=atExactScope() is provided, + the returned list only includes all policy assignments that at the given scope. If + $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy + assignments of the policy definition whose id is {value}. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. + :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 PolicyAssignmentListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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_for_management_group.metadata['url'] # type: ignore + path_format_arguments = { + 'managementGroupId': self._serialize.url("management_group_id", management_group_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', skip_quote=True) + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + 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('PolicyAssignmentListResult', 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_for_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + + def list( + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.PolicyAssignmentListResult"] + """Retrieves all policy assignments that apply to a subscription. + + This operation retrieves the list of all policy assignments associated with the given + subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', + 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the + unfiltered list includes all policy assignments associated with the subscription, including + those that apply directly or from management groups that contain the given subscription, as + well as any applied to objects contained within the subscription. If $filter=atScope() is + provided, the returned list includes all policy assignments that apply to the subscription, + which is everything in the unfiltered list except those applied to objects contained within the + subscription. If $filter=atExactScope() is provided, the returned list only includes all policy + assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, + the returned list includes all policy assignments of the policy definition whose id is {value}. + + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', + 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering + is performed. If $filter=atScope() is provided, the returned list only includes all policy + assignments that apply to the scope, which is everything in the unfiltered list except those + applied to sub scopes contained within the given scope. If $filter=atExactScope() is provided, + the returned list only includes all policy assignments that at the given scope. If + $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy + assignments of the policy definition whose id is {value}. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. + :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 PolicyAssignmentListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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', skip_quote=True) + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + 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('PolicyAssignmentListResult', 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/Microsoft.Authorization/policyAssignments'} # type: ignore + + def delete_by_id( + self, + policy_assignment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.PolicyAssignment"] + """Deletes a policy assignment. + + This operation deletes the policy with the given ID. Policy assignment IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' + (management group), '/subscriptions/{subscriptionId}' (subscription), + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + (resource). + + :param policy_assignment_id: The ID of the policy assignment to delete. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + accept = "application/json" + + # Construct URL + url = self.delete_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_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, 204]: + 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('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + def create_by_id( + self, + policy_assignment_id, # type: str + parameters, # type: "_models.PolicyAssignment" + **kwargs # type: Any + ): + # type: (...) -> "_models.PolicyAssignment" + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_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, 'PolicyAssignment') + 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 [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + def get_by_id( + self, + policy_assignment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.PolicyAssignment" + """Retrieves the policy assignment with the given ID. + + The operation retrieves the policy assignment with the given ID. Policy assignment IDs have + this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to get. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + accept = "application/json" + + # Construct URL + url = self.get_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_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('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + def update_by_id( + self, + policy_assignment_id, # type: str + parameters, # type: "_models.PolicyAssignmentUpdate" + **kwargs # type: Any + ): + # type: (...) -> "_models.PolicyAssignment" + """Updates a policy assignment. + + This operation updates the policy assignment with the given ID. Policy assignments made on a + scope apply to all resources contained in that scope. For example, when you assign a policy to + a resource group that policy applies to all resources in the group. Policy assignment IDs have + this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to update. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment patch request. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_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, 'PolicyAssignmentUpdate') + 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('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_definitions_operations.py new file mode 100644 index 000000000000..a3a0f40e1261 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_definitions_operations.py @@ -0,0 +1,749 @@ +# 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 PolicyDefinitionsOperations(object): + """PolicyDefinitionsOperations 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.policy.v2021_06_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 create_or_update( + self, + policy_definition_name, # type: str + parameters, # type: "_models.PolicyDefinition" + **kwargs # type: Any + ): + # type: (...) -> "_models.PolicyDefinition" + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. + :type policy_definition_name: str + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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 = { + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_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, 'PolicyDefinition') + 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 [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + def delete( + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes a policy definition in a subscription. + + This operation deletes the policy definition in the given subscription with the given name. + + :param policy_definition_name: The name of the policy definition to delete. + :type policy_definition_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-06-01" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_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}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + def get( + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.PolicyDefinition" + """Retrieves a policy definition in a subscription. + + This operation retrieves the policy definition in the given subscription with the given name. + + :param policy_definition_name: The name of the policy definition to get. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_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('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + def get_built_in( + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.PolicyDefinition" + """Retrieves a built-in policy definition. + + This operation retrieves the built-in policy definition with the given name. + + :param policy_definition_name: The name of the built-in policy definition to get. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + accept = "application/json" + + # Construct URL + url = self.get_built_in.metadata['url'] # type: ignore + path_format_arguments = { + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = 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('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + def create_or_update_at_management_group( + self, + policy_definition_name, # type: str + management_group_id, # type: str + parameters, # type: "_models.PolicyDefinition" + **kwargs # type: Any + ): + # type: (...) -> "_models.PolicyDefinition" + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + + :param policy_definition_name: The name of the policy definition to create. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update_at_management_group.metadata['url'] # type: ignore + path_format_arguments = { + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), + 'managementGroupId': self._serialize.url("management_group_id", management_group_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, 'PolicyDefinition') + 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 [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + def delete_at_management_group( + self, + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes a policy definition in a management group. + + This operation deletes the policy definition in the given management group with the given name. + + :param policy_definition_name: The name of the policy definition to delete. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. + :type management_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-06-01" + accept = "application/json" + + # Construct URL + url = self.delete_at_management_group.metadata['url'] # type: ignore + path_format_arguments = { + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), + 'managementGroupId': self._serialize.url("management_group_id", management_group_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_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + def get_at_management_group( + self, + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.PolicyDefinition" + """Retrieve a policy definition in a management group. + + This operation retrieves the policy definition in the given management group with the given + name. + + :param policy_definition_name: The name of the policy definition to get. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. + :type management_group_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + accept = "application/json" + + # Construct URL + url = self.get_at_management_group.metadata['url'] # type: ignore + path_format_arguments = { + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), + 'managementGroupId': self._serialize.url("management_group_id", management_group_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('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + def list( + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.PolicyDefinitionListResult"] + """Retrieves policy definitions in a subscription. + + This operation retrieves a list of all the policy definitions in a given subscription that + match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType + -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list + includes all policy definitions associated with the subscription, including those that apply + directly or from management groups that contain the given subscription. If + $filter=atExactScope() is provided, the returned list only includes all policy definitions that + at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list + only includes all policy definitions whose type match the {value}. Possible policyType values + are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, + the returned list only includes all policy definitions whose category match the {value}. + + :param filter: The filter to apply on the operation. Valid values for $filter are: + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy definitions whose type match + the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy + definitions whose category match the {value}. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. + :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 PolicyDefinitionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + + 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('PolicyDefinitionListResult', 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/Microsoft.Authorization/policyDefinitions'} # type: ignore + + def list_built_in( + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.PolicyDefinitionListResult"] + """Retrieve built-in policy definitions. + + This operation retrieves a list of all the built-in policy definitions that match the optional + given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes + all built-in policy definitions whose type match the {value}. Possible policyType values are + NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the + returned list only includes all built-in policy definitions whose category match the {value}. + + :param filter: The filter to apply on the operation. Valid values for $filter are: + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy definitions whose type match + the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy + definitions whose category match the {value}. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. + :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 PolicyDefinitionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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_built_in.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + + 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('PolicyDefinitionListResult', 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_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + + def list_by_management_group( + self, + management_group_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.PolicyDefinitionListResult"] + """Retrieve policy definitions in a management group. + + This operation retrieves a list of all the policy definitions in a given management group that + match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType + -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list + includes all policy definitions associated with the management group, including those that + apply directly or from management groups that contain the given management group. If + $filter=atExactScope() is provided, the returned list only includes all policy definitions that + at the given management group. If $filter='policyType -eq {value}' is provided, the returned + list only includes all policy definitions whose type match the {value}. Possible policyType + values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is + provided, the returned list only includes all policy definitions whose category match the + {value}. + + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param filter: The filter to apply on the operation. Valid values for $filter are: + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy definitions whose type match + the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy + definitions whose category match the {value}. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. + :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 PolicyDefinitionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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_management_group.metadata['url'] # type: ignore + path_format_arguments = { + 'managementGroupId': self._serialize.url("management_group_id", management_group_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') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + + 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('PolicyDefinitionListResult', 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_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_exemptions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_exemptions_operations.py new file mode 100644 index 000000000000..215486618d07 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_exemptions_operations.py @@ -0,0 +1,653 @@ +# 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 PolicyExemptionsOperations(object): + """PolicyExemptionsOperations 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.policy.v2021_06_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( + self, + scope, # type: str + policy_exemption_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes a policy exemption. + + This operation deletes a policy exemption, given its name and the scope it was created in. The + scope of a policy exemption is the part of its ID preceding + '/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'. + + :param scope: The scope of the policy exemption. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_exemption_name: The name of the policy exemption to delete. + :type policy_exemption_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 = "2020-07-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'policyExemptionName': self._serialize.url("policy_exemption_name", policy_exemption_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.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': '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'} # type: ignore + + def create_or_update( + self, + scope, # type: str + policy_exemption_name, # type: str + parameters, # type: "_models.PolicyExemption" + **kwargs # type: Any + ): + # type: (...) -> "_models.PolicyExemption" + """Creates or updates a policy exemption. + + This operation creates or updates a policy exemption with the given scope and name. Policy + exemptions apply to all resources contained within their scope. For example, when you create a + policy exemption at resource group scope for a policy assignment at the same or above level, + the exemption exempts to all applicable resources in the resource group. + + :param scope: The scope of the policy exemption. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_exemption_name: The name of the policy exemption to delete. + :type policy_exemption_name: str + :param parameters: Parameters for the policy exemption. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyExemption, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemption"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-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 = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'policyExemptionName': self._serialize.url("policy_exemption_name", policy_exemption_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'PolicyExemption') + 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('PolicyExemption', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PolicyExemption', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'} # type: ignore + + def get( + self, + scope, # type: str + policy_exemption_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.PolicyExemption" + """Retrieves a policy exemption. + + This operation retrieves a single policy exemption, given its name and the scope it was created + at. + + :param scope: The scope of the policy exemption. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_exemption_name: The name of the policy exemption to delete. + :type policy_exemption_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyExemption, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemption"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'policyExemptionName': self._serialize.url("policy_exemption_name", policy_exemption_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = 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('PolicyExemption', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'} # type: ignore + + def list( + self, + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.PolicyExemptionListResult"] + """Retrieves all policy exemptions that apply to a subscription. + + This operation retrieves the list of all policy exemptions associated with the given + subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', + 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not + provided, the unfiltered list includes all policy exemptions associated with the subscription, + including those that apply directly or from management groups that contain the given + subscription, as well as any applied to objects contained within the subscription. + + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', + 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter is not provided, the unfiltered list includes + all policy exemptions associated with the scope, including those that apply directly or apply + from containing scopes. If $filter=atScope() is provided, the returned list only includes all + policy exemptions that apply to the scope, which is everything in the unfiltered list except + those applied to sub scopes contained within the given scope. If $filter=atExactScope() is + provided, the returned list only includes all policy exemptions that at the given scope. If + $filter=excludeExpired() is provided, the returned list only includes all policy exemptions + that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId eq + '{value}' is provided. the returned list only includes all policy exemptions that are + associated with the give policyAssignmentId. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-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'), + } + 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', skip_quote=True) + 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('PolicyExemptionListResult', 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/Microsoft.Authorization/policyExemptions'} # type: ignore + + def list_for_resource_group( + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.PolicyExemptionListResult"] + """Retrieves all policy exemptions that apply to a resource group. + + This operation retrieves the list of all policy exemptions associated with the given resource + group in the given subscription that match the optional given $filter. Valid values for $filter + are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If + $filter is not provided, the unfiltered list includes all policy exemptions associated with the + resource group, including those that apply directly or apply from containing scopes, as well as + any applied to resources contained within the resource group. + + :param resource_group_name: The name of the resource group containing the resource. + :type resource_group_name: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', + 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter is not provided, the unfiltered list includes + all policy exemptions associated with the scope, including those that apply directly or apply + from containing scopes. If $filter=atScope() is provided, the returned list only includes all + policy exemptions that apply to the scope, which is everything in the unfiltered list except + those applied to sub scopes contained within the given scope. If $filter=atExactScope() is + provided, the returned list only includes all policy exemptions that at the given scope. If + $filter=excludeExpired() is provided, the returned list only includes all policy exemptions + that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId eq + '{value}' is provided. the returned list only includes all policy exemptions that are + associated with the give policyAssignmentId. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-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_for_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 filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) + 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('PolicyExemptionListResult', 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_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions'} # type: ignore + + def list_for_resource( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.PolicyExemptionListResult"] + """Retrieves all policy exemptions that apply to a resource. + + This operation retrieves the list of all policy exemptions associated with the specified + resource in the given resource group and subscription that match the optional given $filter. + Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or + 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all + policy exemptions associated with the resource, including those that apply directly or from all + containing scopes, as well as any applied to resources contained within the resource. Three + parameters plus the resource name are used to identify a specific resource. If the resource is + not part of a parent resource (the more common case), the parent resource path should not be + provided (or provided as ''). For example a web app could be specified as + ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == + 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all + parameters should be provided. For example a virtual machine DNS name could be specified as + ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == + 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == + 'MyComputerName'). A convenient alternative to providing the namespace and type name separately + is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', + {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == + 'MyWebApp'). + + :param resource_group_name: The name of the resource group containing the resource. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. For example, the + namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource path. Use empty string if there is none. + :type parent_resource_path: str + :param resource_type: The resource type name. For example the type name of a web app is 'sites' + (from Microsoft.Web/sites). + :type resource_type: str + :param resource_name: The name of the resource. + :type resource_name: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', + 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter is not provided, the unfiltered list includes + all policy exemptions associated with the scope, including those that apply directly or apply + from containing scopes. If $filter=atScope() is provided, the returned list only includes all + policy exemptions that apply to the scope, which is everything in the unfiltered list except + those applied to sub scopes contained within the given scope. If $filter=atExactScope() is + provided, the returned list only includes all policy exemptions that at the given scope. If + $filter=excludeExpired() is provided, the returned list only includes all policy exemptions + that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId eq + '{value}' is provided. the returned list only includes all policy exemptions that are + associated with the give policyAssignmentId. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-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_for_resource.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\._\(\)]+$'), + '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'), + } + 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', skip_quote=True) + 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('PolicyExemptionListResult', 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_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions'} # type: ignore + + def list_for_management_group( + self, + management_group_id, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.PolicyExemptionListResult"] + """Retrieves all policy exemptions that apply to a management group. + + This operation retrieves the list of all policy exemptions applicable to the management group + that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', + 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter=atScope() is provided, the + returned list includes all policy exemptions that are assigned to the management group or the + management group's ancestors. + + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', + 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter is not provided, the unfiltered list includes + all policy exemptions associated with the scope, including those that apply directly or apply + from containing scopes. If $filter=atScope() is provided, the returned list only includes all + policy exemptions that apply to the scope, which is everything in the unfiltered list except + those applied to sub scopes contained within the given scope. If $filter=atExactScope() is + provided, the returned list only includes all policy exemptions that at the given scope. If + $filter=excludeExpired() is provided, the returned list only includes all policy exemptions + that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId eq + '{value}' is provided. the returned list only includes all policy exemptions that are + associated with the give policyAssignmentId. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-07-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_for_management_group.metadata['url'] # type: ignore + path_format_arguments = { + 'managementGroupId': self._serialize.url("management_group_id", management_group_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', skip_quote=True) + 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('PolicyExemptionListResult', 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_for_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyExemptions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_set_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_set_definitions_operations.py new file mode 100644 index 000000000000..3d9b86a2313d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_set_definitions_operations.py @@ -0,0 +1,757 @@ +# 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 PolicySetDefinitionsOperations(object): + """PolicySetDefinitionsOperations 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.policy.v2021_06_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 create_or_update( + self, + policy_set_definition_name, # type: str + parameters, # type: "_models.PolicySetDefinition" + **kwargs # type: Any + ): + # type: (...) -> "_models.PolicySetDefinition" + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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 = { + 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_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, 'PolicySetDefinition') + 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('PolicySetDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + def delete( + self, + policy_set_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes a policy set definition. + + This operation deletes the policy set definition in the given subscription with the given name. + + :param policy_set_definition_name: The name of the policy set definition to delete. + :type policy_set_definition_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-06-01" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_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}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + def get( + self, + policy_set_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.PolicySetDefinition" + """Retrieves a policy set definition. + + This operation retrieves the policy set definition in the given subscription with the given + name. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_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('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + def get_built_in( + self, + policy_set_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.PolicySetDefinition" + """Retrieves a built in policy set definition. + + This operation retrieves the built-in policy set definition with the given name. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + accept = "application/json" + + # Construct URL + url = self.get_built_in.metadata['url'] # type: ignore + path_format_arguments = { + 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = 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('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + def list( + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.PolicySetDefinitionListResult"] + """Retrieves the policy set definitions for a subscription. + + This operation retrieves a list of all the policy set definitions in a given subscription that + match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType + -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list + includes all policy set definitions associated with the subscription, including those that + apply directly or from management groups that contain the given subscription. If + $filter=atExactScope() is provided, the returned list only includes all policy set definitions + that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned + list only includes all policy set definitions whose type match the {value}. Possible policyType + values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the + returned list only includes all policy set definitions whose category match the {value}. + + :param filter: The filter to apply on the operation. Valid values for $filter are: + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy set definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy set definitions whose type + match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy set + definitions whose category match the {value}. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. + :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 PolicySetDefinitionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + + 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('PolicySetDefinitionListResult', 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/Microsoft.Authorization/policySetDefinitions'} # type: ignore + + def list_built_in( + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.PolicySetDefinitionListResult"] + """Retrieves built-in policy set definitions. + + This operation retrieves a list of all the built-in policy set definitions that match the + optional given $filter. If $filter='category -eq {value}' is provided, the returned list only + includes all built-in policy set definitions whose category match the {value}. + + :param filter: The filter to apply on the operation. Valid values for $filter are: + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy set definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy set definitions whose type + match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy set + definitions whose category match the {value}. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. + :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 PolicySetDefinitionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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_built_in.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + + 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('PolicySetDefinitionListResult', 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_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + + def create_or_update_at_management_group( + self, + policy_set_definition_name, # type: str + management_group_id, # type: str + parameters, # type: "_models.PolicySetDefinition" + **kwargs # type: Any + ): + # type: (...) -> "_models.PolicySetDefinition" + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param parameters: The policy set definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update_at_management_group.metadata['url'] # type: ignore + path_format_arguments = { + 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), + 'managementGroupId': self._serialize.url("management_group_id", management_group_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, 'PolicySetDefinition') + 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('PolicySetDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + def delete_at_management_group( + self, + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes a policy set definition. + + This operation deletes the policy set definition in the given management group with the given + name. + + :param policy_set_definition_name: The name of the policy set definition to delete. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. + :type management_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-06-01" + accept = "application/json" + + # Construct URL + url = self.delete_at_management_group.metadata['url'] # type: ignore + path_format_arguments = { + 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), + 'managementGroupId': self._serialize.url("management_group_id", management_group_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_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + def get_at_management_group( + self, + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.PolicySetDefinition" + """Retrieves a policy set definition. + + This operation retrieves the policy set definition in the given management group with the given + name. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. + :type management_group_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-01" + accept = "application/json" + + # Construct URL + url = self.get_at_management_group.metadata['url'] # type: ignore + path_format_arguments = { + 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), + 'managementGroupId': self._serialize.url("management_group_id", management_group_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('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + def list_by_management_group( + self, + management_group_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.PolicySetDefinitionListResult"] + """Retrieves all policy set definitions in management group. + + This operation retrieves a list of all the policy set definitions in a given management group + that match the optional given $filter. Valid values for $filter are: 'atExactScope()', + 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered + list includes all policy set definitions associated with the management group, including those + that apply directly or from management groups that contain the given management group. If + $filter=atExactScope() is provided, the returned list only includes all policy set definitions + that at the given management group. If $filter='policyType -eq {value}' is provided, the + returned list only includes all policy set definitions whose type match the {value}. Possible + policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is + provided, the returned list only includes all policy set definitions whose category match the + {value}. + + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param filter: The filter to apply on the operation. Valid values for $filter are: + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy set definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy set definitions whose type + match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy set + definitions whose category match the {value}. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. + :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 PolicySetDefinitionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-06-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_management_group.metadata['url'] # type: ignore + path_format_arguments = { + 'managementGroupId': self._serialize.url("management_group_id", management_group_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') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + + 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('PolicySetDefinitionListResult', 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_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_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/resources/v2016_02_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_version.py index 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.0" +VERSION = "1.0.0b1" 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 index 232662316d4d..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "19.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_version.py index 232662316d4d..e5754a47ce68 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "19.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_providers_operations.py index 694e9dc9377e..f40003d62297 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_providers_operations.py @@ -270,14 +270,11 @@ async def register( def list( self, - top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> 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. @@ -309,8 +306,6 @@ def prepare_request(next_link=None): 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') @@ -348,14 +343,11 @@ async def get_next(next_link=None): def list_at_tenant_scope( self, - top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> 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. @@ -383,8 +375,6 @@ def prepare_request(next_link=None): 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') diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_resources_operations.py index 023da22c9f85..514f2cade8d9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_resources_operations.py @@ -388,20 +388,30 @@ def list( ) -> 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. + :param filter: The filter to apply on the operation.:code:`
`:code:`
`Filter comparison + operators include ``eq`` (equals) and ``ne`` (not equals) and may be used with the following + properties: ``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:`
`:code:`
`\ + ``substringof(value, property)`` can be used to filter for substrings of the following + currently-supported properties: ``name`` and ``resourceGroup``\ :code:`
`:code:`
`For + example, to get all resources with 'demo' anywhere in the resource name, use + ``$filter=substringof('demo', name)``\ :code:`
`:code:`
`Multiple substring operations + can also be combined using ``and``\ /\ ``or`` + operators.:code:`
`:code:`
`:code:`
`Resources can be filtered by tag names and + values. For example, to filter for a tag name and value, use ``$filter=tagName eq 'tag1' and + tagValue eq 'Value1'``. Note that when resources are filtered by tag name and value, + :code:`the original tags for each resource will not be returned in the results.` Any + list of additional properties queried via ``$expand`` may also not be compatible when filtering + by tag names/values. :code:`
`:code:`
`For tag names only, resources can be filtered by + prefix using the following syntax: ``$filter=startswith(tagName, 'depart')``. This query will + return all resources with a tag name prefixed by the phrase ``depart`` (i.e.\ ``department``\ , + ``departureDate``\ , ``departureTime``\ , etc.):code:`
`:code:`
`:code:`
`Note that + some properties can be combined when filtering resources, which include the following: + ``substringof() and/or resourceType``\ , ``plan and plan/publisher and plan/name``\ , and + ``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, diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_providers_operations.py index e2114a07cba5..1fe6971c0011 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_providers_operations.py @@ -278,15 +278,12 @@ def register( 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. @@ -318,8 +315,6 @@ def prepare_request(next_link=None): 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') @@ -357,15 +352,12 @@ def get_next(next_link=None): 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. @@ -393,8 +385,6 @@ def prepare_request(next_link=None): 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') diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_resources_operations.py index 05557c6524e2..f0eb8f013360 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_resources_operations.py @@ -398,20 +398,30 @@ def list( # 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. + :param filter: The filter to apply on the operation.:code:`
`:code:`
`Filter comparison + operators include ``eq`` (equals) and ``ne`` (not equals) and may be used with the following + properties: ``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:`
`:code:`
`\ + ``substringof(value, property)`` can be used to filter for substrings of the following + currently-supported properties: ``name`` and ``resourceGroup``\ :code:`
`:code:`
`For + example, to get all resources with 'demo' anywhere in the resource name, use + ``$filter=substringof('demo', name)``\ :code:`
`:code:`
`Multiple substring operations + can also be combined using ``and``\ /\ ``or`` + operators.:code:`
`:code:`
`:code:`
`Resources can be filtered by tag names and + values. For example, to filter for a tag name and value, use ``$filter=tagName eq 'tag1' and + tagValue eq 'Value1'``. Note that when resources are filtered by tag name and value, + :code:`the original tags for each resource will not be returned in the results.` Any + list of additional properties queried via ``$expand`` may also not be compatible when filtering + by tag names/values. :code:`
`:code:`
`For tag names only, resources can be filtered by + prefix using the following syntax: ``$filter=startswith(tagName, 'depart')``. This query will + return all resources with a tag name prefixed by the phrase ``depart`` (i.e.\ ``department``\ , + ``departureDate``\ , ``departureTime``\ , etc.):code:`
`:code:`
`:code:`
`Note that + some properties can be combined when filtering resources, which include the following: + ``substringof() and/or resourceType``\ , ``plan and plan/publisher and plan/name``\ , and + ``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, diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_operations_mixin.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_operations_mixin.py index 1a194a9807e9..ed151630858f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_operations_mixin.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_operations_mixin.py @@ -36,10 +36,10 @@ def check_resource_name( :param resource_name_definition: Resource object with values for resource name and resource type. - :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName + :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckResourceNameResult, or the result of cls(response) - :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult + :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('check_resource_name') @@ -51,6 +51,8 @@ def check_resource_name( from .v2019_06_01.operations import SubscriptionClientOperationsMixin as OperationClass elif api_version == '2019-11-01': from .v2019_11_01.operations import SubscriptionClientOperationsMixin as OperationClass + elif api_version == '2021-01-01': + from .v2021_01_01.operations import SubscriptionClientOperationsMixin as OperationClass else: raise ValueError("API version {} does not have operation 'check_resource_name'".format(api_version)) mixin_instance = OperationClass() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_subscription_client.py index 584f2df83ab4..915c656beced 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_subscription_client.py @@ -54,11 +54,12 @@ class SubscriptionClient(SubscriptionClientOperationsMixin, MultiApiClientMixin, :type profile: azure.profiles.KnownProfiles """ - DEFAULT_API_VERSION = '2019-11-01' + DEFAULT_API_VERSION = '2021-01-01' _PROFILE_TAG = "azure.mgmt.resource.subscriptions.SubscriptionClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { None: DEFAULT_API_VERSION, + 'operations': '2019-11-01', }}, _PROFILE_TAG + " latest" ) @@ -92,6 +93,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2018-06-01: :mod:`v2018_06_01.models` * 2019-06-01: :mod:`v2019_06_01.models` * 2019-11-01: :mod:`v2019_11_01.models` + * 2021-01-01: :mod:`v2021_01_01.models` """ if api_version == '2016-06-01': from .v2016_06_01 import models @@ -105,6 +107,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2019-11-01': from .v2019_11_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 @@ -137,6 +142,7 @@ def subscriptions(self): * 2018-06-01: :class:`SubscriptionsOperations` * 2019-06-01: :class:`SubscriptionsOperations` * 2019-11-01: :class:`SubscriptionsOperations` + * 2021-01-01: :class:`SubscriptionsOperations` """ api_version = self._get_api_version('subscriptions') if api_version == '2016-06-01': @@ -147,6 +153,8 @@ def subscriptions(self): from .v2019_06_01.operations import SubscriptionsOperations as OperationClass elif api_version == '2019-11-01': from .v2019_11_01.operations import SubscriptionsOperations as OperationClass + elif api_version == '2021-01-01': + from .v2021_01_01.operations import SubscriptionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'subscriptions'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -159,6 +167,7 @@ def tenants(self): * 2018-06-01: :class:`TenantsOperations` * 2019-06-01: :class:`TenantsOperations` * 2019-11-01: :class:`TenantsOperations` + * 2021-01-01: :class:`TenantsOperations` """ api_version = self._get_api_version('tenants') if api_version == '2016-06-01': @@ -169,6 +178,8 @@ def tenants(self): from .v2019_06_01.operations import TenantsOperations as OperationClass elif api_version == '2019-11-01': from .v2019_11_01.operations import TenantsOperations as OperationClass + elif api_version == '2021-01-01': + from .v2021_01_01.operations import TenantsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'tenants'".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/subscriptions/aio/_operations_mixin.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_operations_mixin.py index 28b797545d9e..7ab07ebf2f8b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_operations_mixin.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_operations_mixin.py @@ -32,10 +32,10 @@ async def check_resource_name( :param resource_name_definition: Resource object with values for resource name and resource type. - :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName + :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckResourceNameResult, or the result of cls(response) - :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult + :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('check_resource_name') @@ -47,6 +47,8 @@ async def check_resource_name( from ..v2019_06_01.aio.operations import SubscriptionClientOperationsMixin as OperationClass elif api_version == '2019-11-01': from ..v2019_11_01.aio.operations import SubscriptionClientOperationsMixin as OperationClass + elif api_version == '2021-01-01': + from ..v2021_01_01.aio.operations import SubscriptionClientOperationsMixin as OperationClass else: raise ValueError("API version {} does not have operation 'check_resource_name'".format(api_version)) mixin_instance = OperationClass() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_subscription_client.py index ca0b63129ad1..a9abc20407d7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_subscription_client.py @@ -52,11 +52,12 @@ class SubscriptionClient(SubscriptionClientOperationsMixin, MultiApiClientMixin, :type profile: azure.profiles.KnownProfiles """ - DEFAULT_API_VERSION = '2019-11-01' + DEFAULT_API_VERSION = '2021-01-01' _PROFILE_TAG = "azure.mgmt.resource.subscriptions.SubscriptionClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { None: DEFAULT_API_VERSION, + 'operations': '2019-11-01', }}, _PROFILE_TAG + " latest" ) @@ -90,6 +91,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2018-06-01: :mod:`v2018_06_01.models` * 2019-06-01: :mod:`v2019_06_01.models` * 2019-11-01: :mod:`v2019_11_01.models` + * 2021-01-01: :mod:`v2021_01_01.models` """ if api_version == '2016-06-01': from ..v2016_06_01 import models @@ -103,6 +105,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2019-11-01': from ..v2019_11_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 @@ -135,6 +140,7 @@ def subscriptions(self): * 2018-06-01: :class:`SubscriptionsOperations` * 2019-06-01: :class:`SubscriptionsOperations` * 2019-11-01: :class:`SubscriptionsOperations` + * 2021-01-01: :class:`SubscriptionsOperations` """ api_version = self._get_api_version('subscriptions') if api_version == '2016-06-01': @@ -145,6 +151,8 @@ def subscriptions(self): from ..v2019_06_01.aio.operations import SubscriptionsOperations as OperationClass elif api_version == '2019-11-01': from ..v2019_11_01.aio.operations import SubscriptionsOperations as OperationClass + elif api_version == '2021-01-01': + from ..v2021_01_01.aio.operations import SubscriptionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'subscriptions'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -157,6 +165,7 @@ def tenants(self): * 2018-06-01: :class:`TenantsOperations` * 2019-06-01: :class:`TenantsOperations` * 2019-11-01: :class:`TenantsOperations` + * 2021-01-01: :class:`TenantsOperations` """ api_version = self._get_api_version('tenants') if api_version == '2016-06-01': @@ -167,6 +176,8 @@ def tenants(self): from ..v2019_06_01.aio.operations import TenantsOperations as OperationClass elif api_version == '2019-11-01': from ..v2019_11_01.aio.operations import TenantsOperations as OperationClass + elif api_version == '2021-01-01': + from ..v2021_01_01.aio.operations import TenantsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'tenants'".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/subscriptions/models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/models.py index 28ba9b61c72e..4d1c3072bc67 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/models.py @@ -5,3 +5,4 @@ # license information. # -------------------------------------------------------------------------- from .v2019_11_01.models import * +from .v2021_01_01.models import * 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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.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 232662316d4d..e5754a47ce68 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 = "19.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/__init__.py new file mode 100644 index 000000000000..6d8f45c77a61 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/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 ._subscription_client import SubscriptionClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ['SubscriptionClient'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_configuration.py new file mode 100644 index 000000000000..4cd4f335e002 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_configuration.py @@ -0,0 +1,65 @@ +# 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 SubscriptionClientConfiguration(Configuration): + """Configuration for SubscriptionClient. + + 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 + """ + + def __init__( + self, + credential, # type: "TokenCredential" + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + super(SubscriptionClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + 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/subscriptions/v2021_01_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_metadata.json new file mode 100644 index 000000000000..5c7ce346bf28 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_metadata.json @@ -0,0 +1,110 @@ +{ + "chosen_version": "2021-01-01", + "total_api_version_list": ["2021-01-01"], + "client": { + "name": "SubscriptionClient", + "filename": "_subscription_client", + "description": "All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization.", + "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\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"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\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"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 + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + } + }, + "constant": { + }, + "call": "credential", + "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": { + "subscriptions": "SubscriptionsOperations", + "tenants": "TenantsOperations" + }, + "operation_mixins": { + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "operations": { + "check_resource_name" : { + "sync": { + "signature": "def check_resource_name(\n self,\n resource_name_definition=None, # type: Optional[\"_models.ResourceName\"]\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def check_resource_name(\n self,\n resource_name_definition: Optional[\"_models.ResourceName\"] = None,\n **kwargs: Any\n) -\u003e \"_models.CheckResourceNameResult\":\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "resource_name_definition" + } + } + } +} \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_subscription_client.py new file mode 100644 index 000000000000..33d13aa52091 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_subscription_client.py @@ -0,0 +1,88 @@ +# 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 SubscriptionClientConfiguration +from .operations import SubscriptionsOperations +from .operations import TenantsOperations +from .operations import SubscriptionClientOperationsMixin +from . import models + + +class SubscriptionClient(SubscriptionClientOperationsMixin): + """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. + + :ivar subscriptions: SubscriptionsOperations operations + :vartype subscriptions: azure.mgmt.resource.subscriptions.v2021_01_01.operations.SubscriptionsOperations + :ivar tenants: TenantsOperations operations + :vartype tenants: azure.mgmt.resource.subscriptions.v2021_01_01.operations.TenantsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param str base_url: Service URL + """ + + def __init__( + self, + credential, # type: "TokenCredential" + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = SubscriptionClientConfiguration(credential, **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.subscriptions = SubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tenants = TenantsOperations( + 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 + """ + http_request.url = self._client.format_url(http_request.url) + 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: () -> SubscriptionClient + 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/subscriptions/v2021_01_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/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/subscriptions/v2021_01_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/__init__.py new file mode 100644 index 000000000000..25a76f1a6996 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/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 ._subscription_client import SubscriptionClient +__all__ = ['SubscriptionClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_configuration.py new file mode 100644 index 000000000000..4bb922d53910 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_configuration.py @@ -0,0 +1,61 @@ +# 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 SubscriptionClientConfiguration(Configuration): + """Configuration for SubscriptionClient. + + 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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + **kwargs: Any + ) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + super(SubscriptionClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + 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/subscriptions/v2021_01_01/aio/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_subscription_client.py new file mode 100644 index 000000000000..dd8b88cd62ed --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_subscription_client.py @@ -0,0 +1,81 @@ +# 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 SubscriptionClientConfiguration +from .operations import SubscriptionsOperations +from .operations import TenantsOperations +from .operations import SubscriptionClientOperationsMixin +from .. import models + + +class SubscriptionClient(SubscriptionClientOperationsMixin): + """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. + + :ivar subscriptions: SubscriptionsOperations operations + :vartype subscriptions: azure.mgmt.resource.subscriptions.v2021_01_01.aio.operations.SubscriptionsOperations + :ivar tenants: TenantsOperations operations + :vartype tenants: azure.mgmt.resource.subscriptions.v2021_01_01.aio.operations.TenantsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param str base_url: Service URL + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = SubscriptionClientConfiguration(credential, **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.subscriptions = SubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tenants = TenantsOperations( + 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 + """ + http_request.url = self._client.format_url(http_request.url) + 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) -> "SubscriptionClient": + 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/subscriptions/v2021_01_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/__init__.py new file mode 100644 index 000000000000..2547a9583d70 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/__init__.py @@ -0,0 +1,17 @@ +# 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 ._subscriptions_operations import SubscriptionsOperations +from ._tenants_operations import TenantsOperations +from ._subscription_client_operations import SubscriptionClientOperationsMixin + +__all__ = [ + 'SubscriptionsOperations', + 'TenantsOperations', + 'SubscriptionClientOperationsMixin', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_subscription_client_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_subscription_client_operations.py new file mode 100644 index 000000000000..5d14abe7d8cf --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_subscription_client_operations.py @@ -0,0 +1,82 @@ +# 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 SubscriptionClientOperationsMixin: + + async def check_resource_name( + self, + resource_name_definition: Optional["_models.ResourceName"] = None, + **kwargs: Any + ) -> "_models.CheckResourceNameResult": + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. + :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckResourceNameResult"] + 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.check_resource_name.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] + if resource_name_definition is not None: + body_content = self._serialize.body(resource_name_definition, 'ResourceName') + else: + body_content = None + 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('CheckResourceNameResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_subscriptions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_subscriptions_operations.py new file mode 100644 index 000000000000..fc3419dabd4a --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_subscriptions_operations.py @@ -0,0 +1,234 @@ +# 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 SubscriptionsOperations: + """SubscriptionsOperations 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.subscriptions.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_locations( + self, + subscription_id: str, + include_extended_locations: Optional[bool] = None, + **kwargs: Any + ) -> AsyncIterable["_models.LocationListResult"]: + """Gets all available geo-locations. + + This operation provides all the locations that are available for resource providers; however, + each resource provider may support a subset of this list. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param include_extended_locations: Whether to include extended locations. + :type include_extended_locations: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LocationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.LocationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] + 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_locations.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", 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') + if include_extended_locations is not None: + query_parameters['includeExtendedLocations'] = self._serialize.query("include_extended_locations", include_extended_locations, 'bool') + + 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('LocationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + + async def get( + self, + subscription_id: str, + **kwargs: Any + ) -> "_models.Subscription": + """Gets details about a specified subscription. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Subscription, or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.Subscription + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Subscription"] + 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 = { + 'subscriptionId': self._serialize.url("subscription_id", 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('Subscription', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.SubscriptionListResult"]: + """Gets all subscriptions for a tenant. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.SubscriptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] + 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('SubscriptionListResult', 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'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_tenants_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_tenants_operations.py new file mode 100644 index 000000000000..fdcd9f317284 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_tenants_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 TenantsOperations: + """TenantsOperations 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.subscriptions.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: Any + ) -> AsyncIterable["_models.TenantListResult"]: + """Gets the tenants for your account. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TenantListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] + 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('TenantListResult', 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': '/tenants'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/__init__.py new file mode 100644 index 000000000000..05452f7cf6cf --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/__init__.py @@ -0,0 +1,81 @@ +# 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 CheckResourceNameResult + from ._models_py3 import ErrorAdditionalInfo + from ._models_py3 import ErrorResponse + from ._models_py3 import Location + from ._models_py3 import LocationListResult + from ._models_py3 import LocationMetadata + from ._models_py3 import ManagedByTenant + from ._models_py3 import Operation + from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult + from ._models_py3 import PairedRegion + from ._models_py3 import ResourceName + from ._models_py3 import Subscription + from ._models_py3 import SubscriptionListResult + from ._models_py3 import SubscriptionPolicies + from ._models_py3 import TenantIdDescription + from ._models_py3 import TenantListResult +except (SyntaxError, ImportError): + from ._models import CheckResourceNameResult # type: ignore + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import Location # type: ignore + from ._models import LocationListResult # type: ignore + from ._models import LocationMetadata # type: ignore + from ._models import ManagedByTenant # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import PairedRegion # type: ignore + from ._models import ResourceName # type: ignore + from ._models import Subscription # type: ignore + from ._models import SubscriptionListResult # type: ignore + from ._models import SubscriptionPolicies # type: ignore + from ._models import TenantIdDescription # type: ignore + from ._models import TenantListResult # type: ignore + +from ._subscription_client_enums import ( + LocationType, + RegionCategory, + RegionType, + ResourceNameStatus, + SpendingLimit, + SubscriptionState, + TenantCategory, +) + +__all__ = [ + 'CheckResourceNameResult', + 'ErrorAdditionalInfo', + 'ErrorResponse', + 'Location', + 'LocationListResult', + 'LocationMetadata', + 'ManagedByTenant', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'PairedRegion', + 'ResourceName', + 'Subscription', + 'SubscriptionListResult', + 'SubscriptionPolicies', + 'TenantIdDescription', + 'TenantListResult', + 'LocationType', + 'RegionCategory', + 'RegionType', + 'ResourceNameStatus', + 'SpendingLimit', + 'SubscriptionState', + 'TenantCategory', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_models.py new file mode 100644 index 000000000000..3d8d6c873a3a --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_models.py @@ -0,0 +1,654 @@ +# 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 CheckResourceNameResult(msrest.serialization.Model): + """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. + + :param name: Name of Resource. + :type name: str + :param type: Type of Resource. + :type type: str + :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + "Reserved". + :type status: str or ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceNameStatus + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CheckResourceNameResult, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.type = kwargs.get('type', None) + self.status = kwargs.get('status', 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: any + """ + + _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.subscriptions.v2021_01_01.models.ErrorResponse] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.resource.subscriptions.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 Location(msrest.serialization.Model): + """Location information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The fully qualified ID of the location. For example, + /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. + :vartype id: str + :ivar subscription_id: The subscription ID. + :vartype subscription_id: str + :ivar name: The location name. + :vartype name: str + :ivar type: The location type. Possible values include: "Region", "EdgeZone". + :vartype type: str or ~azure.mgmt.resource.subscriptions.v2021_01_01.models.LocationType + :ivar display_name: The display name of the location. + :vartype display_name: str + :ivar regional_display_name: The display name of the location and its region. + :vartype regional_display_name: str + :param metadata: Metadata of the location, such as lat/long, paired region, and others. + :type metadata: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.LocationMetadata + """ + + _validation = { + 'id': {'readonly': True}, + 'subscription_id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'display_name': {'readonly': True}, + 'regional_display_name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'regional_display_name': {'key': 'regionalDisplayName', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': 'LocationMetadata'}, + } + + def __init__( + self, + **kwargs + ): + super(Location, self).__init__(**kwargs) + self.id = None + self.subscription_id = None + self.name = None + self.type = None + self.display_name = None + self.regional_display_name = None + self.metadata = kwargs.get('metadata', None) + + +class LocationListResult(msrest.serialization.Model): + """Location list operation response. + + :param value: An array of locations. + :type value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Location] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Location]'}, + } + + def __init__( + self, + **kwargs + ): + super(LocationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + + +class LocationMetadata(msrest.serialization.Model): + """Location metadata information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar region_type: The type of the region. Possible values include: "Physical", "Logical". + :vartype region_type: str or ~azure.mgmt.resource.subscriptions.v2021_01_01.models.RegionType + :ivar region_category: The category of the region. Possible values include: "Recommended", + "Extended", "Other". + :vartype region_category: str or + ~azure.mgmt.resource.subscriptions.v2021_01_01.models.RegionCategory + :ivar geography_group: The geography group of the location. + :vartype geography_group: str + :ivar longitude: The longitude of the location. + :vartype longitude: str + :ivar latitude: The latitude of the location. + :vartype latitude: str + :ivar physical_location: The physical location of the Azure location. + :vartype physical_location: str + :param paired_region: The regions paired to this region. + :type paired_region: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.PairedRegion] + :ivar home_location: The home location of an edge zone. + :vartype home_location: str + """ + + _validation = { + 'region_type': {'readonly': True}, + 'region_category': {'readonly': True}, + 'geography_group': {'readonly': True}, + 'longitude': {'readonly': True}, + 'latitude': {'readonly': True}, + 'physical_location': {'readonly': True}, + 'home_location': {'readonly': True}, + } + + _attribute_map = { + 'region_type': {'key': 'regionType', 'type': 'str'}, + 'region_category': {'key': 'regionCategory', 'type': 'str'}, + 'geography_group': {'key': 'geographyGroup', 'type': 'str'}, + 'longitude': {'key': 'longitude', 'type': 'str'}, + 'latitude': {'key': 'latitude', 'type': 'str'}, + 'physical_location': {'key': 'physicalLocation', 'type': 'str'}, + 'paired_region': {'key': 'pairedRegion', 'type': '[PairedRegion]'}, + 'home_location': {'key': 'homeLocation', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(LocationMetadata, self).__init__(**kwargs) + self.region_type = None + self.region_category = None + self.geography_group = None + self.longitude = None + self.latitude = None + self.physical_location = None + self.paired_region = kwargs.get('paired_region', None) + self.home_location = None + + +class ManagedByTenant(msrest.serialization.Model): + """Information about a tenant managing the subscription. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tenant_id: The tenant ID of the managing tenant. This is a GUID. + :vartype tenant_id: str + """ + + _validation = { + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ManagedByTenant, self).__init__(**kwargs) + self.tenant_id = 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.subscriptions.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.subscriptions.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 PairedRegion(msrest.serialization.Model): + """Information regarding paired region. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the paired region. + :vartype name: str + :ivar id: The fully qualified ID of the location. For example, + /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. + :vartype id: str + :ivar subscription_id: The subscription ID. + :vartype subscription_id: str + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'subscription_id': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PairedRegion, self).__init__(**kwargs) + self.name = None + self.id = None + self.subscription_id = None + + +class ResourceName(msrest.serialization.Model): + """Name and Type of the Resource. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. Name of the resource. + :type name: str + :param type: Required. The type of the resource. + :type type: str + """ + + _validation = { + 'name': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceName, self).__init__(**kwargs) + self.name = kwargs['name'] + self.type = kwargs['type'] + + +class Subscription(msrest.serialization.Model): + """Subscription information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The fully qualified ID for the subscription. For example, + /subscriptions/00000000-0000-0000-0000-000000000000. + :vartype id: str + :ivar subscription_id: The subscription ID. + :vartype subscription_id: str + :ivar display_name: The subscription display name. + :vartype display_name: str + :ivar tenant_id: The subscription tenant ID. + :vartype tenant_id: str + :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, + and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". + :vartype state: str or ~azure.mgmt.resource.subscriptions.v2021_01_01.models.SubscriptionState + :param subscription_policies: The subscription policies. + :type subscription_policies: + ~azure.mgmt.resource.subscriptions.v2021_01_01.models.SubscriptionPolicies + :param authorization_source: The authorization source of the request. Valid values are one or + more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, + RoleBased'. + :type authorization_source: str + :param managed_by_tenants: An array containing the tenants managing the subscription. + :type managed_by_tenants: + list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.ManagedByTenant] + :param tags: A set of tags. The tags attached to the subscription. + :type tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'subscription_id': {'readonly': True}, + 'display_name': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'state': {'key': 'state', 'type': 'str'}, + 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, + 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, + 'managed_by_tenants': {'key': 'managedByTenants', 'type': '[ManagedByTenant]'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(Subscription, self).__init__(**kwargs) + self.id = None + self.subscription_id = None + self.display_name = None + self.tenant_id = None + self.state = None + self.subscription_policies = kwargs.get('subscription_policies', None) + self.authorization_source = kwargs.get('authorization_source', None) + self.managed_by_tenants = kwargs.get('managed_by_tenants', None) + self.tags = kwargs.get('tags', None) + + +class SubscriptionListResult(msrest.serialization.Model): + """Subscription list operation response. + + All required parameters must be populated in order to send to Azure. + + :param value: An array of subscriptions. + :type value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Subscription] + :param next_link: Required. The URL to get the next set of results. + :type next_link: str + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Subscription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SubscriptionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs['next_link'] + + +class SubscriptionPolicies(msrest.serialization.Model): + """Subscription policies. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar location_placement_id: The subscription location placement ID. The ID indicates which + regions are visible for a subscription. For example, a subscription with a location placement + Id of Public_2014-09-01 has access to Azure public regions. + :vartype location_placement_id: str + :ivar quota_id: The subscription quota ID. + :vartype quota_id: str + :ivar spending_limit: The subscription spending limit. Possible values include: "On", "Off", + "CurrentPeriodOff". + :vartype spending_limit: str or + ~azure.mgmt.resource.subscriptions.v2021_01_01.models.SpendingLimit + """ + + _validation = { + 'location_placement_id': {'readonly': True}, + 'quota_id': {'readonly': True}, + 'spending_limit': {'readonly': True}, + } + + _attribute_map = { + 'location_placement_id': {'key': 'locationPlacementId', 'type': 'str'}, + 'quota_id': {'key': 'quotaId', 'type': 'str'}, + 'spending_limit': {'key': 'spendingLimit', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SubscriptionPolicies, self).__init__(**kwargs) + self.location_placement_id = None + self.quota_id = None + self.spending_limit = None + + +class TenantIdDescription(msrest.serialization.Model): + """Tenant Id information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The fully qualified ID of the tenant. For example, + /tenants/00000000-0000-0000-0000-000000000000. + :vartype id: str + :ivar tenant_id: The tenant ID. For example, 00000000-0000-0000-0000-000000000000. + :vartype tenant_id: str + :ivar tenant_category: Category of the tenant. Possible values include: "Home", "ProjectedBy", + "ManagedBy". + :vartype tenant_category: str or + ~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantCategory + :ivar country: Country/region name of the address for the tenant. + :vartype country: str + :ivar country_code: Country/region abbreviation for the tenant. + :vartype country_code: str + :ivar display_name: The display name of the tenant. + :vartype display_name: str + :ivar domains: The list of domains for the tenant. + :vartype domains: list[str] + :ivar default_domain: The default domain for the tenant. + :vartype default_domain: str + :ivar tenant_type: The tenant type. Only available for 'Home' tenant category. + :vartype tenant_type: str + :ivar tenant_branding_logo_url: The tenant's branding logo URL. Only available for 'Home' + tenant category. + :vartype tenant_branding_logo_url: str + """ + + _validation = { + 'id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'tenant_category': {'readonly': True}, + 'country': {'readonly': True}, + 'country_code': {'readonly': True}, + 'display_name': {'readonly': True}, + 'domains': {'readonly': True}, + 'default_domain': {'readonly': True}, + 'tenant_type': {'readonly': True}, + 'tenant_branding_logo_url': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'tenant_category': {'key': 'tenantCategory', 'type': 'str'}, + 'country': {'key': 'country', 'type': 'str'}, + 'country_code': {'key': 'countryCode', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'domains': {'key': 'domains', 'type': '[str]'}, + 'default_domain': {'key': 'defaultDomain', 'type': 'str'}, + 'tenant_type': {'key': 'tenantType', 'type': 'str'}, + 'tenant_branding_logo_url': {'key': 'tenantBrandingLogoUrl', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TenantIdDescription, self).__init__(**kwargs) + self.id = None + self.tenant_id = None + self.tenant_category = None + self.country = None + self.country_code = None + self.display_name = None + self.domains = None + self.default_domain = None + self.tenant_type = None + self.tenant_branding_logo_url = None + + +class TenantListResult(msrest.serialization.Model): + """Tenant Ids information. + + All required parameters must be populated in order to send to Azure. + + :param value: An array of tenants. + :type value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantIdDescription] + :param next_link: Required. The URL to use for getting the next set of results. + :type next_link: str + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TenantIdDescription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TenantListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs['next_link'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_models_py3.py new file mode 100644 index 000000000000..c49a2740875b --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_models_py3.py @@ -0,0 +1,693 @@ +# 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 ._subscription_client_enums import * + + +class CheckResourceNameResult(msrest.serialization.Model): + """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. + + :param name: Name of Resource. + :type name: str + :param type: Type of Resource. + :type type: str + :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + "Reserved". + :type status: str or ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceNameStatus + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + type: Optional[str] = None, + status: Optional[Union[str, "ResourceNameStatus"]] = None, + **kwargs + ): + super(CheckResourceNameResult, self).__init__(**kwargs) + self.name = name + self.type = type + self.status = status + + +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: any + """ + + _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.subscriptions.v2021_01_01.models.ErrorResponse] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.resource.subscriptions.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 Location(msrest.serialization.Model): + """Location information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The fully qualified ID of the location. For example, + /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. + :vartype id: str + :ivar subscription_id: The subscription ID. + :vartype subscription_id: str + :ivar name: The location name. + :vartype name: str + :ivar type: The location type. Possible values include: "Region", "EdgeZone". + :vartype type: str or ~azure.mgmt.resource.subscriptions.v2021_01_01.models.LocationType + :ivar display_name: The display name of the location. + :vartype display_name: str + :ivar regional_display_name: The display name of the location and its region. + :vartype regional_display_name: str + :param metadata: Metadata of the location, such as lat/long, paired region, and others. + :type metadata: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.LocationMetadata + """ + + _validation = { + 'id': {'readonly': True}, + 'subscription_id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'display_name': {'readonly': True}, + 'regional_display_name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'regional_display_name': {'key': 'regionalDisplayName', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': 'LocationMetadata'}, + } + + def __init__( + self, + *, + metadata: Optional["LocationMetadata"] = None, + **kwargs + ): + super(Location, self).__init__(**kwargs) + self.id = None + self.subscription_id = None + self.name = None + self.type = None + self.display_name = None + self.regional_display_name = None + self.metadata = metadata + + +class LocationListResult(msrest.serialization.Model): + """Location list operation response. + + :param value: An array of locations. + :type value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Location] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Location]'}, + } + + def __init__( + self, + *, + value: Optional[List["Location"]] = None, + **kwargs + ): + super(LocationListResult, self).__init__(**kwargs) + self.value = value + + +class LocationMetadata(msrest.serialization.Model): + """Location metadata information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar region_type: The type of the region. Possible values include: "Physical", "Logical". + :vartype region_type: str or ~azure.mgmt.resource.subscriptions.v2021_01_01.models.RegionType + :ivar region_category: The category of the region. Possible values include: "Recommended", + "Extended", "Other". + :vartype region_category: str or + ~azure.mgmt.resource.subscriptions.v2021_01_01.models.RegionCategory + :ivar geography_group: The geography group of the location. + :vartype geography_group: str + :ivar longitude: The longitude of the location. + :vartype longitude: str + :ivar latitude: The latitude of the location. + :vartype latitude: str + :ivar physical_location: The physical location of the Azure location. + :vartype physical_location: str + :param paired_region: The regions paired to this region. + :type paired_region: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.PairedRegion] + :ivar home_location: The home location of an edge zone. + :vartype home_location: str + """ + + _validation = { + 'region_type': {'readonly': True}, + 'region_category': {'readonly': True}, + 'geography_group': {'readonly': True}, + 'longitude': {'readonly': True}, + 'latitude': {'readonly': True}, + 'physical_location': {'readonly': True}, + 'home_location': {'readonly': True}, + } + + _attribute_map = { + 'region_type': {'key': 'regionType', 'type': 'str'}, + 'region_category': {'key': 'regionCategory', 'type': 'str'}, + 'geography_group': {'key': 'geographyGroup', 'type': 'str'}, + 'longitude': {'key': 'longitude', 'type': 'str'}, + 'latitude': {'key': 'latitude', 'type': 'str'}, + 'physical_location': {'key': 'physicalLocation', 'type': 'str'}, + 'paired_region': {'key': 'pairedRegion', 'type': '[PairedRegion]'}, + 'home_location': {'key': 'homeLocation', 'type': 'str'}, + } + + def __init__( + self, + *, + paired_region: Optional[List["PairedRegion"]] = None, + **kwargs + ): + super(LocationMetadata, self).__init__(**kwargs) + self.region_type = None + self.region_category = None + self.geography_group = None + self.longitude = None + self.latitude = None + self.physical_location = None + self.paired_region = paired_region + self.home_location = None + + +class ManagedByTenant(msrest.serialization.Model): + """Information about a tenant managing the subscription. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tenant_id: The tenant ID of the managing tenant. This is a GUID. + :vartype tenant_id: str + """ + + _validation = { + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ManagedByTenant, self).__init__(**kwargs) + self.tenant_id = 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.subscriptions.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.subscriptions.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 PairedRegion(msrest.serialization.Model): + """Information regarding paired region. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the paired region. + :vartype name: str + :ivar id: The fully qualified ID of the location. For example, + /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. + :vartype id: str + :ivar subscription_id: The subscription ID. + :vartype subscription_id: str + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'subscription_id': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PairedRegion, self).__init__(**kwargs) + self.name = None + self.id = None + self.subscription_id = None + + +class ResourceName(msrest.serialization.Model): + """Name and Type of the Resource. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. Name of the resource. + :type name: str + :param type: Required. The type of the resource. + :type type: str + """ + + _validation = { + 'name': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + type: str, + **kwargs + ): + super(ResourceName, self).__init__(**kwargs) + self.name = name + self.type = type + + +class Subscription(msrest.serialization.Model): + """Subscription information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The fully qualified ID for the subscription. For example, + /subscriptions/00000000-0000-0000-0000-000000000000. + :vartype id: str + :ivar subscription_id: The subscription ID. + :vartype subscription_id: str + :ivar display_name: The subscription display name. + :vartype display_name: str + :ivar tenant_id: The subscription tenant ID. + :vartype tenant_id: str + :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, + and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". + :vartype state: str or ~azure.mgmt.resource.subscriptions.v2021_01_01.models.SubscriptionState + :param subscription_policies: The subscription policies. + :type subscription_policies: + ~azure.mgmt.resource.subscriptions.v2021_01_01.models.SubscriptionPolicies + :param authorization_source: The authorization source of the request. Valid values are one or + more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, + RoleBased'. + :type authorization_source: str + :param managed_by_tenants: An array containing the tenants managing the subscription. + :type managed_by_tenants: + list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.ManagedByTenant] + :param tags: A set of tags. The tags attached to the subscription. + :type tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'subscription_id': {'readonly': True}, + 'display_name': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'state': {'key': 'state', 'type': 'str'}, + 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, + 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, + 'managed_by_tenants': {'key': 'managedByTenants', 'type': '[ManagedByTenant]'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + subscription_policies: Optional["SubscriptionPolicies"] = None, + authorization_source: Optional[str] = None, + managed_by_tenants: Optional[List["ManagedByTenant"]] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(Subscription, self).__init__(**kwargs) + self.id = None + self.subscription_id = None + self.display_name = None + self.tenant_id = None + self.state = None + self.subscription_policies = subscription_policies + self.authorization_source = authorization_source + self.managed_by_tenants = managed_by_tenants + self.tags = tags + + +class SubscriptionListResult(msrest.serialization.Model): + """Subscription list operation response. + + All required parameters must be populated in order to send to Azure. + + :param value: An array of subscriptions. + :type value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Subscription] + :param next_link: Required. The URL to get the next set of results. + :type next_link: str + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Subscription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + next_link: str, + value: Optional[List["Subscription"]] = None, + **kwargs + ): + super(SubscriptionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SubscriptionPolicies(msrest.serialization.Model): + """Subscription policies. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar location_placement_id: The subscription location placement ID. The ID indicates which + regions are visible for a subscription. For example, a subscription with a location placement + Id of Public_2014-09-01 has access to Azure public regions. + :vartype location_placement_id: str + :ivar quota_id: The subscription quota ID. + :vartype quota_id: str + :ivar spending_limit: The subscription spending limit. Possible values include: "On", "Off", + "CurrentPeriodOff". + :vartype spending_limit: str or + ~azure.mgmt.resource.subscriptions.v2021_01_01.models.SpendingLimit + """ + + _validation = { + 'location_placement_id': {'readonly': True}, + 'quota_id': {'readonly': True}, + 'spending_limit': {'readonly': True}, + } + + _attribute_map = { + 'location_placement_id': {'key': 'locationPlacementId', 'type': 'str'}, + 'quota_id': {'key': 'quotaId', 'type': 'str'}, + 'spending_limit': {'key': 'spendingLimit', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SubscriptionPolicies, self).__init__(**kwargs) + self.location_placement_id = None + self.quota_id = None + self.spending_limit = None + + +class TenantIdDescription(msrest.serialization.Model): + """Tenant Id information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The fully qualified ID of the tenant. For example, + /tenants/00000000-0000-0000-0000-000000000000. + :vartype id: str + :ivar tenant_id: The tenant ID. For example, 00000000-0000-0000-0000-000000000000. + :vartype tenant_id: str + :ivar tenant_category: Category of the tenant. Possible values include: "Home", "ProjectedBy", + "ManagedBy". + :vartype tenant_category: str or + ~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantCategory + :ivar country: Country/region name of the address for the tenant. + :vartype country: str + :ivar country_code: Country/region abbreviation for the tenant. + :vartype country_code: str + :ivar display_name: The display name of the tenant. + :vartype display_name: str + :ivar domains: The list of domains for the tenant. + :vartype domains: list[str] + :ivar default_domain: The default domain for the tenant. + :vartype default_domain: str + :ivar tenant_type: The tenant type. Only available for 'Home' tenant category. + :vartype tenant_type: str + :ivar tenant_branding_logo_url: The tenant's branding logo URL. Only available for 'Home' + tenant category. + :vartype tenant_branding_logo_url: str + """ + + _validation = { + 'id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'tenant_category': {'readonly': True}, + 'country': {'readonly': True}, + 'country_code': {'readonly': True}, + 'display_name': {'readonly': True}, + 'domains': {'readonly': True}, + 'default_domain': {'readonly': True}, + 'tenant_type': {'readonly': True}, + 'tenant_branding_logo_url': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'tenant_category': {'key': 'tenantCategory', 'type': 'str'}, + 'country': {'key': 'country', 'type': 'str'}, + 'country_code': {'key': 'countryCode', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'domains': {'key': 'domains', 'type': '[str]'}, + 'default_domain': {'key': 'defaultDomain', 'type': 'str'}, + 'tenant_type': {'key': 'tenantType', 'type': 'str'}, + 'tenant_branding_logo_url': {'key': 'tenantBrandingLogoUrl', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TenantIdDescription, self).__init__(**kwargs) + self.id = None + self.tenant_id = None + self.tenant_category = None + self.country = None + self.country_code = None + self.display_name = None + self.domains = None + self.default_domain = None + self.tenant_type = None + self.tenant_branding_logo_url = None + + +class TenantListResult(msrest.serialization.Model): + """Tenant Ids information. + + All required parameters must be populated in order to send to Azure. + + :param value: An array of tenants. + :type value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantIdDescription] + :param next_link: Required. The URL to use for getting the next set of results. + :type next_link: str + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TenantIdDescription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + next_link: str, + value: Optional[List["TenantIdDescription"]] = None, + **kwargs + ): + super(TenantListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_subscription_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_subscription_client_enums.py new file mode 100644 index 000000000000..ef07d8424e15 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_subscription_client_enums.py @@ -0,0 +1,82 @@ +# 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 LocationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The location type. + """ + + REGION = "Region" + EDGE_ZONE = "EdgeZone" + +class RegionCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The category of the region. + """ + + RECOMMENDED = "Recommended" + EXTENDED = "Extended" + OTHER = "Other" + +class RegionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of the region. + """ + + PHYSICAL = "Physical" + LOGICAL = "Logical" + +class ResourceNameStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Is the resource name Allowed or Reserved + """ + + ALLOWED = "Allowed" + RESERVED = "Reserved" + +class SpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The subscription spending limit. + """ + + ON = "On" + OFF = "Off" + CURRENT_PERIOD_OFF = "CurrentPeriodOff" + +class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. + """ + + ENABLED = "Enabled" + WARNED = "Warned" + PAST_DUE = "PastDue" + DISABLED = "Disabled" + DELETED = "Deleted" + +class TenantCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Category of the tenant. + """ + + HOME = "Home" + PROJECTED_BY = "ProjectedBy" + MANAGED_BY = "ManagedBy" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/__init__.py new file mode 100644 index 000000000000..2547a9583d70 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/__init__.py @@ -0,0 +1,17 @@ +# 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 ._subscriptions_operations import SubscriptionsOperations +from ._tenants_operations import TenantsOperations +from ._subscription_client_operations import SubscriptionClientOperationsMixin + +__all__ = [ + 'SubscriptionsOperations', + 'TenantsOperations', + 'SubscriptionClientOperationsMixin', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_subscription_client_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_subscription_client_operations.py new file mode 100644 index 000000000000..2f4de44a2ab3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_subscription_client_operations.py @@ -0,0 +1,87 @@ +# 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 SubscriptionClientOperationsMixin(object): + + def check_resource_name( + self, + resource_name_definition=None, # type: Optional["_models.ResourceName"] + **kwargs # type: Any + ): + # type: (...) -> "_models.CheckResourceNameResult" + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. + :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckResourceNameResult"] + 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.check_resource_name.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] + if resource_name_definition is not None: + body_content = self._serialize.body(resource_name_definition, 'ResourceName') + else: + body_content = None + 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('CheckResourceNameResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_subscriptions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_subscriptions_operations.py new file mode 100644 index 000000000000..a5a0667243c2 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_subscriptions_operations.py @@ -0,0 +1,241 @@ +# 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 SubscriptionsOperations(object): + """SubscriptionsOperations 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.subscriptions.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_locations( + self, + subscription_id, # type: str + include_extended_locations=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.LocationListResult"] + """Gets all available geo-locations. + + This operation provides all the locations that are available for resource providers; however, + each resource provider may support a subset of this list. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param include_extended_locations: Whether to include extended locations. + :type include_extended_locations: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LocationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.LocationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] + 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_locations.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", 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') + if include_extended_locations is not None: + query_parameters['includeExtendedLocations'] = self._serialize.query("include_extended_locations", include_extended_locations, 'bool') + + 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('LocationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + + def get( + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.Subscription" + """Gets details about a specified subscription. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Subscription, or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.Subscription + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Subscription"] + 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 = { + 'subscriptionId': self._serialize.url("subscription_id", 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('Subscription', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.SubscriptionListResult"] + """Gets all subscriptions for a tenant. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.SubscriptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] + 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('SubscriptionListResult', 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'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_tenants_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_tenants_operations.py new file mode 100644 index 000000000000..904300d56211 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_tenants_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 TenantsOperations(object): + """TenantsOperations 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.subscriptions.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.TenantListResult"] + """Gets the tenants for your account. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TenantListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] + 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('TenantListResult', 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': '/tenants'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/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/templatespecs/v2019_06_01_preview/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_version.py index 232662316d4d..e5754a47ce68 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 = "19.0.0" +VERSION = "1.0.0b1" 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 index 232662316d4d..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "19.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_version.py index 232662316d4d..e5754a47ce68 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "19.0.0" +VERSION = "1.0.0b1"