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 aacf7f31a797..f0e74a66b2a8 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-01-01' + DEFAULT_API_VERSION = '2019-06-01' _PROFILE_TAG = "azure.mgmt.resource.policy.PolicyClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -79,6 +79,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2018-03-01: :mod:`v2018_03_01.models` * 2018-05-01: :mod:`v2018_05_01.models` * 2019-01-01: :mod:`v2019_01_01.models` + * 2019-06-01: :mod:`v2019_06_01.models` """ if api_version == '2015-10-01-preview': from .v2015_10_01_preview import models @@ -101,6 +102,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2019-01-01': from .v2019_01_01 import models return models + elif api_version == '2019-06-01': + from .v2019_06_01 import models + return models raise NotImplementedError("APIVersion {} is not available".format(api_version)) @property @@ -114,6 +118,7 @@ def policy_assignments(self): * 2018-03-01: :class:`PolicyAssignmentsOperations` * 2018-05-01: :class:`PolicyAssignmentsOperations` * 2019-01-01: :class:`PolicyAssignmentsOperations` + * 2019-06-01: :class:`PolicyAssignmentsOperations` """ api_version = self._get_api_version('policy_assignments') if api_version == '2015-10-01-preview': @@ -130,6 +135,8 @@ def policy_assignments(self): from .v2018_05_01.operations import PolicyAssignmentsOperations as OperationClass elif api_version == '2019-01-01': from .v2019_01_01.operations import PolicyAssignmentsOperations as OperationClass + elif api_version == '2019-06-01': + from .v2019_06_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))) @@ -145,6 +152,7 @@ def policy_definitions(self): * 2018-03-01: :class:`PolicyDefinitionsOperations` * 2018-05-01: :class:`PolicyDefinitionsOperations` * 2019-01-01: :class:`PolicyDefinitionsOperations` + * 2019-06-01: :class:`PolicyDefinitionsOperations` """ api_version = self._get_api_version('policy_definitions') if api_version == '2015-10-01-preview': @@ -161,6 +169,8 @@ def policy_definitions(self): from .v2018_05_01.operations import PolicyDefinitionsOperations as OperationClass elif api_version == '2019-01-01': from .v2019_01_01.operations import PolicyDefinitionsOperations as OperationClass + elif api_version == '2019-06-01': + from .v2019_06_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))) @@ -173,6 +183,7 @@ def policy_set_definitions(self): * 2018-03-01: :class:`PolicySetDefinitionsOperations` * 2018-05-01: :class:`PolicySetDefinitionsOperations` * 2019-01-01: :class:`PolicySetDefinitionsOperations` + * 2019-06-01: :class:`PolicySetDefinitionsOperations` """ api_version = self._get_api_version('policy_set_definitions') if api_version == '2017-06-01-preview': @@ -183,6 +194,8 @@ def policy_set_definitions(self): from .v2018_05_01.operations import PolicySetDefinitionsOperations as OperationClass elif api_version == '2019-01-01': from .v2019_01_01.operations import PolicySetDefinitionsOperations as OperationClass + elif api_version == '2019-06-01': + from .v2019_06_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 97f53e8a7934..e14bb6e177c2 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_01_01.models import * +from .v2019_06_01.models import * diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/__init__.py new file mode 100644 index 000000000000..56bf47bfb9e4 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from ._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_06_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_configuration.py new file mode 100644 index 000000000000..ede4f42045d0 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_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_06_01/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_policy_client.py new file mode 100644 index 000000000000..9becba788cc5 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_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_06_01.operations.PolicyAssignmentsOperations + :ivar policy_definitions: PolicyDefinitions operations + :vartype policy_definitions: azure.mgmt.resource.policy.v2019_06_01.operations.PolicyDefinitionsOperations + :ivar policy_set_definitions: PolicySetDefinitions operations + :vartype policy_set_definitions: azure.mgmt.resource.policy.v2019_06_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-06-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_06_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/__init__.py new file mode 100644 index 000000000000..871692defb76 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/__init__.py @@ -0,0 +1,51 @@ +# 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 ErrorResponse, ErrorResponseException + from ._models_py3 import Identity + from ._models_py3 import PolicyAssignment + from ._models_py3 import PolicyDefinition + from ._models_py3 import PolicyDefinitionReference + from ._models_py3 import PolicySetDefinition + from ._models_py3 import PolicySku +except (SyntaxError, ImportError): + from ._models import ErrorResponse, ErrorResponseException + from ._models import Identity + from ._models import PolicyAssignment + from ._models import PolicyDefinition + 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, +) + +__all__ = [ + 'ErrorResponse', 'ErrorResponseException', + 'Identity', + 'PolicyAssignment', + 'PolicyDefinition', + 'PolicyDefinitionReference', + 'PolicySetDefinition', + 'PolicySku', + 'PolicyAssignmentPaged', + 'PolicyDefinitionPaged', + 'PolicySetDefinitionPaged', + 'EnforcementMode', + 'ResourceIdentityType', + 'PolicyType', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_models.py new file mode 100644 index 000000000000..6d76cbd87a01 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_models.py @@ -0,0 +1,358 @@ +# 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): + """CloudError. + """ + + _attribute_map = { + } + + +class ErrorResponse(Model): + """Error response indicates Azure Resource Manager is not able to process the + incoming request. The reason is provided in the error message. + + :param http_status: Http status code. + :type http_status: str + :param error_code: Error code. + :type error_code: str + :param error_message: Error message indicating why the operation failed. + :type error_message: str + """ + + _attribute_map = { + 'http_status': {'key': 'httpStatus', 'type': 'str'}, + 'error_code': {'key': 'errorCode', 'type': 'str'}, + 'error_message': {'key': 'errorMessage', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ErrorResponse, self).__init__(**kwargs) + self.http_status = kwargs.get('http_status', None) + self.error_code = kwargs.get('error_code', None) + self.error_message = kwargs.get('error_message', None) + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) + + +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_06_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 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: Required if a parameter is used in policy rule. + :type parameters: object + :param description: This message will be part of response in case of + policy violation. + :type description: str + :param metadata: The policy assignment metadata. + :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_06_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_06_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_06_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': 'object'}, + '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, and Custom. Possible values include: + 'NotSpecified', 'BuiltIn', 'Custom' + :type policy_type: str or + ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyType + :param mode: The policy definition mode. Some examples are All, Indexed, + Microsoft.KeyVault.Data. + :type mode: str + :param display_name: The display name of the policy definition. + :type display_name: str + :param description: The policy definition description. + :type description: str + :param policy_rule: The policy rule. + :type policy_rule: object + :param metadata: The policy definition metadata. + :type metadata: object + :param parameters: Required if a parameter is used in policy rule. + :type parameters: object + :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': 'object'}, + '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 PolicyDefinitionReference(Model): + """The policy definition reference. + + :param policy_definition_id: The ID of the policy definition or policy set + definition. + :type policy_definition_id: str + :param parameters: Required if a parameter is used in policy rule. + :type parameters: object + """ + + _attribute_map = { + 'policy_definition_id': {'key': 'policyDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': 'object'}, + } + + 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) + + +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, and Custom. Possible values include: + 'NotSpecified', 'BuiltIn', 'Custom' + :type policy_type: str or + ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyType + :param display_name: The display name of the policy set definition. + :type display_name: str + :param description: The policy set definition description. + :type description: str + :param metadata: The policy set definition metadata. + :type metadata: object + :param parameters: The policy set definition parameters that can be used + in policy definition references. + :type parameters: object + :param policy_definitions: Required. An array of policy definition + references. + :type policy_definitions: + list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionReference] + :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': 'object'}, + 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, + '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.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_06_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_models_py3.py new file mode 100644 index 000000000000..dd814ee24957 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_models_py3.py @@ -0,0 +1,358 @@ +# 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): + """CloudError. + """ + + _attribute_map = { + } + + +class ErrorResponse(Model): + """Error response indicates Azure Resource Manager is not able to process the + incoming request. The reason is provided in the error message. + + :param http_status: Http status code. + :type http_status: str + :param error_code: Error code. + :type error_code: str + :param error_message: Error message indicating why the operation failed. + :type error_message: str + """ + + _attribute_map = { + 'http_status': {'key': 'httpStatus', 'type': 'str'}, + 'error_code': {'key': 'errorCode', 'type': 'str'}, + 'error_message': {'key': 'errorMessage', 'type': 'str'}, + } + + def __init__(self, *, http_status: str=None, error_code: str=None, error_message: str=None, **kwargs) -> None: + super(ErrorResponse, self).__init__(**kwargs) + self.http_status = http_status + self.error_code = error_code + self.error_message = error_message + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) + + +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_06_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 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: Required if a parameter is used in policy rule. + :type parameters: object + :param description: This message will be part of response in case of + policy violation. + :type description: str + :param metadata: The policy assignment metadata. + :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_06_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_06_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_06_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': 'object'}, + '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, and Custom. Possible values include: + 'NotSpecified', 'BuiltIn', 'Custom' + :type policy_type: str or + ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyType + :param mode: The policy definition mode. Some examples are All, Indexed, + Microsoft.KeyVault.Data. + :type mode: str + :param display_name: The display name of the policy definition. + :type display_name: str + :param description: The policy definition description. + :type description: str + :param policy_rule: The policy rule. + :type policy_rule: object + :param metadata: The policy definition metadata. + :type metadata: object + :param parameters: Required if a parameter is used in policy rule. + :type parameters: object + :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': 'object'}, + '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 PolicyDefinitionReference(Model): + """The policy definition reference. + + :param policy_definition_id: The ID of the policy definition or policy set + definition. + :type policy_definition_id: str + :param parameters: Required if a parameter is used in policy rule. + :type parameters: object + """ + + _attribute_map = { + 'policy_definition_id': {'key': 'policyDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': 'object'}, + } + + def __init__(self, *, policy_definition_id: str=None, parameters=None, **kwargs) -> None: + super(PolicyDefinitionReference, self).__init__(**kwargs) + self.policy_definition_id = policy_definition_id + self.parameters = parameters + + +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, and Custom. Possible values include: + 'NotSpecified', 'BuiltIn', 'Custom' + :type policy_type: str or + ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyType + :param display_name: The display name of the policy set definition. + :type display_name: str + :param description: The policy set definition description. + :type description: str + :param metadata: The policy set definition metadata. + :type metadata: object + :param parameters: The policy set definition parameters that can be used + in policy definition references. + :type parameters: object + :param policy_definitions: Required. An array of policy definition + references. + :type policy_definitions: + list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionReference] + :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': 'object'}, + 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, + '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, **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.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_06_01/models/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_paged_models.py new file mode 100644 index 000000000000..4b47efe6b779 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_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_06_01/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_policy_client_enums.py new file mode 100644 index 000000000000..387aac38a63d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_policy_client_enums.py @@ -0,0 +1,31 @@ +# 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" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/__init__.py new file mode 100644 index 000000000000..c7d7b8eb9d97 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_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_06_01/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_policy_assignments_operations.py new file mode 100644 index 000000000000..c3d3c9427bb2 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_policy_assignments_operations.py @@ -0,0 +1,778 @@ +# 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 .. 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-06-01". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2019-06-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_06_01.models.PolicyAssignment or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # 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]: + raise models.ErrorResponseException(self._deserialize, response) + + 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_06_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_06_01.models.PolicyAssignment or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # 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]: + raise models.ErrorResponseException(self._deserialize, response) + + 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_06_01.models.PolicyAssignment or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # 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]: + raise models.ErrorResponseException(self._deserialize, response) + + 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_06_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment] + :raises: + :class:`ErrorResponseException` + """ + 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]: + raise models.ErrorResponseException(self._deserialize, response) + + 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_06_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment] + :raises: + :class:`ErrorResponseException` + """ + 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]: + raise models.ErrorResponseException(self._deserialize, response) + + 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_06_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment] + :raises: + :class:`ErrorResponseException` + """ + 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]: + raise models.ErrorResponseException(self._deserialize, response) + + 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_06_01.models.PolicyAssignment or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # 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]: + raise models.ErrorResponseException(self._deserialize, response) + + 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_06_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_06_01.models.PolicyAssignment or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # 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]: + raise models.ErrorResponseException(self._deserialize, response) + + 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_06_01.models.PolicyAssignment or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # 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]: + raise models.ErrorResponseException(self._deserialize, response) + + 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_06_01/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_policy_definitions_operations.py new file mode 100644 index 000000000000..6def5f46aeb7 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_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-06-01". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2019-06-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_06_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_06_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_06_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_06_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_06_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_06_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_06_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_06_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2019_06_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_06_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2019_06_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_06_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2019_06_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_06_01/operations/_policy_set_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_policy_set_definitions_operations.py new file mode 100644 index 000000000000..8c8a1e4e898e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_policy_set_definitions_operations.py @@ -0,0 +1,680 @@ +# 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 .. 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-06-01". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2019-06-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_06_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_06_01.models.PolicySetDefinition or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # 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]: + raise models.ErrorResponseException(self._deserialize, response) + + 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:`ErrorResponseException` + """ + # 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]: + raise models.ErrorResponseException(self._deserialize, response) + + 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_06_01.models.PolicySetDefinition or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # 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]: + raise models.ErrorResponseException(self._deserialize, response) + + 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_06_01.models.PolicySetDefinition or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # 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]: + raise models.ErrorResponseException(self._deserialize, response) + + 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_06_01.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition] + :raises: + :class:`ErrorResponseException` + """ + 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]: + raise models.ErrorResponseException(self._deserialize, response) + + 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_06_01.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition] + :raises: + :class:`ErrorResponseException` + """ + 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]: + raise models.ErrorResponseException(self._deserialize, response) + + 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_06_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_06_01.models.PolicySetDefinition or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # 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]: + raise models.ErrorResponseException(self._deserialize, response) + + 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:`ErrorResponseException` + """ + # 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]: + raise models.ErrorResponseException(self._deserialize, response) + + 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_06_01.models.PolicySetDefinition or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # 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]: + raise models.ErrorResponseException(self._deserialize, response) + + 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_06_01.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition] + :raises: + :class:`ErrorResponseException` + """ + 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]: + raise models.ErrorResponseException(self._deserialize, response) + + 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_06_01/version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/version.py new file mode 100644 index 000000000000..4174449873ab --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_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-06-01" +