PolicyAssignmentsOperations Class
Warning
DO NOT instantiate this class directly.
Instead, you should access the following operations through
<xref:policy_assignments> attribute.
- Inheritance
-
builtins.objectPolicyAssignmentsOperations
Constructor
PolicyAssignmentsOperations(*args, **kwargs)
Methods
create |
Creates a policy assignment. Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. |
create_by_id |
Creates a policy assignment by ID. Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. |
delete |
Deletes a policy assignment. |
delete_by_id |
Deletes a policy assignment by ID. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. |
get |
Gets a policy assignment. |
get_by_id |
Gets a policy assignment by ID. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. |
list |
Gets all the policy assignments for a subscription. |
list_for_resource |
Gets policy assignments for a resource. |
list_for_resource_group |
Gets policy assignments for the resource group. |
create
Creates a policy assignment.
Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group.
create(scope: str, policy_assignment_name: str, parameters: _models.PolicyAssignment, *, content_type: str = 'application/json', **kwargs: Any) -> _models.PolicyAssignment
Parameters
Name | Description |
---|---|
scope
Required
|
The scope of the policy assignment. Required. |
policy_assignment_name
Required
|
The name of the policy assignment. Required. |
parameters
Required
|
Parameters for the policy assignment. Is either a PolicyAssignment type or a IO[bytes] type. Required. |
Returns
Type | Description |
---|---|
PolicyAssignment or the result of cls(response) |
Exceptions
Type | Description |
---|---|
create_by_id
Creates a policy assignment by ID.
Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources.
create_by_id(policy_assignment_id: str, parameters: _models.PolicyAssignment, *, content_type: str = 'application/json', **kwargs: Any) -> _models.PolicyAssignment
Parameters
Name | Description |
---|---|
policy_assignment_id
Required
|
The ID of the policy assignment to create. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. Required. |
parameters
Required
|
Parameters for policy assignment. Is either a PolicyAssignment type or a IO[bytes] type. Required. |
Returns
Type | Description |
---|---|
PolicyAssignment or the result of cls(response) |
Exceptions
Type | Description |
---|---|
delete
Deletes a policy assignment.
delete(scope: str, policy_assignment_name: str, **kwargs: Any) -> PolicyAssignment | None
Parameters
Name | Description |
---|---|
scope
Required
|
The scope of the policy assignment. Required. |
policy_assignment_name
Required
|
The name of the policy assignment to delete. Required. |
Returns
Type | Description |
---|---|
PolicyAssignment or None or the result of cls(response) |
Exceptions
Type | Description |
---|---|
delete_by_id
Deletes a policy assignment by ID.
When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources.
delete_by_id(policy_assignment_id: str, **kwargs: Any) -> PolicyAssignment
Parameters
Name | Description |
---|---|
policy_assignment_id
Required
|
The ID of the policy assignment to delete. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. Required. |
Returns
Type | Description |
---|---|
PolicyAssignment or the result of cls(response) |
Exceptions
Type | Description |
---|---|
get
Gets a policy assignment.
get(scope: str, policy_assignment_name: str, **kwargs: Any) -> PolicyAssignment
Parameters
Name | Description |
---|---|
scope
Required
|
The scope of the policy assignment. Required. |
policy_assignment_name
Required
|
The name of the policy assignment to get. Required. |
Returns
Type | Description |
---|---|
PolicyAssignment or the result of cls(response) |
Exceptions
Type | Description |
---|---|
get_by_id
Gets a policy assignment by ID.
When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources.
get_by_id(policy_assignment_id: str, **kwargs: Any) -> PolicyAssignment
Parameters
Name | Description |
---|---|
policy_assignment_id
Required
|
The ID of the policy assignment to get. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. Required. |
Returns
Type | Description |
---|---|
PolicyAssignment or the result of cls(response) |
Exceptions
Type | Description |
---|---|
list
Gets all the policy assignments for a subscription.
list(filter: str | None = None, **kwargs: Any) -> Iterable[PolicyAssignment]
Parameters
Name | Description |
---|---|
filter
Required
|
The filter to apply on the operation. Default value is None. |
Returns
Type | Description |
---|---|
An iterator like instance of either PolicyAssignment or the result of cls(response) |
Exceptions
Type | Description |
---|---|
list_for_resource
Gets policy assignments for a resource.
list_for_resource(resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, filter: str | None = None, **kwargs: Any) -> Iterable[PolicyAssignment]
Parameters
Name | Description |
---|---|
resource_group_name
Required
|
The name of the resource group containing the resource. The name is case insensitive. Required. |
resource_provider_namespace
Required
|
The namespace of the resource provider. Required. |
parent_resource_path
Required
|
The parent resource path. Required. |
resource_type
Required
|
The resource type. Required. |
resource_name
Required
|
The name of the resource with policy assignments. Required. |
filter
Required
|
The filter to apply on the operation. Default value is None. |
Returns
Type | Description |
---|---|
An iterator like instance of either PolicyAssignment or the result of cls(response) |
Exceptions
Type | Description |
---|---|
list_for_resource_group
Gets policy assignments for the resource group.
list_for_resource_group(resource_group_name: str, filter: str | None = None, **kwargs: Any) -> Iterable[PolicyAssignment]
Parameters
Name | Description |
---|---|
resource_group_name
Required
|
The name of the resource group that contains policy assignments. Required. |
filter
Required
|
The filter to apply on the operation. Default value is None. |
Returns
Type | Description |
---|---|
An iterator like instance of either PolicyAssignment or the result of cls(response) |
Exceptions
Type | Description |
---|---|
Attributes
models
models = <module 'azure.mgmt.resource.policy.v2016_12_01.models' from 'C:\\hostedtoolcache\\windows\\Python\\3.11.9\\x64\\Lib\\site-packages\\azure\\mgmt\\resource\\policy\\v2016_12_01\\models\\__init__.py'>
Azure SDK for Python