Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class PolicyClient(MultiApiClientMixin, SDKClient):
:type profile: azure.profiles.KnownProfiles
"""

DEFAULT_API_VERSION = '2019-06-01'
DEFAULT_API_VERSION = '2019-09-01'
_PROFILE_TAG = "azure.mgmt.resource.policy.PolicyClient"
LATEST_PROFILE = ProfileDefinition({
_PROFILE_TAG: {
Expand Down Expand Up @@ -80,6 +80,7 @@ def models(cls, api_version=DEFAULT_API_VERSION):
* 2018-05-01: :mod:`v2018_05_01.models<azure.mgmt.resource.policy.v2018_05_01.models>`
* 2019-01-01: :mod:`v2019_01_01.models<azure.mgmt.resource.policy.v2019_01_01.models>`
* 2019-06-01: :mod:`v2019_06_01.models<azure.mgmt.resource.policy.v2019_06_01.models>`
* 2019-09-01: :mod:`v2019_09_01.models<azure.mgmt.resource.policy.v2019_09_01.models>`
"""
if api_version == '2015-10-01-preview':
from .v2015_10_01_preview import models
Expand All @@ -105,6 +106,9 @@ def models(cls, api_version=DEFAULT_API_VERSION):
elif api_version == '2019-06-01':
from .v2019_06_01 import models
return models
elif api_version == '2019-09-01':
from .v2019_09_01 import models
return models
raise NotImplementedError("APIVersion {} is not available".format(api_version))

@property
Expand All @@ -119,6 +123,7 @@ def policy_assignments(self):
* 2018-05-01: :class:`PolicyAssignmentsOperations<azure.mgmt.resource.policy.v2018_05_01.operations.PolicyAssignmentsOperations>`
* 2019-01-01: :class:`PolicyAssignmentsOperations<azure.mgmt.resource.policy.v2019_01_01.operations.PolicyAssignmentsOperations>`
* 2019-06-01: :class:`PolicyAssignmentsOperations<azure.mgmt.resource.policy.v2019_06_01.operations.PolicyAssignmentsOperations>`
* 2019-09-01: :class:`PolicyAssignmentsOperations<azure.mgmt.resource.policy.v2019_09_01.operations.PolicyAssignmentsOperations>`
"""
api_version = self._get_api_version('policy_assignments')
if api_version == '2015-10-01-preview':
Expand All @@ -137,6 +142,8 @@ def policy_assignments(self):
from .v2019_01_01.operations import PolicyAssignmentsOperations as OperationClass
elif api_version == '2019-06-01':
from .v2019_06_01.operations import PolicyAssignmentsOperations as OperationClass
elif api_version == '2019-09-01':
from .v2019_09_01.operations import PolicyAssignmentsOperations as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
Expand All @@ -153,6 +160,7 @@ def policy_definitions(self):
* 2018-05-01: :class:`PolicyDefinitionsOperations<azure.mgmt.resource.policy.v2018_05_01.operations.PolicyDefinitionsOperations>`
* 2019-01-01: :class:`PolicyDefinitionsOperations<azure.mgmt.resource.policy.v2019_01_01.operations.PolicyDefinitionsOperations>`
* 2019-06-01: :class:`PolicyDefinitionsOperations<azure.mgmt.resource.policy.v2019_06_01.operations.PolicyDefinitionsOperations>`
* 2019-09-01: :class:`PolicyDefinitionsOperations<azure.mgmt.resource.policy.v2019_09_01.operations.PolicyDefinitionsOperations>`
"""
api_version = self._get_api_version('policy_definitions')
if api_version == '2015-10-01-preview':
Expand All @@ -171,6 +179,8 @@ def policy_definitions(self):
from .v2019_01_01.operations import PolicyDefinitionsOperations as OperationClass
elif api_version == '2019-06-01':
from .v2019_06_01.operations import PolicyDefinitionsOperations as OperationClass
elif api_version == '2019-09-01':
from .v2019_09_01.operations import PolicyDefinitionsOperations as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
Expand All @@ -184,6 +194,7 @@ def policy_set_definitions(self):
* 2018-05-01: :class:`PolicySetDefinitionsOperations<azure.mgmt.resource.policy.v2018_05_01.operations.PolicySetDefinitionsOperations>`
* 2019-01-01: :class:`PolicySetDefinitionsOperations<azure.mgmt.resource.policy.v2019_01_01.operations.PolicySetDefinitionsOperations>`
* 2019-06-01: :class:`PolicySetDefinitionsOperations<azure.mgmt.resource.policy.v2019_06_01.operations.PolicySetDefinitionsOperations>`
* 2019-09-01: :class:`PolicySetDefinitionsOperations<azure.mgmt.resource.policy.v2019_09_01.operations.PolicySetDefinitionsOperations>`
"""
api_version = self._get_api_version('policy_set_definitions')
if api_version == '2017-06-01-preview':
Expand All @@ -196,6 +207,8 @@ def policy_set_definitions(self):
from .v2019_01_01.operations import PolicySetDefinitionsOperations as OperationClass
elif api_version == '2019-06-01':
from .v2019_06_01.operations import PolicySetDefinitionsOperations as OperationClass
elif api_version == '2019-09-01':
from .v2019_09_01.operations import PolicySetDefinitionsOperations as OperationClass
else:
raise NotImplementedError("APIVersion {} is not available".format(api_version))
return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
from .v2019_06_01.models import *
from .v2019_09_01.models import *
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ class Identity(Model):
: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'
:param type: The identity type. This is the only required field when
adding a system assigned identity to a resource. Possible values include:
'SystemAssigned', 'None'
:type type: str or
~azure.mgmt.resource.policy.v2019_09_01.models.ResourceIdentityType
"""
Expand All @@ -149,7 +150,7 @@ def __init__(self, **kwargs):


