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 f0e74a66b2a8..5cb862ac32a8 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 @@ -46,7 +46,7 @@ class PolicyClient(MultiApiClientMixin, SDKClient): :type profile: azure.profiles.KnownProfiles """ - DEFAULT_API_VERSION = '2019-06-01' + DEFAULT_API_VERSION = '2019-09-01' _PROFILE_TAG = "azure.mgmt.resource.policy.PolicyClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -80,6 +80,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2018-05-01: :mod:`v2018_05_01.models` * 2019-01-01: :mod:`v2019_01_01.models` * 2019-06-01: :mod:`v2019_06_01.models` + * 2019-09-01: :mod:`v2019_09_01.models` """ if api_version == '2015-10-01-preview': from .v2015_10_01_preview import models @@ -105,6 +106,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2019-06-01': from .v2019_06_01 import models return models + elif api_version == '2019-09-01': + from .v2019_09_01 import models + return models raise NotImplementedError("APIVersion {} is not available".format(api_version)) @property @@ -119,6 +123,7 @@ def policy_assignments(self): * 2018-05-01: :class:`PolicyAssignmentsOperations` * 2019-01-01: :class:`PolicyAssignmentsOperations` * 2019-06-01: :class:`PolicyAssignmentsOperations` + * 2019-09-01: :class:`PolicyAssignmentsOperations` """ api_version = self._get_api_version('policy_assignments') if api_version == '2015-10-01-preview': @@ -137,6 +142,8 @@ def policy_assignments(self): from .v2019_01_01.operations import PolicyAssignmentsOperations as OperationClass elif api_version == '2019-06-01': from .v2019_06_01.operations import PolicyAssignmentsOperations as OperationClass + elif api_version == '2019-09-01': + from .v2019_09_01.operations import PolicyAssignmentsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -153,6 +160,7 @@ def policy_definitions(self): * 2018-05-01: :class:`PolicyDefinitionsOperations` * 2019-01-01: :class:`PolicyDefinitionsOperations` * 2019-06-01: :class:`PolicyDefinitionsOperations` + * 2019-09-01: :class:`PolicyDefinitionsOperations` """ api_version = self._get_api_version('policy_definitions') if api_version == '2015-10-01-preview': @@ -171,6 +179,8 @@ def policy_definitions(self): from .v2019_01_01.operations import PolicyDefinitionsOperations as OperationClass elif api_version == '2019-06-01': from .v2019_06_01.operations import PolicyDefinitionsOperations as OperationClass + elif api_version == '2019-09-01': + from .v2019_09_01.operations import PolicyDefinitionsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -184,6 +194,7 @@ def policy_set_definitions(self): * 2018-05-01: :class:`PolicySetDefinitionsOperations` * 2019-01-01: :class:`PolicySetDefinitionsOperations` * 2019-06-01: :class:`PolicySetDefinitionsOperations` + * 2019-09-01: :class:`PolicySetDefinitionsOperations` """ api_version = self._get_api_version('policy_set_definitions') if api_version == '2017-06-01-preview': @@ -196,6 +207,8 @@ def policy_set_definitions(self): from .v2019_01_01.operations import PolicySetDefinitionsOperations as OperationClass elif api_version == '2019-06-01': from .v2019_06_01.operations import PolicySetDefinitionsOperations as OperationClass + elif api_version == '2019-09-01': + from .v2019_09_01.operations import PolicySetDefinitionsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".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 e14bb6e177c2..1d5d79558e5e 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 .v2019_06_01.models import * +from .v2019_09_01.models import * diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/__init__.py new file mode 100644 index 000000000000..56bf47bfb9e4 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_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 ._configuration import PolicyClientConfiguration +from ._policy_client import PolicyClient +__all__ = ['PolicyClient', 'PolicyClientConfiguration'] + +from .version import VERSION + +__version__ = VERSION + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_configuration.py new file mode 100644 index 000000000000..ede4f42045d0 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_configuration.py @@ -0,0 +1,48 @@ +# 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 msrestazure import AzureConfiguration + +from .version import VERSION + + +class PolicyClientConfiguration(AzureConfiguration): + """Configuration for PolicyClient + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, credentials, subscription_id, base_url=None): + + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + if not base_url: + base_url = 'https://management.azure.com' + + super(PolicyClientConfiguration, self).__init__(base_url) + + # Starting Autorest.Python 4.0.64, make connection pool activated by default + self.keep_alive = True + + self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) + self.add_user_agent('Azure-SDK-For-Python') + + self.credentials = credentials + self.subscription_id = subscription_id diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_policy_client.py new file mode 100644 index 000000000000..b232c927bb8a --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_policy_client.py @@ -0,0 +1,59 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.service_client import SDKClient +from msrest import Serializer, Deserializer + +from ._configuration import PolicyClientConfiguration +from .operations import PolicyAssignmentsOperations +from .operations import PolicyDefinitionsOperations +from .operations import PolicySetDefinitionsOperations +from . import models + + +class PolicyClient(SDKClient): + """To manage and control access to your resources, you can define customized policies and assign them at a scope. + + :ivar config: Configuration for client. + :vartype config: PolicyClientConfiguration + + :ivar policy_assignments: PolicyAssignments operations + :vartype policy_assignments: azure.mgmt.resource.policy.v2019_09_01.operations.PolicyAssignmentsOperations + :ivar policy_definitions: PolicyDefinitions operations + :vartype policy_definitions: azure.mgmt.resource.policy.v2019_09_01.operations.PolicyDefinitionsOperations + :ivar policy_set_definitions: PolicySetDefinitions operations + :vartype policy_set_definitions: azure.mgmt.resource.policy.v2019_09_01.operations.PolicySetDefinitionsOperations + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, credentials, subscription_id, base_url=None): + + self.config = PolicyClientConfiguration(credentials, subscription_id, base_url) + super(PolicyClient, self).__init__(self.config.credentials, self.config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self.api_version = '2019-09-01' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/__init__.py new file mode 100644 index 000000000000..7bb65cbc04ac --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/__init__.py @@ -0,0 +1,68 @@ +# 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 ErrorAdditionalInfo + from ._models_py3 import ErrorResponse + from ._models_py3 import Identity + from ._models_py3 import ParameterDefinitionsValue + from ._models_py3 import ParameterDefinitionsValueMetadata + from ._models_py3 import ParameterValuesValue + from ._models_py3 import PolicyAssignment + from ._models_py3 import PolicyDefinition + from ._models_py3 import PolicyDefinitionGroup + from ._models_py3 import PolicyDefinitionReference + from ._models_py3 import PolicySetDefinition + from ._models_py3 import PolicySku +except (SyntaxError, ImportError): + from ._models import ErrorAdditionalInfo + from ._models import ErrorResponse + from ._models import Identity + from ._models import ParameterDefinitionsValue + from ._models import ParameterDefinitionsValueMetadata + from ._models import ParameterValuesValue + from ._models import PolicyAssignment + from ._models import PolicyDefinition + from ._models import PolicyDefinitionGroup + from ._models import PolicyDefinitionReference + from ._models import PolicySetDefinition + from ._models import PolicySku +from ._paged_models import PolicyAssignmentPaged +from ._paged_models import PolicyDefinitionPaged +from ._paged_models import PolicySetDefinitionPaged +from ._policy_client_enums import ( + EnforcementMode, + ResourceIdentityType, + PolicyType, + ParameterType, +) + +__all__ = [ + 'ErrorAdditionalInfo', + 'ErrorResponse', + 'Identity', + 'ParameterDefinitionsValue', + 'ParameterDefinitionsValueMetadata', + 'ParameterValuesValue', + 'PolicyAssignment', + 'PolicyDefinition', + 'PolicyDefinitionGroup', + 'PolicyDefinitionReference', + 'PolicySetDefinition', + 'PolicySku', + 'PolicyAssignmentPaged', + 'PolicyDefinitionPaged', + 'PolicySetDefinitionPaged', + 'EnforcementMode', + 'ResourceIdentityType', + 'PolicyType', + 'ParameterType', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_models.py new file mode 100644 index 000000000000..114036a52a39 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_models.py @@ -0,0 +1,558 @@ +# 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 msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class CloudError(Model): + """An error response from a policy operation. + + :param error: + :type error: ~azure.mgmt.resource.policy.v2019_09_01.models.ErrorResponse + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponse'}, + } + + def __init__(self, **kwargs): + super(CloudError, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class CloudErrorException(HttpOperationError): + """Server responsed with exception of type: 'CloudError'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) + + +class ErrorAdditionalInfo(Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: object + """ + + _validation = { + 'type': {'readonly': True}, + 'info': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'info': {'key': 'info', 'type': 'object'}, + } + + def __init__(self, **kwargs): + super(ErrorAdditionalInfo, self).__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorResponse(Model): + """The resource management error response. + + 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.v2019_09_01.models.ErrorResponse] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.resource.policy.v2019_09_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(Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar principal_id: The principal ID of the resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of the resource identity. + :vartype tenant_id: str + :param type: The identity type. Possible values include: 'SystemAssigned', + 'None' + :type type: str or + ~azure.mgmt.resource.policy.v2019_09_01.models.ResourceIdentityType + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + } + + def __init__(self, **kwargs): + super(Identity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = kwargs.get('type', None) + + +class ParameterDefinitionsValue(Model): + """ParameterDefinitionsValue. + + :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.v2019_09_01.models.ParameterType + :param allowed_values: The allowed values for the parameter. + :type allowed_values: list[object] + :param default_value: The default value for the parameter if no value is + provided. + :type default_value: object + :param metadata: General metadata for the parameter. + :type metadata: + ~azure.mgmt.resource.policy.v2019_09_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(Model): + """General metadata for the parameter. + + :param additional_properties: Unmatched properties from the message are + deserialized this collection + :type additional_properties: dict[str, object] + :param display_name: The display name for the parameter. + :type display_name: str + :param description: The description of the parameter. + :type description: str + """ + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + 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) + + +class ParameterValuesValue(Model): + """ParameterValuesValue. + + :param value: The value of the parameter. + :type value: object + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': 'object'}, + } + + def __init__(self, **kwargs): + super(ParameterValuesValue, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + + +class PolicyAssignment(Model): + """The policy assignment. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :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 + :param scope: The scope for the policy assignment. + :type 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.v2019_09_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: object + :param enforcement_mode: The policy assignment enforcement mode. Possible + values are Default and DoNotEnforce. Possible values include: 'Default', + 'DoNotEnforce' + :type enforcement_mode: str or + ~azure.mgmt.resource.policy.v2019_09_01.models.EnforcementMode + :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 sku: The policy sku. This property is optional, obsolete, and will + be ignored. + :type sku: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySku + :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.v2019_09_01.models.Identity + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + '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'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'PolicySku'}, + 'location': {'key': 'location', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + } + + def __init__(self, **kwargs): + super(PolicyAssignment, self).__init__(**kwargs) + self.display_name = kwargs.get('display_name', None) + self.policy_definition_id = kwargs.get('policy_definition_id', None) + self.scope = kwargs.get('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', None) + self.id = None + self.type = None + self.name = None + self.sku = kwargs.get('sku', None) + self.location = kwargs.get('location', None) + self.identity = kwargs.get('identity', None) + + +class PolicyDefinition(Model): + """The policy definition. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :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.v2019_09_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: object + :param metadata: The policy definition metadata. Metadata is an open + ended object and is typically a collection of key value pairs. + :type metadata: object + :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.v2019_09_01.models.ParameterDefinitionsValue] + :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 + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + '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}'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(PolicyDefinition, self).__init__(**kwargs) + self.policy_type = kwargs.get('policy_type', None) + self.mode = kwargs.get('mode', None) + 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) + self.id = None + self.name = None + self.type = None + + +class PolicyDefinitionGroup(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.get('name', None) + 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 PolicyDefinitionReference(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.v2019_09_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.get('policy_definition_id', None) + 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 PolicySetDefinition(Model): + """The policy set definition. + + 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. + + :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.v2019_09_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: object + :param parameters: The policy set definition parameters that can be used + in policy definition references. + :type parameters: dict[str, + ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterDefinitionsValue] + :param policy_definitions: Required. An array of policy definition + references. + :type policy_definitions: + list[~azure.mgmt.resource.policy.v2019_09_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.v2019_09_01.models.PolicyDefinitionGroup] + :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 + """ + + _validation = { + 'policy_definitions': {'required': True}, + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + '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]'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(PolicySetDefinition, self).__init__(**kwargs) + 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) + self.id = None + self.name = None + self.type = None + + +class PolicySku(Model): + """The policy sku. This property is optional, obsolete, and will be ignored. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The name of the policy sku. Possible values are A0 + and A1. + :type name: str + :param tier: The policy sku tier. Possible values are Free and Standard. + :type tier: str + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(PolicySku, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.tier = kwargs.get('tier', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_models_py3.py new file mode 100644 index 000000000000..1b95a34bd701 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_models_py3.py @@ -0,0 +1,558 @@ +# 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 msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class CloudError(Model): + """An error response from a policy operation. + + :param error: + :type error: ~azure.mgmt.resource.policy.v2019_09_01.models.ErrorResponse + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponse'}, + } + + def __init__(self, *, error=None, **kwargs) -> None: + super(CloudError, self).__init__(**kwargs) + self.error = error + + +class CloudErrorException(HttpOperationError): + """Server responsed with exception of type: 'CloudError'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) + + +class ErrorAdditionalInfo(Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: object + """ + + _validation = { + 'type': {'readonly': True}, + 'info': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'info': {'key': 'info', 'type': 'object'}, + } + + def __init__(self, **kwargs) -> None: + super(ErrorAdditionalInfo, self).__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorResponse(Model): + """The resource management error response. + + 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.v2019_09_01.models.ErrorResponse] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.resource.policy.v2019_09_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) -> None: + super(ErrorResponse, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class Identity(Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar principal_id: The principal ID of the resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of the resource identity. + :vartype tenant_id: str + :param type: The identity type. Possible values include: 'SystemAssigned', + 'None' + :type type: str or + ~azure.mgmt.resource.policy.v2019_09_01.models.ResourceIdentityType + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + } + + def __init__(self, *, type=None, **kwargs) -> None: + super(Identity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + + +class ParameterDefinitionsValue(Model): + """ParameterDefinitionsValue. + + :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.v2019_09_01.models.ParameterType + :param allowed_values: The allowed values for the parameter. + :type allowed_values: list[object] + :param default_value: The default value for the parameter if no value is + provided. + :type default_value: object + :param metadata: General metadata for the parameter. + :type metadata: + ~azure.mgmt.resource.policy.v2019_09_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=None, allowed_values=None, default_value=None, metadata=None, **kwargs) -> None: + super(ParameterDefinitionsValue, self).__init__(**kwargs) + self.type = type + self.allowed_values = allowed_values + self.default_value = default_value + self.metadata = metadata + + +class ParameterDefinitionsValueMetadata(Model): + """General metadata for the parameter. + + :param additional_properties: Unmatched properties from the message are + deserialized this collection + :type additional_properties: dict[str, object] + :param display_name: The display name for the parameter. + :type display_name: str + :param description: The description of the parameter. + :type description: str + """ + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__(self, *, additional_properties=None, display_name: str=None, description: str=None, **kwargs) -> None: + super(ParameterDefinitionsValueMetadata, self).__init__(**kwargs) + self.additional_properties = additional_properties + self.display_name = display_name + self.description = description + + +class ParameterValuesValue(Model): + """ParameterValuesValue. + + :param value: The value of the parameter. + :type value: object + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': 'object'}, + } + + def __init__(self, *, value=None, **kwargs) -> None: + super(ParameterValuesValue, self).__init__(**kwargs) + self.value = value + + +class PolicyAssignment(Model): + """The policy assignment. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :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 + :param scope: The scope for the policy assignment. + :type 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.v2019_09_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: object + :param enforcement_mode: The policy assignment enforcement mode. Possible + values are Default and DoNotEnforce. Possible values include: 'Default', + 'DoNotEnforce' + :type enforcement_mode: str or + ~azure.mgmt.resource.policy.v2019_09_01.models.EnforcementMode + :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 sku: The policy sku. This property is optional, obsolete, and will + be ignored. + :type sku: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySku + :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.v2019_09_01.models.Identity + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + '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'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'PolicySku'}, + 'location': {'key': 'location', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + } + + def __init__(self, *, display_name: str=None, policy_definition_id: str=None, scope: str=None, not_scopes=None, parameters=None, description: str=None, metadata=None, enforcement_mode=None, sku=None, location: str=None, identity=None, **kwargs) -> None: + super(PolicyAssignment, self).__init__(**kwargs) + self.display_name = display_name + self.policy_definition_id = policy_definition_id + self.scope = scope + self.not_scopes = not_scopes + self.parameters = parameters + self.description = description + self.metadata = metadata + self.enforcement_mode = enforcement_mode + self.id = None + self.type = None + self.name = None + self.sku = sku + self.location = location + self.identity = identity + + +class PolicyDefinition(Model): + """The policy definition. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :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.v2019_09_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: object + :param metadata: The policy definition metadata. Metadata is an open + ended object and is typically a collection of key value pairs. + :type metadata: object + :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.v2019_09_01.models.ParameterDefinitionsValue] + :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 + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + '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}'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__(self, *, policy_type=None, mode: str=None, display_name: str=None, description: str=None, policy_rule=None, metadata=None, parameters=None, **kwargs) -> None: + super(PolicyDefinition, self).__init__(**kwargs) + 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 + self.id = None + self.name = None + self.type = None + + +class PolicyDefinitionGroup(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: str=None, category: str=None, description: str=None, additional_metadata_id: str=None, **kwargs) -> None: + 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 PolicyDefinitionReference(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.v2019_09_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=None, policy_definition_reference_id: str=None, group_names=None, **kwargs) -> None: + 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 PolicySetDefinition(Model): + """The policy set definition. + + 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. + + :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.v2019_09_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: object + :param parameters: The policy set definition parameters that can be used + in policy definition references. + :type parameters: dict[str, + ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterDefinitionsValue] + :param policy_definitions: Required. An array of policy definition + references. + :type policy_definitions: + list[~azure.mgmt.resource.policy.v2019_09_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.v2019_09_01.models.PolicyDefinitionGroup] + :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 + """ + + _validation = { + 'policy_definitions': {'required': True}, + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + '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]'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__(self, *, policy_definitions, policy_type=None, display_name: str=None, description: str=None, metadata=None, parameters=None, policy_definition_groups=None, **kwargs) -> None: + super(PolicySetDefinition, self).__init__(**kwargs) + 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 + self.id = None + self.name = None + self.type = None + + +class PolicySku(Model): + """The policy sku. This property is optional, obsolete, and will be ignored. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The name of the policy sku. Possible values are A0 + and A1. + :type name: str + :param tier: The policy sku tier. Possible values are Free and Standard. + :type tier: str + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + } + + def __init__(self, *, name: str, tier: str=None, **kwargs) -> None: + super(PolicySku, self).__init__(**kwargs) + self.name = name + self.tier = tier diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_paged_models.py new file mode 100644 index 000000000000..d6168d1d62aa --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_paged_models.py @@ -0,0 +1,53 @@ +# 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 msrest.paging import Paged + + +class PolicyAssignmentPaged(Paged): + """ + A paging container for iterating over a list of :class:`PolicyAssignment ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[PolicyAssignment]'} + } + + def __init__(self, *args, **kwargs): + + super(PolicyAssignmentPaged, self).__init__(*args, **kwargs) +class PolicyDefinitionPaged(Paged): + """ + A paging container for iterating over a list of :class:`PolicyDefinition ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[PolicyDefinition]'} + } + + def __init__(self, *args, **kwargs): + + super(PolicyDefinitionPaged, self).__init__(*args, **kwargs) +class PolicySetDefinitionPaged(Paged): + """ + A paging container for iterating over a list of :class:`PolicySetDefinition ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[PolicySetDefinition]'} + } + + def __init__(self, *args, **kwargs): + + super(PolicySetDefinitionPaged, self).__init__(*args, **kwargs) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_policy_client_enums.py new file mode 100644 index 000000000000..355e37daa4a5 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_policy_client_enums.py @@ -0,0 +1,43 @@ +# 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 + + +class EnforcementMode(str, Enum): + + default = "Default" #: The policy effect is enforced during resource creation or update. + do_not_enforce = "DoNotEnforce" #: The policy effect is not enforced during resource creation or update. + + +class ResourceIdentityType(str, Enum): + + system_assigned = "SystemAssigned" + none = "None" + + +class PolicyType(str, Enum): + + not_specified = "NotSpecified" + built_in = "BuiltIn" + custom = "Custom" + static = "Static" + + +class ParameterType(str, Enum): + + string = "String" + array = "Array" + object_enum = "Object" + boolean = "Boolean" + integer = "Integer" + float_enum = "Float" + date_time_enum = "DateTime" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/__init__.py new file mode 100644 index 000000000000..c7d7b8eb9d97 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/__init__.py @@ -0,0 +1,20 @@ +# 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_assignments_operations import PolicyAssignmentsOperations +from ._policy_definitions_operations import PolicyDefinitionsOperations +from ._policy_set_definitions_operations import PolicySetDefinitionsOperations + +__all__ = [ + 'PolicyAssignmentsOperations', + 'PolicyDefinitionsOperations', + 'PolicySetDefinitionsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_policy_assignments_operations.py new file mode 100644 index 000000000000..f6bf86d9c05a --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_policy_assignments_operations.py @@ -0,0 +1,788 @@ +# 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 uuid +from msrest.pipeline import ClientRawResponse +from msrestazure.azure_exceptions import CloudError + +from .. import models + + +class PolicyAssignmentsOperations(object): + """PolicyAssignmentsOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: The API version to use for the operation. Constant value: "2019-09-01". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2019-09-01" + + self.config = config + + def delete( + self, scope, policy_assignment_name, custom_headers=None, raw=False, **operation_config): + """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 + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyAssignment or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.delete.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 204]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyAssignment', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + + def create( + self, scope, policy_assignment_name, parameters, custom_headers=None, raw=False, **operation_config): + """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.v2019_09_01.models.PolicyAssignment + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyAssignment or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.create.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(parameters, 'PolicyAssignment') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [201]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + if response.status_code == 201: + deserialized = self._deserialize('PolicyAssignment', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + + def get( + self, scope, policy_assignment_name, custom_headers=None, raw=False, **operation_config): + """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 + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyAssignment or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyAssignment', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + + def list_for_resource_group( + self, resource_group_name, filter=None, custom_headers=None, raw=False, **operation_config): + """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()' 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=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()' or 'policyDefinitionId eq '{value}''. If + $filter is not provided, no filtering is performed. + :type filter: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of PolicyAssignment + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment] + :raises: :class:`CloudError` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_for_resource_group.metadata['url'] + 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 = {} + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} + + def list_for_resource( + self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter=None, custom_headers=None, raw=False, **operation_config): + """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()' 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=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()' or 'policyDefinitionId eq '{value}''. If + $filter is not provided, no filtering is performed. + :type filter: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of PolicyAssignment + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment] + :raises: :class:`CloudError` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_for_resource.metadata['url'] + 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 = {} + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} + + def list( + self, filter=None, custom_headers=None, raw=False, **operation_config): + """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()' 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=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()' or 'policyDefinitionId eq '{value}''. If + $filter is not provided, no filtering is performed. + :type filter: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of PolicyAssignment + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment] + :raises: :class:`CloudError` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + 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 = {} + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} + + def delete_by_id( + self, policy_assignment_id, custom_headers=None, raw=False, **operation_config): + """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 + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyAssignment or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.delete_by_id.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 204]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyAssignment', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} + + def create_by_id( + self, policy_assignment_id, parameters, custom_headers=None, raw=False, **operation_config): + """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.v2019_09_01.models.PolicyAssignment + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyAssignment or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.create_by_id.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(parameters, 'PolicyAssignment') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [201]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + if response.status_code == 201: + deserialized = self._deserialize('PolicyAssignment', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} + + def get_by_id( + self, policy_assignment_id, custom_headers=None, raw=False, **operation_config): + """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 + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyAssignment or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get_by_id.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyAssignment', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_policy_definitions_operations.py new file mode 100644 index 000000000000..09efe4909d9b --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_policy_definitions_operations.py @@ -0,0 +1,686 @@ +# 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 uuid +from msrest.pipeline import ClientRawResponse +from msrestazure.azure_exceptions import CloudError + +from .. import models + + +class PolicyDefinitionsOperations(object): + """PolicyDefinitionsOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: The API version to use for the operation. Constant value: "2019-09-01". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2019-09-01" + + self.config = config + + def create_or_update( + self, policy_definition_name, parameters, custom_headers=None, raw=False, **operation_config): + """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.v2019_09_01.models.PolicyDefinition + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyDefinition or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.create_or_update.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(parameters, 'PolicyDefinition') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [201]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + if response.status_code == 201: + deserialized = self._deserialize('PolicyDefinition', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + + def delete( + self, policy_definition_name, custom_headers=None, raw=False, **operation_config): + """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 + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.delete.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 204]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + + def get( + self, policy_definition_name, custom_headers=None, raw=False, **operation_config): + """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 + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyDefinition or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyDefinition', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + + def get_built_in( + self, policy_definition_name, custom_headers=None, raw=False, **operation_config): + """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 + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyDefinition or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get_built_in.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyDefinition', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + + def create_or_update_at_management_group( + self, policy_definition_name, parameters, management_group_id, custom_headers=None, raw=False, **operation_config): + """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 parameters: The policy definition properties. + :type parameters: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyDefinition or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.create_or_update_at_management_group.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(parameters, 'PolicyDefinition') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [201]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + if response.status_code == 201: + deserialized = self._deserialize('PolicyDefinition', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + + def delete_at_management_group( + self, policy_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): + """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 + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.delete_at_management_group.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 204]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + + def get_at_management_group( + self, policy_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): + """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 + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyDefinition or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get_at_management_group.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyDefinition', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + + def list( + self, custom_headers=None, raw=False, **operation_config): + """Retrieves policy definitions in a subscription. + + This operation retrieves a list of all the policy definitions in a + given subscription. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of PolicyDefinition + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition] + :raises: :class:`CloudError` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} + + def list_built_in( + self, custom_headers=None, raw=False, **operation_config): + """Retrieve built-in policy definitions. + + This operation retrieves a list of all the built-in policy definitions. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of PolicyDefinition + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition] + :raises: :class:`CloudError` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_built_in.metadata['url'] + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} + + def list_by_management_group( + self, management_group_id, custom_headers=None, raw=False, **operation_config): + """Retrieve policy definitions in a management group. + + This operation retrieves a list of all the policy definitions in a + given management group. + + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of PolicyDefinition + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition] + :raises: :class:`CloudError` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_management_group.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_policy_set_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_policy_set_definitions_operations.py new file mode 100644 index 000000000000..07a26ff53a2c --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_policy_set_definitions_operations.py @@ -0,0 +1,691 @@ +# 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 uuid +from msrest.pipeline import ClientRawResponse +from msrestazure.azure_exceptions import CloudError + +from .. import models + + +class PolicySetDefinitionsOperations(object): + """PolicySetDefinitionsOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: The API version to use for the operation. Constant value: "2019-09-01". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2019-09-01" + + self.config = config + + def create_or_update( + self, policy_set_definition_name, parameters, custom_headers=None, raw=False, **operation_config): + """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.v2019_09_01.models.PolicySetDefinition + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicySetDefinition or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.create_or_update.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(parameters, 'PolicySetDefinition') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 201]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicySetDefinition', response) + if response.status_code == 201: + deserialized = self._deserialize('PolicySetDefinition', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + + def delete( + self, policy_set_definition_name, custom_headers=None, raw=False, **operation_config): + """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 + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.delete.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 204]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + + def get( + self, policy_set_definition_name, custom_headers=None, raw=False, **operation_config): + """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 + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicySetDefinition or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicySetDefinition', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + + def get_built_in( + self, policy_set_definition_name, custom_headers=None, raw=False, **operation_config): + """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 + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicySetDefinition or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get_built_in.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicySetDefinition', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + + def list( + self, custom_headers=None, raw=False, **operation_config): + """Retrieves the policy set definitions for a subscription. + + This operation retrieves a list of all the policy set definitions in + the given subscription. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of PolicySetDefinition + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition] + :raises: :class:`CloudError` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.PolicySetDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions'} + + def list_built_in( + self, custom_headers=None, raw=False, **operation_config): + """Retrieves built-in policy set definitions. + + This operation retrieves a list of all the built-in policy set + definitions. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of PolicySetDefinition + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition] + :raises: :class:`CloudError` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_built_in.metadata['url'] + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.PolicySetDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} + + def create_or_update_at_management_group( + self, policy_set_definition_name, parameters, management_group_id, custom_headers=None, raw=False, **operation_config): + """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 parameters: The policy set definition properties. + :type parameters: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicySetDefinition or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.create_or_update_at_management_group.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(parameters, 'PolicySetDefinition') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 201]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicySetDefinition', response) + if response.status_code == 201: + deserialized = self._deserialize('PolicySetDefinition', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + + def delete_at_management_group( + self, policy_set_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): + """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 + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.delete_at_management_group.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 204]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + + def get_at_management_group( + self, policy_set_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): + """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 + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicySetDefinition or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get_at_management_group.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicySetDefinition', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + + def list_by_management_group( + self, management_group_id, custom_headers=None, raw=False, **operation_config): + """Retrieves all policy set definitions in management group. + + This operation retrieves a list of all the a policy set definition in + the given management group. + + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of PolicySetDefinition + :rtype: + ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition] + :raises: :class:`CloudError` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_management_group.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.PolicySetDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions'} 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 new file mode 100644 index 000000000000..c438021f6b89 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/version.py @@ -0,0 +1,13 @@ +# 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 = "2019-09-01" + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/__init__.py index 7f71f20a961b..bee7b2ee4105 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/__init__.py @@ -51,6 +51,7 @@ from ._models_py3 import ResourceGroupProperties from ._models_py3 import ResourceProviderOperationDisplayProperties from ._models_py3 import ResourcesMoveInfo + from ._models_py3 import ScopedDeployment from ._models_py3 import Sku from ._models_py3 import SubResource from ._models_py3 import TagCount @@ -104,6 +105,7 @@ from ._models import ResourceGroupProperties from ._models import ResourceProviderOperationDisplayProperties from ._models import ResourcesMoveInfo + from ._models import ScopedDeployment from ._models import Sku from ._models import SubResource from ._models import TagCount @@ -173,6 +175,7 @@ 'ResourceGroupProperties', 'ResourceProviderOperationDisplayProperties', 'ResourcesMoveInfo', + 'ScopedDeployment', 'Sku', 'SubResource', 'TagCount', diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_models.py index 525c93fe0bad..626f842725b3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_models.py @@ -1413,6 +1413,34 @@ def __init__(self, **kwargs): self.target_resource_group = kwargs.get('target_resource_group', None) +class ScopedDeployment(Model): + """Deployment operation parameters. + + All required parameters must be populated in order to send to Azure. + + :param location: Required. The location to store the deployment data. + :type location: str + :param properties: Required. The deployment properties. + :type properties: + ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + """ + + _validation = { + 'location': {'required': True}, + 'properties': {'required': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, + } + + def __init__(self, **kwargs): + super(ScopedDeployment, self).__init__(**kwargs) + self.location = kwargs.get('location', None) + self.properties = kwargs.get('properties', None) + + class Sku(Model): """SKU for the resource. diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_models_py3.py index 9ed400df10a7..aaac8bcaffd6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_models_py3.py @@ -1413,6 +1413,34 @@ def __init__(self, *, resources=None, target_resource_group: str=None, **kwargs) self.target_resource_group = target_resource_group +class ScopedDeployment(Model): + """Deployment operation parameters. + + All required parameters must be populated in order to send to Azure. + + :param location: Required. The location to store the deployment data. + :type location: str + :param properties: Required. The deployment properties. + :type properties: + ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + """ + + _validation = { + 'location': {'required': True}, + 'properties': {'required': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, + } + + def __init__(self, *, location: str, properties, **kwargs) -> None: + super(ScopedDeployment, self).__init__(**kwargs) + self.location = location + self.properties = properties + + class Sku(Model): """SKU for the resource. diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_deployments_operations.py index 26406e6a8e31..d10519d69f0f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_deployments_operations.py @@ -765,8 +765,8 @@ def check_existence_at_tenant_scope( def _create_or_update_at_tenant_scope_initial( - self, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.Deployment(location=location, properties=properties) + self, deployment_name, location, properties, custom_headers=None, raw=False, **operation_config): + parameters = models.ScopedDeployment(location=location, properties=properties) # Construct URL url = self.create_or_update_at_tenant_scope.metadata['url'] @@ -791,7 +791,7 @@ def _create_or_update_at_tenant_scope_initial( header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body - body_content = self._serialize.body(parameters, 'Deployment') + body_content = self._serialize.body(parameters, 'ScopedDeployment') # Construct and send request request = self._client.put(url, query_parameters, header_parameters, body_content) @@ -816,7 +816,7 @@ def _create_or_update_at_tenant_scope_initial( return deserialized def create_or_update_at_tenant_scope( - self, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): + self, deployment_name, location, properties, custom_headers=None, raw=False, polling=True, **operation_config): """Deploys resources at tenant scope. You can provide the template and parameters directly in the request or @@ -824,11 +824,11 @@ def create_or_update_at_tenant_scope( :param deployment_name: The name of the deployment. :type deployment_name: str + :param location: The location to store the deployment data. + :type location: str :param properties: The deployment properties. :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties - :param location: The location to store the deployment data. - :type location: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response @@ -844,8 +844,8 @@ def create_or_update_at_tenant_scope( """ raw_result = self._create_or_update_at_tenant_scope_initial( deployment_name=deployment_name, - properties=properties, location=location, + properties=properties, custom_headers=custom_headers, raw=True, **operation_config @@ -983,17 +983,17 @@ def cancel_at_tenant_scope( cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} def validate_at_tenant_scope( - self, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): + self, deployment_name, location, properties, custom_headers=None, raw=False, **operation_config): """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param deployment_name: The name of the deployment. :type deployment_name: str + :param location: The location to store the deployment data. + :type location: str :param properties: The deployment properties. :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties - :param location: The location to store the deployment data. - :type location: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -1005,7 +1005,7 @@ def validate_at_tenant_scope( or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ - parameters = models.Deployment(location=location, properties=properties) + parameters = models.ScopedDeployment(location=location, properties=properties) # Construct URL url = self.validate_at_tenant_scope.metadata['url'] @@ -1030,7 +1030,7 @@ def validate_at_tenant_scope( header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body - body_content = self._serialize.body(parameters, 'Deployment') + body_content = self._serialize.body(parameters, 'ScopedDeployment') # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) @@ -1329,8 +1329,8 @@ def check_existence_at_management_group_scope( def _create_or_update_at_management_group_scope_initial( - self, group_id, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.Deployment(location=location, properties=properties) + self, group_id, deployment_name, location, properties, custom_headers=None, raw=False, **operation_config): + parameters = models.ScopedDeployment(location=location, properties=properties) # Construct URL url = self.create_or_update_at_management_group_scope.metadata['url'] @@ -1356,7 +1356,7 @@ def _create_or_update_at_management_group_scope_initial( header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body - body_content = self._serialize.body(parameters, 'Deployment') + body_content = self._serialize.body(parameters, 'ScopedDeployment') # Construct and send request request = self._client.put(url, query_parameters, header_parameters, body_content) @@ -1381,7 +1381,7 @@ def _create_or_update_at_management_group_scope_initial( return deserialized def create_or_update_at_management_group_scope( - self, group_id, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): + self, group_id, deployment_name, location, properties, custom_headers=None, raw=False, polling=True, **operation_config): """Deploys resources at management group scope. You can provide the template and parameters directly in the request or @@ -1391,11 +1391,11 @@ def create_or_update_at_management_group_scope( :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str + :param location: The location to store the deployment data. + :type location: str :param properties: The deployment properties. :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties - :param location: The location to store the deployment data. - :type location: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response @@ -1412,8 +1412,8 @@ def create_or_update_at_management_group_scope( raw_result = self._create_or_update_at_management_group_scope_initial( group_id=group_id, deployment_name=deployment_name, - properties=properties, location=location, + properties=properties, custom_headers=custom_headers, raw=True, **operation_config @@ -1557,7 +1557,7 @@ def cancel_at_management_group_scope( cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} def validate_at_management_group_scope( - self, group_id, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): + self, group_id, deployment_name, location, properties, custom_headers=None, raw=False, **operation_config): """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. @@ -1565,11 +1565,11 @@ def validate_at_management_group_scope( :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str + :param location: The location to store the deployment data. + :type location: str :param properties: The deployment properties. :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties - :param location: The location to store the deployment data. - :type location: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -1581,7 +1581,7 @@ def validate_at_management_group_scope( or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ - parameters = models.Deployment(location=location, properties=properties) + parameters = models.ScopedDeployment(location=location, properties=properties) # Construct URL url = self.validate_at_management_group_scope.metadata['url'] @@ -1607,7 +1607,7 @@ def validate_at_management_group_scope( header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body - body_content = self._serialize.body(parameters, 'Deployment') + body_content = self._serialize.body(parameters, 'ScopedDeployment') # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content)