class ParameterDefinitionsValue(Model):
"""ParameterDefinitionsValue.
"""The definition of a parameter that can be provided to the policy.

:param type: The data type of the parameter. Possible values include:
'String', 'Array', 'Object', 'Boolean', 'Integer', 'Float', 'DateTime'
Expand Down Expand Up @@ -206,7 +207,7 @@ def __init__(self, **kwargs):


class ParameterValuesValue(Model):
"""ParameterValuesValue.
"""The value of a parameter.

:param value: The value of the parameter.
:type value: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ class Identity(Model):
: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'
:param type: The identity type. This is the only required field when
adding a system assigned identity to a resource. Possible values include:
'SystemAssigned', 'None'
:type type: str or
~azure.mgmt.resource.policy.v2019_09_01.models.ResourceIdentityType
"""
Expand All @@ -149,7 +150,7 @@ def __init__(self, *, type=None, **kwargs) -> None:


class ParameterDefinitionsValue(Model):
"""ParameterDefinitionsValue.
"""The definition of a parameter that can be provided to the policy.

:param type: The data type of the parameter. Possible values include:
'String', 'Array', 'Object', 'Boolean', 'Integer', 'Float', 'DateTime'
Expand Down Expand Up @@ -206,7 +207,7 @@ def __init__(self, *, additional_properties=None, display_name: str=None, descri


class ParameterValuesValue(Model):
"""ParameterValuesValue.
"""The value of a parameter.

:param value: The value of the parameter.
:type value: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class EnforcementMode(str, Enum):

class ResourceIdentityType(str, Enum):

system_assigned = "SystemAssigned"
none = "None"
system_assigned = "SystemAssigned" #: Indicates that a system assigned identity is associated with the resource.
none = "None" #: Indicates that no identity is associated with the resource or that the existing identity should be removed.


class PolicyType(str, Enum):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,90 @@ def internal_paging(next_link=None):
return deserialized
list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'}

def list_for_management_group(
self, management_group_id, filter, custom_headers=None, raw=False, **operation_config):
"""Retrieves all policy assignments that apply to a management group.

This operation retrieves the list of all policy assignments applicable
to the management group that match the given $filter. Valid values for
$filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If
$filter=atScope() is provided, the returned list includes all policy
assignments that are assigned to the management group or the management
group's ancestors. If $filter=policyDefinitionId eq '{value}' is
provided, the returned list includes all policy assignments of the
policy definition whose id is {value} that apply to the management
group.

:param management_group_id: The ID of the management group.
:type management_group_id: str
:param filter: The filter to apply on the operation. Valid values for
$filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. A
filter is required when listing policy assignments at management group
scope.
: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<msrest:optionsforoperations>`.
:return: An iterator like instance of PolicyAssignment
:rtype:
~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment]
:raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
"""
def prepare_request(next_link=None):
if not next_link:
# Construct URL
url = self.list_for_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['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True)
query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

else:
url = next_link
query_parameters = {}

# Construct headers
header_parameters = {}
header_parameters['Accept'] = 'application/json'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
header_parameters.update(custom_headers)
if self.config.accept_language is not None:
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

# Construct and send request
request = self._client.get(url, query_parameters, header_parameters)
return request

def internal_paging(next_link=None):
request = prepare_request(next_link)

response = self._client.send(request, stream=False, **operation_config)

if response.status_code not in [200]:
exp = CloudError(response)
exp.request_id = response.headers.get('x-ms-request-id')
raise exp

return response

# Deserialize response
header_dict = None
if raw:
header_dict = {}
deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict)

return deserialized
list_for_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/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.
Expand Down
Loading