From 55bfadbb1f0a91de6cdb88ebfb52278d35e9143c Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Wed, 16 Sep 2026 21:22:23 +0000 Subject: [PATCH] Configurations: 'specification/resources/resource-manager/Microsoft.Authorization/policy/tspconfig.yaml', API Version: 2026-06-01, SDK Release Type: stable, and CommitSHA: '710828f4424a112000ac9a81896a8648f87b7548' in SpecRepo: 'https://github.com/Azure/azure-rest-api-specs' Pipeline run: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=6845337 Refer to https://eng.ms/docs/products/azure-developer-experience/develop/sdk-release/sdk-release-prerequisites to prepare for SDK release. --- .../azure-mgmt-resource-policy/CHANGELOG.md | 35 + .../azure-mgmt-resource-policy/_metadata.json | 10 +- .../azure-mgmt-resource-policy/api.md | 1583 +-- .../api.metadata.yml | 3 +- .../apiview-properties.json | 81 - .../azure/mgmt/resource/policy/_client.py | 27 +- .../mgmt/resource/policy/_configuration.py | 9 +- .../mgmt/resource/policy/_utils/model_base.py | 18 - .../azure/mgmt/resource/policy/_version.py | 2 +- .../azure/mgmt/resource/policy/aio/_client.py | 29 +- .../resource/policy/aio/_configuration.py | 9 +- .../policy/aio/operations/__init__.py | 8 - .../policy/aio/operations/_operations.py | 5678 ++------ .../mgmt/resource/policy/models/__init__.py | 34 - .../mgmt/resource/policy/models/_enums.py | 35 +- .../mgmt/resource/policy/models/_models.py | 788 +- .../resource/policy/operations/__init__.py | 8 - .../resource/policy/operations/_operations.py | 10666 +++++----------- .../azure/mgmt/resource/policy/types.py | 330 +- .../generated_samples/acquire_policy_token.py | 2 +- ...cquire_policy_token_at_management_group.py | 2 +- .../create_or_update_policy_definition.py | 2 +- ...pdate_policy_definition_advanced_params.py | 2 +- ...e_policy_definition_at_management_group.py | 2 +- ...xternal_evaluation_enforcement_settings.py | 2 +- ...ate_or_update_policy_definition_version.py | 2 +- ..._definition_version_at_management_group.py | 2 +- ...licy_enrollment_with_resource_selectors.py | 59 - .../create_or_update_policy_exemption.py | 53 - ...xemption_with_exemption_management_mode.py | 54 - ...olicy_exemption_with_resource_selectors.py | 60 - .../create_or_update_policy_set_definition.py | 2 +- ...licy_set_definition_at_management_group.py | 6 +- ...or_update_policy_set_definition_version.py | 2 +- ..._definition_version_at_management_group.py | 6 +- ...pdate_policy_set_definition_with_groups.py | 2 +- ...inition_with_groups_at_management_group.py | 2 +- .../create_or_update_variable.py | 42 - ..._or_update_variable_at_management_group.py | 43 - ...date_variable_value_at_management_group.py | 51 - .../create_policy_assignment.py | 2 +- ...licy_assignment_non_compliance_messages.py | 2 +- ...licy_assignment_with_enroll_enforcement.py | 2 +- .../create_policy_assignment_with_identity.py | 2 +- ...create_policy_assignment_with_overrides.py | 2 +- ...h_resource_rollout_percentage_selector.py} | 22 +- ...licy_assignment_with_resource_selectors.py | 2 +- ...nment_with_selfserve_exemption_settings.py | 2 +- ..._assignment_with_user_assigned_identity.py | 2 +- ...e_policy_assignment_without_enforcement.py | 2 +- .../delete_policy_assignment.py | 2 +- .../delete_policy_definition.py | 2 +- ...e_policy_definition_at_management_group.py | 2 +- .../delete_policy_definition_version.py | 2 +- ..._definition_version_at_management_group.py | 2 +- .../delete_policy_enrollment.py | 41 - .../delete_policy_exemption.py | 41 - .../delete_policy_set_definition.py | 2 +- ...licy_set_definition_at_management_group.py | 2 +- .../delete_policy_set_definition_version.py | 2 +- ..._definition_version_at_management_group.py | 2 +- .../generated_samples/delete_variable.py | 40 - .../delete_variable_at_management_group.py | 41 - .../delete_variable_value.py | 41 - ...lete_variable_value_at_management_group.py | 42 - .../get_built_in_policy_set_definition.py | 2 +- ..._built_in_policy_set_definition_version.py | 2 +- .../get_builtin_policy_definition.py | 2 +- .../get_builtin_policy_definition_version.py | 2 +- .../get_data_policy_manifest.py | 2 +- .../get_policy_assignment.py | 2 +- .../get_policy_assignment_with_identity.py | 2 +- .../get_policy_assignment_with_overrides.py | 2 +- ...h_resource_rollout_percentage_selector.py} | 10 +- ...licy_assignment_with_resource_selectors.py | 2 +- ..._assignment_with_user_assigned_identity.py | 2 +- .../get_policy_definition.py | 2 +- ...t_policy_definition_at_management_group.py | 2 +- .../get_policy_definition_version.py | 2 +- ..._definition_version_at_management_group.py | 2 +- .../get_policy_enrollment.py | 42 - ...licy_enrollment_with_resource_selectors.py | 42 - ...olicy_exemption_with_resource_selectors.py | 42 - .../get_policy_set_definition.py | 2 +- ...licy_set_definition_at_management_group.py | 2 +- .../get_policy_set_definition_version.py | 2 +- ..._definition_version_at_management_group.py | 2 +- .../generated_samples/get_variable.py | 41 - .../get_variable_at_management_group.py | 42 - .../generated_samples/get_variable_value.py | 42 - .../get_variable_value_at_management_group.py | 43 - ...all_built_in_policy_definition_versions.py | 2 +- ...built_in_policy_set_definition_versions.py | 2 +- .../list_all_policy_definition_versions.py | 2 +- ...definition_versions_by_management_group.py | 2 +- ...list_all_policy_set_definition_versions.py | 2 +- ...definition_versions_by_management_group.py | 2 +- ...ist_built_in_policy_definition_versions.py | 2 +- .../list_built_in_policy_definitions.py | 2 +- ...built_in_policy_set_definition_versions.py | 2 +- .../list_built_in_policy_set_definitions.py | 2 +- .../list_data_policy_manifests.py | 2 +- ..._data_policy_manifests_namespace_filter.py | 2 +- .../list_policy_assignments.py | 2 +- ...policy_assignments_for_management_group.py | 2 +- .../list_policy_assignments_for_resource.py | 2 +- ...t_policy_assignments_for_resource_group.py | 2 +- .../list_policy_definition_versions.py | 2 +- ...definition_versions_by_management_group.py | 2 +- .../list_policy_definitions.py | 2 +- ..._policy_definitions_by_management_group.py | 2 +- ...policy_enrollments_for_management_group.py | 42 - .../list_policy_enrollments_for_resource.py | 46 - ...t_policy_enrollments_for_resource_group.py | 42 - ...ist_policy_enrollments_for_subscription.py | 40 - ..._policy_exemptions_for_management_group.py | 42 - .../list_policy_exemptions_for_resource.py | 46 - ...st_policy_exemptions_for_resource_group.py | 42 - ...list_policy_exemptions_for_subscription.py | 40 - .../list_policy_set_definition_versions.py | 2 +- ...definition_versions_by_management_group.py | 2 +- .../list_policy_set_definitions.py | 2 +- ...icy_set_definitions_by_management_group.py | 2 +- ...st_variable_values_for_management_group.py | 43 - .../list_variable_values_for_subscription.py | 42 - .../list_variables_for_management_group.py | 42 - .../list_variables_for_subscription.py | 40 - .../update_policy_assignment_with_identity.py | 2 +- ...update_policy_assignment_with_overrides.py | 2 +- ...h_resource_rollout_percentage_selector.py} | 15 +- ...licy_assignment_with_resource_selectors.py | 2 +- ...nment_with_selfserve_exemption_settings.py | 2 +- ..._assignment_with_user_assigned_identity.py | 2 +- ...licy_enrollment_with_resource_selectors.py | 53 - ...xemption_with_exemption_management_mode.py | 43 - ...olicy_exemption_with_resource_selectors.py | 53 - ...st_policy_policy_assignments_operations.py | 32 +- ...icy_policy_assignments_operations_async.py | 32 +- ...st_policy_policy_enrollments_operations.py | 139 - ...icy_policy_enrollments_operations_async.py | 140 - ...est_policy_policy_exemptions_operations.py | 141 - ...licy_policy_exemptions_operations_async.py | 142 - .../test_policy_variable_values_operations.py | 137 - ...policy_variable_values_operations_async.py | 138 - .../test_policy_variables_operations.py | 128 - .../test_policy_variables_operations_async.py | 129 - .../azure-mgmt-resource-policy/pyproject.toml | 4 +- .../tsp-location.yaml | 2 +- 148 files changed, 4085 insertions(+), 18203 deletions(-) delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_enrollment_with_resource_selectors.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_exemption.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_exemption_with_exemption_management_mode.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_exemption_with_resource_selectors.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_variable.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_variable_at_management_group.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_variable_value_at_management_group.py rename sdk/resources/azure-mgmt-resource-policy/generated_samples/{create_or_update_policy_enrollment.py => create_policy_assignment_with_resource_rollout_percentage_selector.py} (66%) delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_enrollment.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_exemption.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_variable.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_variable_at_management_group.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_variable_value.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_variable_value_at_management_group.py rename sdk/resources/azure-mgmt-resource-policy/generated_samples/{get_policy_exemption.py => get_policy_assignment_with_resource_rollout_percentage_selector.py} (82%) delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_enrollment.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_enrollment_with_resource_selectors.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_exemption_with_resource_selectors.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/get_variable.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/get_variable_at_management_group.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/get_variable_value.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/get_variable_value_at_management_group.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_enrollments_for_management_group.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_enrollments_for_resource.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_enrollments_for_resource_group.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_enrollments_for_subscription.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_exemptions_for_management_group.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_exemptions_for_resource.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_exemptions_for_resource_group.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_exemptions_for_subscription.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/list_variable_values_for_management_group.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/list_variable_values_for_subscription.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/list_variables_for_management_group.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/list_variables_for_subscription.py rename sdk/resources/azure-mgmt-resource-policy/generated_samples/{create_or_update_variable_value.py => update_policy_assignment_with_resource_rollout_percentage_selector.py} (72%) delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_enrollment_with_resource_selectors.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_exemption_with_exemption_management_mode.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_exemption_with_resource_selectors.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_enrollments_operations.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_enrollments_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_exemptions_operations.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_exemptions_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_variable_values_operations.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_variable_values_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_variables_operations.py delete mode 100644 sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_variables_operations_async.py diff --git a/sdk/resources/azure-mgmt-resource-policy/CHANGELOG.md b/sdk/resources/azure-mgmt-resource-policy/CHANGELOG.md index ed54fee74cb1..da5af3baa0b0 100644 --- a/sdk/resources/azure-mgmt-resource-policy/CHANGELOG.md +++ b/sdk/resources/azure-mgmt-resource-policy/CHANGELOG.md @@ -1,5 +1,40 @@ # Release History +## 1.0.0 (2026-09-16) + +### Features Added + + - Model `Selector` added property `progress` + - Enum `SelectorKind` added member `RESOURCE_ROLLOUT_PERCENTAGE` + +### Breaking Changes + + - Deleted or renamed client operation group `PolicyClient.policy_enrollments` + - Deleted or renamed client operation group `PolicyClient.policy_exemptions` + - Deleted or renamed client operation group `PolicyClient.variable_values` + - Deleted or renamed client operation group `PolicyClient.variables` + - Deleted or renamed model `AssignmentScopeValidation` + - Deleted or renamed model `ExemptionCategory` + - Deleted or renamed model `ExemptionManagementMode` + - Deleted or renamed model `PolicyEnrollment` + - Deleted or renamed model `PolicyEnrollmentProperties` + - Deleted or renamed model `PolicyEnrollmentUpdate` + - Deleted or renamed model `PolicyEnrollmentUpdateProperties` + - Deleted or renamed model `PolicyExemption` + - Deleted or renamed model `PolicyExemptionProperties` + - Deleted or renamed model `PolicyExemptionUpdate` + - Deleted or renamed model `PolicyExemptionUpdateProperties` + - Deleted or renamed model `PolicyVariableColumn` + - Deleted or renamed model `PolicyVariableProperties` + - Deleted or renamed model `PolicyVariableValueColumnValue` + - Deleted or renamed model `PolicyVariableValueProperties` + - Deleted or renamed model `Variable` + - Deleted or renamed model `VariableValue` + - Deleted or renamed model `PolicyEnrollmentsOperations` + - Deleted or renamed model `PolicyExemptionsOperations` + - Deleted or renamed model `VariableValuesOperations` + - Deleted or renamed model `VariablesOperations` + ## 1.0.0b4 (2026-08-31) ### Features Added diff --git a/sdk/resources/azure-mgmt-resource-policy/_metadata.json b/sdk/resources/azure-mgmt-resource-policy/_metadata.json index b97fb5a966d7..3b01ca78acdf 100644 --- a/sdk/resources/azure-mgmt-resource-policy/_metadata.json +++ b/sdk/resources/azure-mgmt-resource-policy/_metadata.json @@ -1,11 +1,11 @@ { - "apiVersion": "2026-01-01-preview", + "apiVersion": "2026-06-01", "apiVersions": { - "Microsoft.Authorization": "2026-01-01-preview" + "Microsoft.Authorization": "2026-06-01" }, - "commit": "fb93aacb4b6f5bcd058e6730b113f1fcdcba8157", + "commit": "710828f4424a112000ac9a81896a8648f87b7548", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "typespec_src": "specification/resources/resource-manager/Microsoft.Authorization/policy", - "emitterVersion": "0.63.5", - "httpClientPythonVersion": "^0.36.0" + "emitterVersion": "0.63.7", + "httpClientPythonVersion": "^0.37.2" } \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource-policy/api.md b/sdk/resources/azure-mgmt-resource-policy/api.md index 2b0634f282a0..375b971ddf50 100644 --- a/sdk/resources/azure-mgmt-resource-policy/api.md +++ b/sdk/resources/azure-mgmt-resource-policy/api.md @@ -6,13 +6,9 @@ namespace azure.mgmt.resource.policy policy_assignments: PolicyAssignmentsOperations policy_definition_versions: PolicyDefinitionVersionsOperations policy_definitions: PolicyDefinitionsOperations - policy_enrollments: PolicyEnrollmentsOperations - policy_exemptions: PolicyExemptionsOperations policy_set_definition_versions: PolicySetDefinitionVersionsOperations policy_set_definitions: PolicySetDefinitionsOperations policy_tokens: PolicyTokensOperations - variable_values: VariableValuesOperations - variables: VariablesOperations def __init__( self, @@ -43,13 +39,9 @@ namespace azure.mgmt.resource.policy.aio policy_assignments: PolicyAssignmentsOperations policy_definition_versions: PolicyDefinitionVersionsOperations policy_definitions: PolicyDefinitionsOperations - policy_enrollments: PolicyEnrollmentsOperations - policy_exemptions: PolicyExemptionsOperations policy_set_definition_versions: PolicySetDefinitionVersionsOperations policy_set_definitions: PolicySetDefinitionsOperations policy_tokens: PolicyTokensOperations - variable_values: VariableValuesOperations - variables: VariablesOperations def __init__( self, @@ -84,7 +76,7 @@ namespace azure.mgmt.resource.policy.aio.operations ) -> None: ... @distributed_trace_async - @api_version_validation(method_added_on='2025-11-01', params_added_on={'2025-11-01': ['api_version', 'policy_mode', 'accept']}, api_versions_list=['2025-11-01', '2025-12-01-preview', '2026-01-01-preview']) + @api_version_validation(method_added_on='2025-11-01', params_added_on={'2025-11-01': ['api_version', 'policy_mode', 'accept']}, api_versions_list=['2025-11-01', '2025-12-01-preview', '2026-01-01-preview', '2026-06-01']) async def get_by_policy_mode( self, policy_mode: str, @@ -92,7 +84,7 @@ namespace azure.mgmt.resource.policy.aio.operations ) -> DataPolicyManifest: ... @distributed_trace - @api_version_validation(method_added_on='2025-11-01', params_added_on={'2025-11-01': ['api_version', 'filter', 'accept']}, api_versions_list=['2025-11-01', '2025-12-01-preview', '2026-01-01-preview']) + @api_version_validation(method_added_on='2025-11-01', params_added_on={'2025-11-01': ['api_version', 'filter', 'accept']}, api_versions_list=['2025-11-01', '2025-12-01-preview', '2026-01-01-preview', '2026-06-01']) def list( self, *, @@ -613,278 +605,6 @@ namespace azure.mgmt.resource.policy.aio.operations ) -> AsyncItemPaged[PolicyDefinition]: ... - class azure.mgmt.resource.policy.aio.operations.PolicyEnrollmentsOperations: - - def __init__( - self, - *args, - **kwargs - ) -> None: ... - - @overload - async def create_or_update( - self, - scope: str, - policy_enrollment_name: str, - parameters: PolicyEnrollment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyEnrollment: ... - - @overload - async def create_or_update( - self, - scope: str, - policy_enrollment_name: str, - parameters: PolicyEnrollment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyEnrollment: ... - - @overload - async def create_or_update( - self, - scope: str, - policy_enrollment_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyEnrollment: ... - - @distributed_trace_async - @api_version_validation(method_added_on='2026-01-01-preview', params_added_on={'2026-01-01-preview': ['api_version', 'scope', 'policy_enrollment_name']}, api_versions_list=['2026-01-01-preview']) - async def delete( - self, - scope: str, - policy_enrollment_name: str, - **kwargs: Any - ) -> None: ... - - @distributed_trace_async - @api_version_validation(method_added_on='2026-01-01-preview', params_added_on={'2026-01-01-preview': ['api_version', 'scope', 'policy_enrollment_name', 'accept']}, api_versions_list=['2026-01-01-preview']) - async def get( - self, - scope: str, - policy_enrollment_name: str, - **kwargs: Any - ) -> PolicyEnrollment: ... - - @distributed_trace - @api_version_validation(method_added_on='2026-01-01-preview', params_added_on={'2026-01-01-preview': ['api_version', 'subscription_id', 'filter', 'accept']}, api_versions_list=['2026-01-01-preview']) - def list( - self, - *, - filter: Optional[str] = ..., - **kwargs: Any - ) -> AsyncItemPaged[PolicyEnrollment]: ... - - @distributed_trace - @api_version_validation(method_added_on='2026-01-01-preview', params_added_on={'2026-01-01-preview': ['api_version', 'management_group_id', 'filter', 'accept']}, api_versions_list=['2026-01-01-preview']) - def list_for_management_group( - self, - management_group_id: str, - *, - filter: Optional[str] = ..., - **kwargs: Any - ) -> AsyncItemPaged[PolicyEnrollment]: ... - - @distributed_trace - @api_version_validation(method_added_on='2026-01-01-preview', params_added_on={'2026-01-01-preview': ['subscription_id', 'resource_group_name', 'resource_provider_namespace', 'parent_resource_path', 'resource_type', 'resource_name', 'api_version', 'filter', 'accept']}, api_versions_list=['2026-01-01-preview']) - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - *, - filter: Optional[str] = ..., - **kwargs: Any - ) -> AsyncItemPaged[PolicyEnrollment]: ... - - @distributed_trace - @api_version_validation(method_added_on='2026-01-01-preview', params_added_on={'2026-01-01-preview': ['api_version', 'subscription_id', 'resource_group_name', 'filter', 'accept']}, api_versions_list=['2026-01-01-preview']) - def list_for_resource_group( - self, - resource_group_name: str, - *, - filter: Optional[str] = ..., - **kwargs: Any - ) -> AsyncItemPaged[PolicyEnrollment]: ... - - @overload - async def update( - self, - scope: str, - policy_enrollment_name: str, - parameters: PolicyEnrollmentUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyEnrollment: ... - - @overload - async def update( - self, - scope: str, - policy_enrollment_name: str, - parameters: PolicyEnrollmentUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyEnrollment: ... - - @overload - async def update( - self, - scope: str, - policy_enrollment_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyEnrollment: ... - - - class azure.mgmt.resource.policy.aio.operations.PolicyExemptionsOperations: - - def __init__( - self, - *args, - **kwargs - ) -> None: ... - - @overload - async def create_or_update( - self, - scope: str, - policy_exemption_name: str, - parameters: PolicyExemption, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyExemption: ... - - @overload - async def create_or_update( - self, - scope: str, - policy_exemption_name: str, - parameters: PolicyExemption, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyExemption: ... - - @overload - async def create_or_update( - self, - scope: str, - policy_exemption_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyExemption: ... - - @distributed_trace_async - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'scope', 'policy_exemption_name']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - async def delete( - self, - scope: str, - policy_exemption_name: str, - **kwargs: Any - ) -> None: ... - - @distributed_trace_async - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'scope', 'policy_exemption_name', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - async def get( - self, - scope: str, - policy_exemption_name: str, - **kwargs: Any - ) -> PolicyExemption: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'subscription_id', 'filter', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def list( - self, - *, - filter: Optional[str] = ..., - **kwargs: Any - ) -> AsyncItemPaged[PolicyExemption]: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'management_group_id', 'filter', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def list_for_management_group( - self, - management_group_id: str, - *, - filter: Optional[str] = ..., - **kwargs: Any - ) -> AsyncItemPaged[PolicyExemption]: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['subscription_id', 'resource_group_name', 'resource_provider_namespace', 'parent_resource_path', 'resource_type', 'resource_name', 'api_version', 'filter', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - *, - filter: Optional[str] = ..., - **kwargs: Any - ) -> AsyncItemPaged[PolicyExemption]: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'subscription_id', 'resource_group_name', 'filter', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def list_for_resource_group( - self, - resource_group_name: str, - *, - filter: Optional[str] = ..., - **kwargs: Any - ) -> AsyncItemPaged[PolicyExemption]: ... - - @overload - async def update( - self, - scope: str, - policy_exemption_name: str, - parameters: PolicyExemptionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyExemption: ... - - @overload - async def update( - self, - scope: str, - policy_exemption_name: str, - parameters: PolicyExemptionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyExemption: ... - - @overload - async def update( - self, - scope: str, - policy_exemption_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyExemption: ... - - class azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations: def __init__( @@ -1260,262 +980,11 @@ namespace azure.mgmt.resource.policy.aio.operations async def acquire_at_management_group( self, management_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyTokenResponse: ... - - - class azure.mgmt.resource.policy.aio.operations.VariableValuesOperations: - - def __init__( - self, - *args, - **kwargs - ) -> None: ... - - @overload - async def create_or_update( - self, - variable_name: str, - variable_value_name: str, - parameters: VariableValue, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> VariableValue: ... - - @overload - async def create_or_update( - self, - variable_name: str, - variable_value_name: str, - parameters: VariableValue, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> VariableValue: ... - - @overload - async def create_or_update( - self, - variable_name: str, - variable_value_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> VariableValue: ... - - @overload - async def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - variable_value_name: str, - parameters: VariableValue, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> VariableValue: ... - - @overload - async def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - variable_value_name: str, - parameters: VariableValue, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> VariableValue: ... - - @overload - async def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - variable_value_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> VariableValue: ... - - @distributed_trace_async - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'subscription_id', 'variable_name', 'variable_value_name']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - async def delete( - self, - variable_name: str, - variable_value_name: str, - **kwargs: Any - ) -> None: ... - - @distributed_trace_async - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'management_group_id', 'variable_name', 'variable_value_name']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - async def delete_at_management_group( - self, - management_group_id: str, - variable_name: str, - variable_value_name: str, - **kwargs: Any - ) -> None: ... - - @distributed_trace_async - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'subscription_id', 'variable_name', 'variable_value_name', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - async def get( - self, - variable_name: str, - variable_value_name: str, - **kwargs: Any - ) -> VariableValue: ... - - @distributed_trace_async - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'management_group_id', 'variable_name', 'variable_value_name', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - async def get_at_management_group( - self, - management_group_id: str, - variable_name: str, - variable_value_name: str, - **kwargs: Any - ) -> VariableValue: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'subscription_id', 'variable_name', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def list( - self, - variable_name: str, - **kwargs: Any - ) -> AsyncItemPaged[VariableValue]: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'management_group_id', 'variable_name', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def list_for_management_group( - self, - management_group_id: str, - variable_name: str, - **kwargs: Any - ) -> AsyncItemPaged[VariableValue]: ... - - - class azure.mgmt.resource.policy.aio.operations.VariablesOperations: - - def __init__( - self, - *args, - **kwargs - ) -> None: ... - - @overload - async def create_or_update( - self, - variable_name: str, - parameters: Variable, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> Variable: ... - - @overload - async def create_or_update( - self, - variable_name: str, - parameters: Variable, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> Variable: ... - - @overload - async def create_or_update( - self, - variable_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> Variable: ... - - @overload - async def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - parameters: Variable, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> Variable: ... - - @overload - async def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - parameters: Variable, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> Variable: ... - - @overload - async def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> Variable: ... - - @distributed_trace_async - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'subscription_id', 'variable_name']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - async def delete( - self, - variable_name: str, - **kwargs: Any - ) -> None: ... - - @distributed_trace_async - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'management_group_id', 'variable_name']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - async def delete_at_management_group( - self, - management_group_id: str, - variable_name: str, - **kwargs: Any - ) -> None: ... - - @distributed_trace_async - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'subscription_id', 'variable_name', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - async def get( - self, - variable_name: str, - **kwargs: Any - ) -> Variable: ... - - @distributed_trace_async - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'management_group_id', 'variable_name', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - async def get_at_management_group( - self, - management_group_id: str, - variable_name: str, - **kwargs: Any - ) -> Variable: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'subscription_id', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def list(self, **kwargs: Any) -> AsyncItemPaged[Variable]: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'management_group_id', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def list_for_management_group( - self, - management_group_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncItemPaged[Variable]: ... + ) -> PolicyTokenResponse: ... namespace azure.mgmt.resource.policy.models @@ -1624,11 +1093,6 @@ namespace azure.mgmt.resource.policy.models PLAIN_TEXT = "PlainText" - class azure.mgmt.resource.policy.models.AssignmentScopeValidation(str, Enum, metaclass=CaseInsensitiveEnumMeta): - DEFAULT = "Default" - DO_NOT_VALIDATE = "DoNotValidate" - - class azure.mgmt.resource.policy.models.AssignmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): CUSTOM = "Custom" NOT_SPECIFIED = "NotSpecified" @@ -1780,16 +1244,6 @@ namespace azure.mgmt.resource.policy.models def __init__(self, mapping: Mapping[str, Any]) -> None: ... - class azure.mgmt.resource.policy.models.ExemptionCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): - MITIGATED = "Mitigated" - WAIVER = "Waiver" - - - class azure.mgmt.resource.policy.models.ExemptionManagementMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - ADMIN = "Admin" - USER_SELF_SERVE = "UserSelfServe" - - class azure.mgmt.resource.policy.models.ExtensionResource(Resource): id: str name: str @@ -2293,197 +1747,6 @@ namespace azure.mgmt.resource.policy.models def __init__(self, mapping: Mapping[str, Any]) -> None: ... - class azure.mgmt.resource.policy.models.PolicyEnrollment(ExtensionResource): - e_tag: Optional[str] - id: str - name: str - properties: Optional[PolicyEnrollmentProperties] - system_data: SystemData - type: str - - def __getattr__(self, name: str) -> Any: ... - - @overload - def __init__( - self, - *, - e_tag: Optional[str] = ..., - properties: Optional[PolicyEnrollmentProperties] = ... - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: ... - - def __setattr__( - self, - key: str, - value: Any - ) -> None: ... - - - class azure.mgmt.resource.policy.models.PolicyEnrollmentProperties(_Model): - assignment_scope_validation: Optional[Union[str, AssignmentScopeValidation]] - description: Optional[str] - display_name: Optional[str] - metadata: Optional[Any] - policy_assignment_id: str - policy_assignment_instance_id: Optional[str] - policy_definition_reference_ids: Optional[list[str]] - resource_selectors: Optional[list[ResourceSelector]] - - @overload - def __init__( - self, - *, - assignment_scope_validation: Optional[Union[str, AssignmentScopeValidation]] = ..., - description: Optional[str] = ..., - display_name: Optional[str] = ..., - metadata: Optional[Any] = ..., - policy_assignment_id: str, - policy_definition_reference_ids: Optional[list[str]] = ..., - resource_selectors: Optional[list[ResourceSelector]] = ... - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: ... - - - class azure.mgmt.resource.policy.models.PolicyEnrollmentUpdate(_Model): - properties: Optional[PolicyEnrollmentUpdateProperties] - - def __getattr__(self, name: str) -> Any: ... - - @overload - def __init__( - self, - *, - properties: Optional[PolicyEnrollmentUpdateProperties] = ... - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: ... - - def __setattr__( - self, - key: str, - value: Any - ) -> None: ... - - - class azure.mgmt.resource.policy.models.PolicyEnrollmentUpdateProperties(_Model): - assignment_scope_validation: Optional[Union[str, AssignmentScopeValidation]] - resource_selectors: Optional[list[ResourceSelector]] - - @overload - def __init__( - self, - *, - assignment_scope_validation: Optional[Union[str, AssignmentScopeValidation]] = ..., - resource_selectors: Optional[list[ResourceSelector]] = ... - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: ... - - - class azure.mgmt.resource.policy.models.PolicyExemption(ExtensionResource): - id: str - name: str - properties: Optional[PolicyExemptionProperties] - system_data: SystemData - type: str - - def __getattr__(self, name: str) -> Any: ... - - @overload - def __init__( - self, - *, - properties: Optional[PolicyExemptionProperties] = ... - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: ... - - def __setattr__( - self, - key: str, - value: Any - ) -> None: ... - - - class azure.mgmt.resource.policy.models.PolicyExemptionProperties(_Model): - assignment_scope_validation: Optional[Union[str, AssignmentScopeValidation]] - description: Optional[str] - display_name: Optional[str] - exemption_category: Union[str, ExemptionCategory] - exemption_management_mode: Optional[Union[str, ExemptionManagementMode]] - expires_on: Optional[datetime] - metadata: Optional[Any] - policy_assignment_id: str - policy_definition_reference_ids: Optional[list[str]] - resource_selectors: Optional[list[ResourceSelector]] - - @overload - def __init__( - self, - *, - assignment_scope_validation: Optional[Union[str, AssignmentScopeValidation]] = ..., - description: Optional[str] = ..., - display_name: Optional[str] = ..., - exemption_category: Union[str, ExemptionCategory], - exemption_management_mode: Optional[Union[str, ExemptionManagementMode]] = ..., - expires_on: Optional[datetime] = ..., - metadata: Optional[Any] = ..., - policy_assignment_id: str, - policy_definition_reference_ids: Optional[list[str]] = ..., - resource_selectors: Optional[list[ResourceSelector]] = ... - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: ... - - - class azure.mgmt.resource.policy.models.PolicyExemptionUpdate(_Model): - properties: Optional[PolicyExemptionUpdateProperties] - - def __getattr__(self, name: str) -> Any: ... - - @overload - def __init__( - self, - *, - properties: Optional[PolicyExemptionUpdateProperties] = ... - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: ... - - def __setattr__( - self, - key: str, - value: Any - ) -> None: ... - - - class azure.mgmt.resource.policy.models.PolicyExemptionUpdateProperties(_Model): - assignment_scope_validation: Optional[Union[str, AssignmentScopeValidation]] - exemption_management_mode: Optional[Union[str, ExemptionManagementMode]] - resource_selectors: Optional[list[ResourceSelector]] - - @overload - def __init__( - self, - *, - assignment_scope_validation: Optional[Union[str, AssignmentScopeValidation]] = ..., - exemption_management_mode: Optional[Union[str, ExemptionManagementMode]] = ..., - resource_selectors: Optional[list[ResourceSelector]] = ... - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: ... - - class azure.mgmt.resource.policy.models.PolicyLogInfo(_Model): policy_assignment_id: Optional[str] policy_assignment_name: Optional[str] @@ -2746,64 +2009,6 @@ namespace azure.mgmt.resource.policy.models STATIC = "Static" - class azure.mgmt.resource.policy.models.PolicyVariableColumn(_Model): - column_name: str - - @overload - def __init__( - self, - *, - column_name: str - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: ... - - - class azure.mgmt.resource.policy.models.PolicyVariableProperties(_Model): - columns: list[PolicyVariableColumn] - - @overload - def __init__( - self, - *, - columns: list[PolicyVariableColumn] - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: ... - - - class azure.mgmt.resource.policy.models.PolicyVariableValueColumnValue(_Model): - column_name: str - column_value: Any - - @overload - def __init__( - self, - *, - column_name: str, - column_value: Any - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: ... - - - class azure.mgmt.resource.policy.models.PolicyVariableValueProperties(_Model): - values_property: list[PolicyVariableValueColumnValue] - - @overload - def __init__( - self, - *, - values_property: list[PolicyVariableValueColumnValue] - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: ... - - class azure.mgmt.resource.policy.models.ProxyResource(Resource): id: str name: str @@ -2860,6 +2065,7 @@ namespace azure.mgmt.resource.policy.models in_property: Optional[list[str]] kind: Optional[Union[str, SelectorKind]] not_in: Optional[list[str]] + progress: Optional[int] @overload def __init__( @@ -2867,7 +2073,8 @@ namespace azure.mgmt.resource.policy.models *, in_property: Optional[list[str]] = ..., kind: Optional[Union[str, SelectorKind]] = ..., - not_in: Optional[list[str]] = ... + not_in: Optional[list[str]] = ..., + progress: Optional[int] = ... ) -> None: ... @overload @@ -2878,106 +2085,55 @@ namespace azure.mgmt.resource.policy.models GROUP_PRINCIPAL_ID = "groupPrincipalId" POLICY_DEFINITION_REFERENCE_ID = "policyDefinitionReferenceId" RESOURCE_LOCATION = "resourceLocation" + RESOURCE_ROLLOUT_PERCENTAGE = "resourceRolloutPercentage" RESOURCE_TYPE = "resourceType" - RESOURCE_WITHOUT_LOCATION = "resourceWithoutLocation" - USER_PRINCIPAL_ID = "userPrincipalId" - - - class azure.mgmt.resource.policy.models.SelfServeExemptionSettings(_Model): - enabled: Optional[bool] - policy_definition_reference_ids: Optional[list[str]] - - @overload - def __init__( - self, - *, - enabled: Optional[bool] = ..., - policy_definition_reference_ids: Optional[list[str]] = ... - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: ... - - - class azure.mgmt.resource.policy.models.SystemData(_Model): - created_at: Optional[datetime] - created_by: Optional[str] - created_by_type: Optional[Union[str, CreatedByType]] - last_modified_at: Optional[datetime] - last_modified_by: Optional[str] - last_modified_by_type: Optional[Union[str, CreatedByType]] - - @overload - def __init__( - self, - *, - created_at: Optional[datetime] = ..., - created_by: Optional[str] = ..., - created_by_type: Optional[Union[str, CreatedByType]] = ..., - last_modified_at: Optional[datetime] = ..., - last_modified_by: Optional[str] = ..., - last_modified_by_type: Optional[Union[str, CreatedByType]] = ... - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: ... - - - class azure.mgmt.resource.policy.models.UserAssignedIdentitiesValue(_Model): - client_id: Optional[str] - principal_id: Optional[str] - - - class azure.mgmt.resource.policy.models.Variable(ProxyResource): - id: str - name: str - properties: Optional[PolicyVariableProperties] - system_data: SystemData - type: str + RESOURCE_WITHOUT_LOCATION = "resourceWithoutLocation" + USER_PRINCIPAL_ID = "userPrincipalId" - def __getattr__(self, name: str) -> Any: ... + + class azure.mgmt.resource.policy.models.SelfServeExemptionSettings(_Model): + enabled: Optional[bool] + policy_definition_reference_ids: Optional[list[str]] @overload def __init__( self, *, - properties: Optional[PolicyVariableProperties] = ... + enabled: Optional[bool] = ..., + policy_definition_reference_ids: Optional[list[str]] = ... ) -> None: ... @overload def __init__(self, mapping: Mapping[str, Any]) -> None: ... - def __setattr__( - self, - key: str, - value: Any - ) -> None: ... - - - class azure.mgmt.resource.policy.models.VariableValue(ProxyResource): - id: str - name: str - properties: Optional[PolicyVariableValueProperties] - system_data: SystemData - type: str - def __getattr__(self, name: str) -> Any: ... + class azure.mgmt.resource.policy.models.SystemData(_Model): + created_at: Optional[datetime] + created_by: Optional[str] + created_by_type: Optional[Union[str, CreatedByType]] + last_modified_at: Optional[datetime] + last_modified_by: Optional[str] + last_modified_by_type: Optional[Union[str, CreatedByType]] @overload def __init__( self, *, - properties: Optional[PolicyVariableValueProperties] = ... + created_at: Optional[datetime] = ..., + created_by: Optional[str] = ..., + created_by_type: Optional[Union[str, CreatedByType]] = ..., + last_modified_at: Optional[datetime] = ..., + last_modified_by: Optional[str] = ..., + last_modified_by_type: Optional[Union[str, CreatedByType]] = ... ) -> None: ... @overload def __init__(self, mapping: Mapping[str, Any]) -> None: ... - def __setattr__( - self, - key: str, - value: Any - ) -> None: ... + + class azure.mgmt.resource.policy.models.UserAssignedIdentitiesValue(_Model): + client_id: Optional[str] + principal_id: Optional[str] namespace azure.mgmt.resource.policy.operations @@ -2991,7 +2147,7 @@ namespace azure.mgmt.resource.policy.operations ) -> None: ... @distributed_trace - @api_version_validation(method_added_on='2025-11-01', params_added_on={'2025-11-01': ['api_version', 'policy_mode', 'accept']}, api_versions_list=['2025-11-01', '2025-12-01-preview', '2026-01-01-preview']) + @api_version_validation(method_added_on='2025-11-01', params_added_on={'2025-11-01': ['api_version', 'policy_mode', 'accept']}, api_versions_list=['2025-11-01', '2025-12-01-preview', '2026-01-01-preview', '2026-06-01']) def get_by_policy_mode( self, policy_mode: str, @@ -2999,7 +2155,7 @@ namespace azure.mgmt.resource.policy.operations ) -> DataPolicyManifest: ... @distributed_trace - @api_version_validation(method_added_on='2025-11-01', params_added_on={'2025-11-01': ['api_version', 'filter', 'accept']}, api_versions_list=['2025-11-01', '2025-12-01-preview', '2026-01-01-preview']) + @api_version_validation(method_added_on='2025-11-01', params_added_on={'2025-11-01': ['api_version', 'filter', 'accept']}, api_versions_list=['2025-11-01', '2025-12-01-preview', '2026-01-01-preview', '2026-06-01']) def list( self, *, @@ -3517,279 +2673,7 @@ namespace azure.mgmt.resource.policy.operations filter: Optional[str] = ..., top: Optional[int] = ..., **kwargs: Any - ) -> ItemPaged[PolicyDefinition]: ... - - - class azure.mgmt.resource.policy.operations.PolicyEnrollmentsOperations: - - def __init__( - self, - *args, - **kwargs - ) -> None: ... - - @overload - def create_or_update( - self, - scope: str, - policy_enrollment_name: str, - parameters: PolicyEnrollment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyEnrollment: ... - - @overload - def create_or_update( - self, - scope: str, - policy_enrollment_name: str, - parameters: PolicyEnrollment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyEnrollment: ... - - @overload - def create_or_update( - self, - scope: str, - policy_enrollment_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyEnrollment: ... - - @distributed_trace - @api_version_validation(method_added_on='2026-01-01-preview', params_added_on={'2026-01-01-preview': ['api_version', 'scope', 'policy_enrollment_name']}, api_versions_list=['2026-01-01-preview']) - def delete( - self, - scope: str, - policy_enrollment_name: str, - **kwargs: Any - ) -> None: ... - - @distributed_trace - @api_version_validation(method_added_on='2026-01-01-preview', params_added_on={'2026-01-01-preview': ['api_version', 'scope', 'policy_enrollment_name', 'accept']}, api_versions_list=['2026-01-01-preview']) - def get( - self, - scope: str, - policy_enrollment_name: str, - **kwargs: Any - ) -> PolicyEnrollment: ... - - @distributed_trace - @api_version_validation(method_added_on='2026-01-01-preview', params_added_on={'2026-01-01-preview': ['api_version', 'subscription_id', 'filter', 'accept']}, api_versions_list=['2026-01-01-preview']) - def list( - self, - *, - filter: Optional[str] = ..., - **kwargs: Any - ) -> ItemPaged[PolicyEnrollment]: ... - - @distributed_trace - @api_version_validation(method_added_on='2026-01-01-preview', params_added_on={'2026-01-01-preview': ['api_version', 'management_group_id', 'filter', 'accept']}, api_versions_list=['2026-01-01-preview']) - def list_for_management_group( - self, - management_group_id: str, - *, - filter: Optional[str] = ..., - **kwargs: Any - ) -> ItemPaged[PolicyEnrollment]: ... - - @distributed_trace - @api_version_validation(method_added_on='2026-01-01-preview', params_added_on={'2026-01-01-preview': ['subscription_id', 'resource_group_name', 'resource_provider_namespace', 'parent_resource_path', 'resource_type', 'resource_name', 'api_version', 'filter', 'accept']}, api_versions_list=['2026-01-01-preview']) - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - *, - filter: Optional[str] = ..., - **kwargs: Any - ) -> ItemPaged[PolicyEnrollment]: ... - - @distributed_trace - @api_version_validation(method_added_on='2026-01-01-preview', params_added_on={'2026-01-01-preview': ['api_version', 'subscription_id', 'resource_group_name', 'filter', 'accept']}, api_versions_list=['2026-01-01-preview']) - def list_for_resource_group( - self, - resource_group_name: str, - *, - filter: Optional[str] = ..., - **kwargs: Any - ) -> ItemPaged[PolicyEnrollment]: ... - - @overload - def update( - self, - scope: str, - policy_enrollment_name: str, - parameters: PolicyEnrollmentUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyEnrollment: ... - - @overload - def update( - self, - scope: str, - policy_enrollment_name: str, - parameters: PolicyEnrollmentUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyEnrollment: ... - - @overload - def update( - self, - scope: str, - policy_enrollment_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyEnrollment: ... - - - class azure.mgmt.resource.policy.operations.PolicyExemptionsOperations: - - def __init__( - self, - *args, - **kwargs - ) -> None: ... - - @overload - def create_or_update( - self, - scope: str, - policy_exemption_name: str, - parameters: PolicyExemption, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyExemption: ... - - @overload - def create_or_update( - self, - scope: str, - policy_exemption_name: str, - parameters: PolicyExemption, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyExemption: ... - - @overload - def create_or_update( - self, - scope: str, - policy_exemption_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyExemption: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'scope', 'policy_exemption_name']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def delete( - self, - scope: str, - policy_exemption_name: str, - **kwargs: Any - ) -> None: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'scope', 'policy_exemption_name', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def get( - self, - scope: str, - policy_exemption_name: str, - **kwargs: Any - ) -> PolicyExemption: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'subscription_id', 'filter', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def list( - self, - *, - filter: Optional[str] = ..., - **kwargs: Any - ) -> ItemPaged[PolicyExemption]: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'management_group_id', 'filter', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def list_for_management_group( - self, - management_group_id: str, - *, - filter: Optional[str] = ..., - **kwargs: Any - ) -> ItemPaged[PolicyExemption]: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['subscription_id', 'resource_group_name', 'resource_provider_namespace', 'parent_resource_path', 'resource_type', 'resource_name', 'api_version', 'filter', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - *, - filter: Optional[str] = ..., - **kwargs: Any - ) -> ItemPaged[PolicyExemption]: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'subscription_id', 'resource_group_name', 'filter', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def list_for_resource_group( - self, - resource_group_name: str, - *, - filter: Optional[str] = ..., - **kwargs: Any - ) -> ItemPaged[PolicyExemption]: ... - - @overload - def update( - self, - scope: str, - policy_exemption_name: str, - parameters: PolicyExemptionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyExemption: ... - - @overload - def update( - self, - scope: str, - policy_exemption_name: str, - parameters: PolicyExemptionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyExemption: ... - - @overload - def update( - self, - scope: str, - policy_exemption_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> PolicyExemption: ... + ) -> ItemPaged[PolicyDefinition]: ... class azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations: @@ -4174,257 +3058,6 @@ namespace azure.mgmt.resource.policy.operations ) -> PolicyTokenResponse: ... - class azure.mgmt.resource.policy.operations.VariableValuesOperations: - - def __init__( - self, - *args, - **kwargs - ) -> None: ... - - @overload - def create_or_update( - self, - variable_name: str, - variable_value_name: str, - parameters: VariableValue, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> VariableValue: ... - - @overload - def create_or_update( - self, - variable_name: str, - variable_value_name: str, - parameters: VariableValue, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> VariableValue: ... - - @overload - def create_or_update( - self, - variable_name: str, - variable_value_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> VariableValue: ... - - @overload - def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - variable_value_name: str, - parameters: VariableValue, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> VariableValue: ... - - @overload - def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - variable_value_name: str, - parameters: VariableValue, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> VariableValue: ... - - @overload - def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - variable_value_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> VariableValue: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'subscription_id', 'variable_name', 'variable_value_name']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def delete( - self, - variable_name: str, - variable_value_name: str, - **kwargs: Any - ) -> None: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'management_group_id', 'variable_name', 'variable_value_name']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def delete_at_management_group( - self, - management_group_id: str, - variable_name: str, - variable_value_name: str, - **kwargs: Any - ) -> None: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'subscription_id', 'variable_name', 'variable_value_name', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def get( - self, - variable_name: str, - variable_value_name: str, - **kwargs: Any - ) -> VariableValue: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'management_group_id', 'variable_name', 'variable_value_name', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def get_at_management_group( - self, - management_group_id: str, - variable_name: str, - variable_value_name: str, - **kwargs: Any - ) -> VariableValue: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'subscription_id', 'variable_name', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def list( - self, - variable_name: str, - **kwargs: Any - ) -> ItemPaged[VariableValue]: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'management_group_id', 'variable_name', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def list_for_management_group( - self, - management_group_id: str, - variable_name: str, - **kwargs: Any - ) -> ItemPaged[VariableValue]: ... - - - class azure.mgmt.resource.policy.operations.VariablesOperations: - - def __init__( - self, - *args, - **kwargs - ) -> None: ... - - @overload - def create_or_update( - self, - variable_name: str, - parameters: Variable, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> Variable: ... - - @overload - def create_or_update( - self, - variable_name: str, - parameters: Variable, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> Variable: ... - - @overload - def create_or_update( - self, - variable_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> Variable: ... - - @overload - def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - parameters: Variable, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> Variable: ... - - @overload - def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - parameters: Variable, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> Variable: ... - - @overload - def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> Variable: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'subscription_id', 'variable_name']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def delete( - self, - variable_name: str, - **kwargs: Any - ) -> None: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'management_group_id', 'variable_name']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def delete_at_management_group( - self, - management_group_id: str, - variable_name: str, - **kwargs: Any - ) -> None: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'subscription_id', 'variable_name', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def get( - self, - variable_name: str, - **kwargs: Any - ) -> Variable: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'management_group_id', 'variable_name', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def get_at_management_group( - self, - management_group_id: str, - variable_name: str, - **kwargs: Any - ) -> Variable: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'subscription_id', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def list(self, **kwargs: Any) -> ItemPaged[Variable]: ... - - @distributed_trace - @api_version_validation(method_added_on='2025-12-01-preview', params_added_on={'2025-12-01-preview': ['api_version', 'management_group_id', 'accept']}, api_versions_list=['2025-12-01-preview', '2026-01-01-preview']) - def list_for_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> ItemPaged[Variable]: ... - - namespace azure.mgmt.resource.policy.types class azure.mgmt.resource.policy.types.ExtensionResource(Resource): @@ -4668,96 +3301,6 @@ namespace azure.mgmt.resource.policy.types version: str - class azure.mgmt.resource.policy.types.PolicyEnrollment(ExtensionResource): - key "eTag": str - key "id": str - key "name": str - key "properties": ForwardRef('PolicyEnrollmentProperties', module='types') - key "systemData": ForwardRef('SystemData', module='types') - key "type": str - eTag: str - id: str - name: str - properties: PolicyEnrollmentProperties - systemData: SystemData - type: str - - - class azure.mgmt.resource.policy.types.PolicyEnrollmentProperties(TypedDict, total=False): - key "assignmentScopeValidation": Union[str, AssignmentScopeValidation] - key "description": str - key "displayName": str - key "metadata": Any - key "policyAssignmentId": Required[str] - key "policyAssignmentInstanceId": str - assignmentScopeValidation: Union[str, AssignmentScopeValidation] - description: str - displayName: str - metadata: Any - policyAssignmentId: str - policyAssignmentInstanceId: str - policyDefinitionReferenceIds: list[str] - resourceSelectors: list[ResourceSelector] - - - class azure.mgmt.resource.policy.types.PolicyEnrollmentUpdate(TypedDict, total=False): - key "properties": ForwardRef('PolicyEnrollmentUpdateProperties', module='types') - properties: PolicyEnrollmentUpdateProperties - - - class azure.mgmt.resource.policy.types.PolicyEnrollmentUpdateProperties(TypedDict, total=False): - key "assignmentScopeValidation": Union[str, AssignmentScopeValidation] - assignmentScopeValidation: Union[str, AssignmentScopeValidation] - resourceSelectors: list[ResourceSelector] - - - class azure.mgmt.resource.policy.types.PolicyExemption(ExtensionResource): - key "id": str - key "name": str - key "properties": ForwardRef('PolicyExemptionProperties', module='types') - key "systemData": ForwardRef('SystemData', module='types') - key "type": str - id: str - name: str - properties: PolicyExemptionProperties - systemData: SystemData - type: str - - - class azure.mgmt.resource.policy.types.PolicyExemptionProperties(TypedDict, total=False): - key "assignmentScopeValidation": Union[str, AssignmentScopeValidation] - key "description": str - key "displayName": str - key "exemptionCategory": Required[Union[str, ExemptionCategory]] - key "exemptionManagementMode": Union[str, ExemptionManagementMode] - key "expiresOn": str - key "metadata": Any - key "policyAssignmentId": Required[str] - assignmentScopeValidation: Union[str, AssignmentScopeValidation] - description: str - displayName: str - exemptionCategory: Union[str, ExemptionCategory] - exemptionManagementMode: Union[str, ExemptionManagementMode] - expiresOn: str - metadata: Any - policyAssignmentId: str - policyDefinitionReferenceIds: list[str] - resourceSelectors: list[ResourceSelector] - - - class azure.mgmt.resource.policy.types.PolicyExemptionUpdate(TypedDict, total=False): - key "properties": ForwardRef('PolicyExemptionUpdateProperties', module='types') - properties: PolicyExemptionUpdateProperties - - - class azure.mgmt.resource.policy.types.PolicyExemptionUpdateProperties(TypedDict, total=False): - key "assignmentScopeValidation": Union[str, AssignmentScopeValidation] - key "exemptionManagementMode": Union[str, ExemptionManagementMode] - assignmentScopeValidation: Union[str, AssignmentScopeValidation] - exemptionManagementMode: Union[str, ExemptionManagementMode] - resourceSelectors: list[ResourceSelector] - - class azure.mgmt.resource.policy.types.PolicySetDefinition(ProxyResource): key "id": str key "name": str @@ -4835,28 +3378,6 @@ namespace azure.mgmt.resource.policy.types operation: PolicyTokenOperation - class azure.mgmt.resource.policy.types.PolicyVariableColumn(TypedDict, total=False): - key "columnName": Required[str] - columnName: str - - - class azure.mgmt.resource.policy.types.PolicyVariableProperties(TypedDict, total=False): - key "columns": Required[list[PolicyVariableColumn]] - columns: list[PolicyVariableColumn] - - - class azure.mgmt.resource.policy.types.PolicyVariableValueColumnValue(TypedDict, total=False): - key "columnName": Required[str] - key "columnValue": Required[Any] - columnName: str - columnValue: Any - - - class azure.mgmt.resource.policy.types.PolicyVariableValueProperties(TypedDict, total=False): - key "values": Required[list[PolicyVariableValueColumnValue]] - values: list[PolicyVariableValueColumnValue] - - class azure.mgmt.resource.policy.types.ProxyResource(Resource): key "id": str key "name": str @@ -4887,9 +3408,11 @@ namespace azure.mgmt.resource.policy.types class azure.mgmt.resource.policy.types.Selector(TypedDict): key "kind": Union[str, SelectorKind] + key "progress": int in: list[str] kind: Union[str, SelectorKind] notIn: list[str] + progress: int class azure.mgmt.resource.policy.types.SelfServeExemptionSettings(TypedDict, total=False): @@ -4920,30 +3443,4 @@ namespace azure.mgmt.resource.policy.types principalId: str - class azure.mgmt.resource.policy.types.Variable(ProxyResource): - key "id": str - key "name": str - key "properties": ForwardRef('PolicyVariableProperties', module='types') - key "systemData": ForwardRef('SystemData', module='types') - key "type": str - id: str - name: str - properties: PolicyVariableProperties - systemData: SystemData - type: str - - - class azure.mgmt.resource.policy.types.VariableValue(ProxyResource): - key "id": str - key "name": str - key "properties": ForwardRef('PolicyVariableValueProperties', module='types') - key "systemData": ForwardRef('SystemData', module='types') - key "type": str - id: str - name: str - properties: PolicyVariableValueProperties - systemData: SystemData - type: str - - ``` \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource-policy/api.metadata.yml b/sdk/resources/azure-mgmt-resource-policy/api.metadata.yml index 7e1ca67abdc4..cc68d0147c23 100644 --- a/sdk/resources/azure-mgmt-resource-policy/api.metadata.yml +++ b/sdk/resources/azure-mgmt-resource-policy/api.metadata.yml @@ -1,3 +1,4 @@ -apiMdSha256: d1cd80c0c9288711807ca5352b122bba4e03b692b8c2fa98b02c26cf087b105b +apiMdSha256: 9457f01dc3258df4655f40fd2351e303ee2287b613bd165052b843732306bd05 +packageVersion: 1.0.0 parserVersion: 0.3.31 pythonVersion: 3.13.15 diff --git a/sdk/resources/azure-mgmt-resource-policy/apiview-properties.json b/sdk/resources/azure-mgmt-resource-policy/apiview-properties.json index 4e23a24b09f9..23d2bb110ecb 100644 --- a/sdk/resources/azure-mgmt-resource-policy/apiview-properties.json +++ b/sdk/resources/azure-mgmt-resource-policy/apiview-properties.json @@ -36,14 +36,6 @@ "azure.mgmt.resource.policy.models.PolicyDefinitionVersion": "Microsoft.Authorization.PolicyDefinitionVersion", "azure.mgmt.resource.policy.models.PolicyDefinitionVersionListResult": "Azure.ResourceManager.ResourceListResult", "azure.mgmt.resource.policy.models.PolicyDefinitionVersionProperties": "Microsoft.Authorization.PolicyDefinitionVersionProperties", - "azure.mgmt.resource.policy.models.PolicyEnrollment": "Microsoft.Authorization.PolicyEnrollment", - "azure.mgmt.resource.policy.models.PolicyEnrollmentProperties": "Microsoft.Authorization.PolicyEnrollmentProperties", - "azure.mgmt.resource.policy.models.PolicyEnrollmentUpdate": "Microsoft.Authorization.PolicyEnrollmentUpdate", - "azure.mgmt.resource.policy.models.PolicyEnrollmentUpdateProperties": "Microsoft.Authorization.PolicyEnrollmentUpdateProperties", - "azure.mgmt.resource.policy.models.PolicyExemption": "Microsoft.Authorization.PolicyExemption", - "azure.mgmt.resource.policy.models.PolicyExemptionProperties": "Microsoft.Authorization.PolicyExemptionProperties", - "azure.mgmt.resource.policy.models.PolicyExemptionUpdate": "Microsoft.Authorization.PolicyExemptionUpdate", - "azure.mgmt.resource.policy.models.PolicyExemptionUpdateProperties": "Microsoft.Authorization.PolicyExemptionUpdateProperties", "azure.mgmt.resource.policy.models.PolicyLogInfo": "Microsoft.Authorization.PolicyLogInfo", "azure.mgmt.resource.policy.models.PolicySetDefinition": "Microsoft.Authorization.PolicySetDefinition", "azure.mgmt.resource.policy.models.PolicySetDefinitionProperties": "Microsoft.Authorization.PolicySetDefinitionProperties", @@ -54,18 +46,12 @@ "azure.mgmt.resource.policy.models.PolicyTokenOperation": "Microsoft.Authorization.PolicyTokenOperation", "azure.mgmt.resource.policy.models.PolicyTokenRequest": "Microsoft.Authorization.PolicyTokenRequest", "azure.mgmt.resource.policy.models.PolicyTokenResponse": "Microsoft.Authorization.PolicyTokenResponse", - "azure.mgmt.resource.policy.models.PolicyVariableColumn": "Microsoft.Authorization.PolicyVariableColumn", - "azure.mgmt.resource.policy.models.PolicyVariableProperties": "Microsoft.Authorization.PolicyVariableProperties", - "azure.mgmt.resource.policy.models.PolicyVariableValueColumnValue": "Microsoft.Authorization.PolicyVariableValueColumnValue", - "azure.mgmt.resource.policy.models.PolicyVariableValueProperties": "Microsoft.Authorization.PolicyVariableValueProperties", "azure.mgmt.resource.policy.models.ResourceSelector": "Microsoft.Authorization.ResourceSelector", "azure.mgmt.resource.policy.models.ResourceTypeAliases": "Microsoft.Authorization.ResourceTypeAliases", "azure.mgmt.resource.policy.models.Selector": "Microsoft.Authorization.Selector", "azure.mgmt.resource.policy.models.SelfServeExemptionSettings": "Microsoft.Authorization.SelfServeExemptionSettings", "azure.mgmt.resource.policy.models.SystemData": "Azure.ResourceManager.CommonTypes.SystemData", "azure.mgmt.resource.policy.models.UserAssignedIdentitiesValue": "Microsoft.Authorization.UserAssignedIdentitiesValue", - "azure.mgmt.resource.policy.models.Variable": "Microsoft.Authorization.Variable", - "azure.mgmt.resource.policy.models.VariableValue": "Microsoft.Authorization.VariableValue", "azure.mgmt.resource.policy.models.CreatedByType": "Azure.ResourceManager.CommonTypes.createdByType", "azure.mgmt.resource.policy.models.EnforcementMode": "Microsoft.Authorization.EnforcementMode", "azure.mgmt.resource.policy.models.SelectorKind": "Microsoft.Authorization.SelectorKind", @@ -78,9 +64,6 @@ "azure.mgmt.resource.policy.models.AliasType": "Microsoft.Authorization.AliasType", "azure.mgmt.resource.policy.models.PolicyType": "Microsoft.Authorization.PolicyType", "azure.mgmt.resource.policy.models.ParameterType": "Microsoft.Authorization.ParameterType", - "azure.mgmt.resource.policy.models.AssignmentScopeValidation": "Microsoft.Authorization.AssignmentScopeValidation", - "azure.mgmt.resource.policy.models.ExemptionCategory": "Microsoft.Authorization.ExemptionCategory", - "azure.mgmt.resource.policy.models.ExemptionManagementMode": "Microsoft.Authorization.ExemptionManagementMode", "azure.mgmt.resource.policy.models.PolicyTokenResult": "Microsoft.Authorization.PolicyTokenResult", "azure.mgmt.resource.policy.models.ExternalEndpointResult": "Microsoft.Authorization.ExternalEndpointResult", "azure.mgmt.resource.policy.models.PolicyAction": "Microsoft.Authorization.PolicyAction", @@ -158,38 +141,6 @@ "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.list_all_at_management_group": "Microsoft.Authorization.PolicyDefinitionVersionsOperationGroup.listAllAtManagementGroup", "azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations.list_all": "Microsoft.Authorization.PolicyDefinitionVersionsOperationGroup.listAll", "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.list_all": "Microsoft.Authorization.PolicyDefinitionVersionsOperationGroup.listAll", - "azure.mgmt.resource.policy.operations.PolicyEnrollmentsOperations.get": "Microsoft.Authorization.PolicyEnrollments.get", - "azure.mgmt.resource.policy.aio.operations.PolicyEnrollmentsOperations.get": "Microsoft.Authorization.PolicyEnrollments.get", - "azure.mgmt.resource.policy.operations.PolicyEnrollmentsOperations.create_or_update": "Microsoft.Authorization.PolicyEnrollments.createOrUpdate", - "azure.mgmt.resource.policy.aio.operations.PolicyEnrollmentsOperations.create_or_update": "Microsoft.Authorization.PolicyEnrollments.createOrUpdate", - "azure.mgmt.resource.policy.operations.PolicyEnrollmentsOperations.update": "Microsoft.Authorization.PolicyEnrollments.update", - "azure.mgmt.resource.policy.aio.operations.PolicyEnrollmentsOperations.update": "Microsoft.Authorization.PolicyEnrollments.update", - "azure.mgmt.resource.policy.operations.PolicyEnrollmentsOperations.delete": "Microsoft.Authorization.PolicyEnrollments.delete", - "azure.mgmt.resource.policy.aio.operations.PolicyEnrollmentsOperations.delete": "Microsoft.Authorization.PolicyEnrollments.delete", - "azure.mgmt.resource.policy.operations.PolicyEnrollmentsOperations.list_for_resource_group": "Microsoft.Authorization.PolicyEnrollments.listForResourceGroup", - "azure.mgmt.resource.policy.aio.operations.PolicyEnrollmentsOperations.list_for_resource_group": "Microsoft.Authorization.PolicyEnrollments.listForResourceGroup", - "azure.mgmt.resource.policy.operations.PolicyEnrollmentsOperations.list_for_management_group": "Microsoft.Authorization.PolicyEnrollments.listForManagementGroup", - "azure.mgmt.resource.policy.aio.operations.PolicyEnrollmentsOperations.list_for_management_group": "Microsoft.Authorization.PolicyEnrollments.listForManagementGroup", - "azure.mgmt.resource.policy.operations.PolicyEnrollmentsOperations.list": "Microsoft.Authorization.PolicyEnrollments.list", - "azure.mgmt.resource.policy.aio.operations.PolicyEnrollmentsOperations.list": "Microsoft.Authorization.PolicyEnrollments.list", - "azure.mgmt.resource.policy.operations.PolicyEnrollmentsOperations.list_for_resource": "Microsoft.Authorization.PolicyEnrollments.listForResource", - "azure.mgmt.resource.policy.aio.operations.PolicyEnrollmentsOperations.list_for_resource": "Microsoft.Authorization.PolicyEnrollments.listForResource", - "azure.mgmt.resource.policy.operations.PolicyExemptionsOperations.get": "Microsoft.Authorization.PolicyExemptions.get", - "azure.mgmt.resource.policy.aio.operations.PolicyExemptionsOperations.get": "Microsoft.Authorization.PolicyExemptions.get", - "azure.mgmt.resource.policy.operations.PolicyExemptionsOperations.create_or_update": "Microsoft.Authorization.PolicyExemptions.createOrUpdate", - "azure.mgmt.resource.policy.aio.operations.PolicyExemptionsOperations.create_or_update": "Microsoft.Authorization.PolicyExemptions.createOrUpdate", - "azure.mgmt.resource.policy.operations.PolicyExemptionsOperations.update": "Microsoft.Authorization.PolicyExemptions.update", - "azure.mgmt.resource.policy.aio.operations.PolicyExemptionsOperations.update": "Microsoft.Authorization.PolicyExemptions.update", - "azure.mgmt.resource.policy.operations.PolicyExemptionsOperations.delete": "Microsoft.Authorization.PolicyExemptions.delete", - "azure.mgmt.resource.policy.aio.operations.PolicyExemptionsOperations.delete": "Microsoft.Authorization.PolicyExemptions.delete", - "azure.mgmt.resource.policy.operations.PolicyExemptionsOperations.list_for_resource_group": "Microsoft.Authorization.PolicyExemptions.listForResourceGroup", - "azure.mgmt.resource.policy.aio.operations.PolicyExemptionsOperations.list_for_resource_group": "Microsoft.Authorization.PolicyExemptions.listForResourceGroup", - "azure.mgmt.resource.policy.operations.PolicyExemptionsOperations.list_for_management_group": "Microsoft.Authorization.PolicyExemptions.listForManagementGroup", - "azure.mgmt.resource.policy.aio.operations.PolicyExemptionsOperations.list_for_management_group": "Microsoft.Authorization.PolicyExemptions.listForManagementGroup", - "azure.mgmt.resource.policy.operations.PolicyExemptionsOperations.list": "Microsoft.Authorization.PolicyExemptions.list", - "azure.mgmt.resource.policy.aio.operations.PolicyExemptionsOperations.list": "Microsoft.Authorization.PolicyExemptions.list", - "azure.mgmt.resource.policy.operations.PolicyExemptionsOperations.list_for_resource": "Microsoft.Authorization.PolicyExemptions.listForResource", - "azure.mgmt.resource.policy.aio.operations.PolicyExemptionsOperations.list_for_resource": "Microsoft.Authorization.PolicyExemptions.listForResource", "azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations.get": "Microsoft.Authorization.PolicySetDefinitions.get", "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations.get": "Microsoft.Authorization.PolicySetDefinitions.get", "azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations.create_or_update": "Microsoft.Authorization.PolicySetDefinitions.createOrUpdate", @@ -236,38 +187,6 @@ "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.list_all_at_management_group": "Microsoft.Authorization.PolicySetDefinitionVersionsOperationGroup.listAllAtManagementGroup", "azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations.list_all": "Microsoft.Authorization.PolicySetDefinitionVersionsOperationGroup.listAll", "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.list_all": "Microsoft.Authorization.PolicySetDefinitionVersionsOperationGroup.listAll", - "azure.mgmt.resource.policy.operations.VariablesOperations.get": "Microsoft.Authorization.Variables.get", - "azure.mgmt.resource.policy.aio.operations.VariablesOperations.get": "Microsoft.Authorization.Variables.get", - "azure.mgmt.resource.policy.operations.VariablesOperations.create_or_update": "Microsoft.Authorization.Variables.createOrUpdate", - "azure.mgmt.resource.policy.aio.operations.VariablesOperations.create_or_update": "Microsoft.Authorization.Variables.createOrUpdate", - "azure.mgmt.resource.policy.operations.VariablesOperations.delete": "Microsoft.Authorization.Variables.delete", - "azure.mgmt.resource.policy.aio.operations.VariablesOperations.delete": "Microsoft.Authorization.Variables.delete", - "azure.mgmt.resource.policy.operations.VariablesOperations.list": "Microsoft.Authorization.Variables.list", - "azure.mgmt.resource.policy.aio.operations.VariablesOperations.list": "Microsoft.Authorization.Variables.list", - "azure.mgmt.resource.policy.operations.VariablesOperations.get_at_management_group": "Microsoft.Authorization.Variables.getAtManagementGroup", - "azure.mgmt.resource.policy.aio.operations.VariablesOperations.get_at_management_group": "Microsoft.Authorization.Variables.getAtManagementGroup", - "azure.mgmt.resource.policy.operations.VariablesOperations.create_or_update_at_management_group": "Microsoft.Authorization.Variables.createOrUpdateAtManagementGroup", - "azure.mgmt.resource.policy.aio.operations.VariablesOperations.create_or_update_at_management_group": "Microsoft.Authorization.Variables.createOrUpdateAtManagementGroup", - "azure.mgmt.resource.policy.operations.VariablesOperations.delete_at_management_group": "Microsoft.Authorization.Variables.deleteAtManagementGroup", - "azure.mgmt.resource.policy.aio.operations.VariablesOperations.delete_at_management_group": "Microsoft.Authorization.Variables.deleteAtManagementGroup", - "azure.mgmt.resource.policy.operations.VariablesOperations.list_for_management_group": "Microsoft.Authorization.Variables.listForManagementGroup", - "azure.mgmt.resource.policy.aio.operations.VariablesOperations.list_for_management_group": "Microsoft.Authorization.Variables.listForManagementGroup", - "azure.mgmt.resource.policy.operations.VariableValuesOperations.get": "Microsoft.Authorization.VariableValues.get", - "azure.mgmt.resource.policy.aio.operations.VariableValuesOperations.get": "Microsoft.Authorization.VariableValues.get", - "azure.mgmt.resource.policy.operations.VariableValuesOperations.create_or_update": "Microsoft.Authorization.VariableValues.createOrUpdate", - "azure.mgmt.resource.policy.aio.operations.VariableValuesOperations.create_or_update": "Microsoft.Authorization.VariableValues.createOrUpdate", - "azure.mgmt.resource.policy.operations.VariableValuesOperations.delete": "Microsoft.Authorization.VariableValues.delete", - "azure.mgmt.resource.policy.aio.operations.VariableValuesOperations.delete": "Microsoft.Authorization.VariableValues.delete", - "azure.mgmt.resource.policy.operations.VariableValuesOperations.list": "Microsoft.Authorization.VariableValues.list", - "azure.mgmt.resource.policy.aio.operations.VariableValuesOperations.list": "Microsoft.Authorization.VariableValues.list", - "azure.mgmt.resource.policy.operations.VariableValuesOperations.get_at_management_group": "Microsoft.Authorization.VariableValues.getAtManagementGroup", - "azure.mgmt.resource.policy.aio.operations.VariableValuesOperations.get_at_management_group": "Microsoft.Authorization.VariableValues.getAtManagementGroup", - "azure.mgmt.resource.policy.operations.VariableValuesOperations.create_or_update_at_management_group": "Microsoft.Authorization.VariableValues.createOrUpdateAtManagementGroup", - "azure.mgmt.resource.policy.aio.operations.VariableValuesOperations.create_or_update_at_management_group": "Microsoft.Authorization.VariableValues.createOrUpdateAtManagementGroup", - "azure.mgmt.resource.policy.operations.VariableValuesOperations.delete_at_management_group": "Microsoft.Authorization.VariableValues.deleteAtManagementGroup", - "azure.mgmt.resource.policy.aio.operations.VariableValuesOperations.delete_at_management_group": "Microsoft.Authorization.VariableValues.deleteAtManagementGroup", - "azure.mgmt.resource.policy.operations.VariableValuesOperations.list_for_management_group": "Microsoft.Authorization.VariableValues.listForManagementGroup", - "azure.mgmt.resource.policy.aio.operations.VariableValuesOperations.list_for_management_group": "Microsoft.Authorization.VariableValues.listForManagementGroup", "azure.mgmt.resource.policy.operations.PolicyTokensOperations.acquire": "Microsoft.Authorization.PolicyTokensOperationGroup.acquire", "azure.mgmt.resource.policy.aio.operations.PolicyTokensOperations.acquire": "Microsoft.Authorization.PolicyTokensOperationGroup.acquire", "azure.mgmt.resource.policy.operations.PolicyTokensOperations.acquire_at_management_group": "Microsoft.Authorization.PolicyTokensOperationGroup.acquireAtManagementGroup", diff --git a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/_client.py b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/_client.py index 6c8cbbd76082..d574a6ddea15 100644 --- a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/_client.py +++ b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/_client.py @@ -24,13 +24,9 @@ PolicyAssignmentsOperations, PolicyDefinitionVersionsOperations, PolicyDefinitionsOperations, - PolicyEnrollmentsOperations, - PolicyExemptionsOperations, PolicySetDefinitionVersionsOperations, PolicySetDefinitionsOperations, PolicyTokensOperations, - VariableValuesOperations, - VariablesOperations, ) if sys.version_info >= (3, 11): @@ -57,20 +53,12 @@ class PolicyClient: # pylint: disable=too-many-instance-attributes,docstring-ke :ivar policy_definition_versions: PolicyDefinitionVersionsOperations operations :vartype policy_definition_versions: azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations - :ivar policy_enrollments: PolicyEnrollmentsOperations operations - :vartype policy_enrollments: azure.mgmt.resource.policy.operations.PolicyEnrollmentsOperations - :ivar policy_exemptions: PolicyExemptionsOperations operations - :vartype policy_exemptions: azure.mgmt.resource.policy.operations.PolicyExemptionsOperations :ivar policy_set_definitions: PolicySetDefinitionsOperations operations :vartype policy_set_definitions: azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations :ivar policy_set_definition_versions: PolicySetDefinitionVersionsOperations operations :vartype policy_set_definition_versions: azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations - :ivar variables: VariablesOperations operations - :vartype variables: azure.mgmt.resource.policy.operations.VariablesOperations - :ivar variable_values: VariableValuesOperations operations - :vartype variable_values: azure.mgmt.resource.policy.operations.VariableValuesOperations :ivar policy_tokens: PolicyTokensOperations operations :vartype policy_tokens: azure.mgmt.resource.policy.operations.PolicyTokensOperations :param credential: Credential used to authenticate requests to the service. Required. @@ -82,10 +70,9 @@ class PolicyClient: # pylint: disable=too-many-instance-attributes,docstring-ke :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is None. :paramtype cloud_setting: ~azure.core.AzureClouds - :keyword api_version: The API version to use for this operation. Known values are - "2026-01-01-preview" and None. Default value is None. If not set, the operation's default API - version will be used. Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: The API version to use for this operation. Known values are "2026-06-01" + and None. Default value is None. If not set, the operation's default API version will be used. + Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ @@ -148,20 +135,12 @@ def __init__( self.policy_definition_versions = PolicyDefinitionVersionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.policy_enrollments = PolicyEnrollmentsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.policy_exemptions = PolicyExemptionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.policy_set_definitions = PolicySetDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize ) self.policy_set_definition_versions = PolicySetDefinitionVersionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.variables = VariablesOperations(self._client, self._config, self._serialize, self._deserialize) - self.variable_values = VariableValuesOperations(self._client, self._config, self._serialize, self._deserialize) self.policy_tokens = PolicyTokensOperations(self._client, self._config, self._serialize, self._deserialize) def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: diff --git a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/_configuration.py b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/_configuration.py index c7180331dc39..d45151ee6bcc 100644 --- a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/_configuration.py +++ b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/_configuration.py @@ -34,10 +34,9 @@ class PolicyClientConfiguration: # pylint: disable=too-many-instance-attributes :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is None. :type cloud_setting: ~azure.core.AzureClouds - :keyword api_version: The API version to use for this operation. Known values are - "2026-01-01-preview" and None. Default value is None. If not set, the operation's default API - version will be used. Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: The API version to use for this operation. Known values are "2026-06-01" + and None. Default value is None. If not set, the operation's default API version will be used. + Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ @@ -49,7 +48,7 @@ def __init__( cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "2026-01-01-preview") + api_version: str = kwargs.pop("api_version", "2026-06-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/_utils/model_base.py b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/_utils/model_base.py index 88aaf1823543..35d5fc024978 100644 --- a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/_utils/model_base.py +++ b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/_utils/model_base.py @@ -1038,10 +1038,6 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: if not rf._rest_name_input: rf._rest_name_input = attr cls._attr_to_rest_field: dict[str, _RestField] = dict(attr_to_rest_field.items()) - cls._backcompat_attr_to_rest_field: dict[str, _RestField] = { - Model._get_backcompat_attribute_name(cls._attr_to_rest_field, attr): rf - for attr, rf in cls._attr_to_rest_field.items() - } # Build XML field plan for fast _init_from_xml (only for XML models) if getattr(cls, "_xml", None): cls._xml_field_plan = _build_xml_field_plan(cls, attr_to_rest_field) @@ -1054,16 +1050,6 @@ def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: if hasattr(base, "__mapping__"): base.__mapping__[discriminator or cls.__name__] = cls # type: ignore - @classmethod - def _get_backcompat_attribute_name(cls, attr_to_rest_field: dict[str, "_RestField"], attr_name: str) -> str: - rest_field_obj = attr_to_rest_field.get(attr_name) # pylint: disable=protected-access - if rest_field_obj is None: - return attr_name - original_tsp_name = getattr(rest_field_obj, "_original_tsp_name", None) # pylint: disable=protected-access - if original_tsp_name: - return original_tsp_name - return attr_name - @classmethod def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: for v in cls.__dict__.values(): @@ -1430,7 +1416,6 @@ def __init__( is_multipart_file_input: bool = False, xml: typing.Optional[dict[str, typing.Any]] = None, deserializer: typing.Optional[typing.Callable] = None, - original_tsp_name: typing.Optional[str] = None, ): self._type = type self._rest_name_input = name @@ -1444,7 +1429,6 @@ def __init__( self._is_multipart_file_input = is_multipart_file_input self._xml = xml if xml is not None else {} self._deserializer = deserializer - self._original_tsp_name = original_tsp_name @property def _class_type(self) -> typing.Any: @@ -1531,7 +1515,6 @@ def rest_field( is_multipart_file_input: bool = False, xml: typing.Optional[dict[str, typing.Any]] = None, deserializer: typing.Optional[typing.Callable] = None, - original_tsp_name: typing.Optional[str] = None, ) -> typing.Any: return _RestField( name=name, @@ -1542,7 +1525,6 @@ def rest_field( is_multipart_file_input=is_multipart_file_input, xml=xml, deserializer=deserializer, - original_tsp_name=original_tsp_name, ) diff --git a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/_version.py b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/_version.py index 22553b18fb7e..0ec13ea52bbf 100644 --- a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/_version.py +++ b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b4" +VERSION = "1.0.0" diff --git a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/aio/_client.py b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/aio/_client.py index fdf618885a8c..83dda7f6c36a 100644 --- a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/aio/_client.py +++ b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/aio/_client.py @@ -24,13 +24,9 @@ PolicyAssignmentsOperations, PolicyDefinitionVersionsOperations, PolicyDefinitionsOperations, - PolicyEnrollmentsOperations, - PolicyExemptionsOperations, PolicySetDefinitionVersionsOperations, PolicySetDefinitionsOperations, PolicyTokensOperations, - VariableValuesOperations, - VariablesOperations, ) if sys.version_info >= (3, 11): @@ -59,22 +55,12 @@ class PolicyClient: # pylint: disable=too-many-instance-attributes,docstring-ke :ivar policy_definition_versions: PolicyDefinitionVersionsOperations operations :vartype policy_definition_versions: azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations - :ivar policy_enrollments: PolicyEnrollmentsOperations operations - :vartype policy_enrollments: - azure.mgmt.resource.policy.aio.operations.PolicyEnrollmentsOperations - :ivar policy_exemptions: PolicyExemptionsOperations operations - :vartype policy_exemptions: - azure.mgmt.resource.policy.aio.operations.PolicyExemptionsOperations :ivar policy_set_definitions: PolicySetDefinitionsOperations operations :vartype policy_set_definitions: azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations :ivar policy_set_definition_versions: PolicySetDefinitionVersionsOperations operations :vartype policy_set_definition_versions: azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations - :ivar variables: VariablesOperations operations - :vartype variables: azure.mgmt.resource.policy.aio.operations.VariablesOperations - :ivar variable_values: VariableValuesOperations operations - :vartype variable_values: azure.mgmt.resource.policy.aio.operations.VariableValuesOperations :ivar policy_tokens: PolicyTokensOperations operations :vartype policy_tokens: azure.mgmt.resource.policy.aio.operations.PolicyTokensOperations :param credential: Credential used to authenticate requests to the service. Required. @@ -86,10 +72,9 @@ class PolicyClient: # pylint: disable=too-many-instance-attributes,docstring-ke :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is None. :paramtype cloud_setting: ~azure.core.AzureClouds - :keyword api_version: The API version to use for this operation. Known values are - "2026-01-01-preview" and None. Default value is None. If not set, the operation's default API - version will be used. Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: The API version to use for this operation. Known values are "2026-06-01" + and None. Default value is None. If not set, the operation's default API version will be used. + Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ @@ -154,20 +139,12 @@ def __init__( self.policy_definition_versions = PolicyDefinitionVersionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.policy_enrollments = PolicyEnrollmentsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.policy_exemptions = PolicyExemptionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.policy_set_definitions = PolicySetDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize ) self.policy_set_definition_versions = PolicySetDefinitionVersionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.variables = VariablesOperations(self._client, self._config, self._serialize, self._deserialize) - self.variable_values = VariableValuesOperations(self._client, self._config, self._serialize, self._deserialize) self.policy_tokens = PolicyTokensOperations(self._client, self._config, self._serialize, self._deserialize) def send_request( diff --git a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/aio/_configuration.py b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/aio/_configuration.py index 947d936e5559..ef1dea0b218f 100644 --- a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/aio/_configuration.py @@ -34,10 +34,9 @@ class PolicyClientConfiguration: # pylint: disable=too-many-instance-attributes :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is None. :type cloud_setting: ~azure.core.AzureClouds - :keyword api_version: The API version to use for this operation. Known values are - "2026-01-01-preview" and None. Default value is None. If not set, the operation's default API - version will be used. Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: The API version to use for this operation. Known values are "2026-06-01" + and None. Default value is None. If not set, the operation's default API version will be used. + Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ @@ -49,7 +48,7 @@ def __init__( cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "2026-01-01-preview") + api_version: str = kwargs.pop("api_version", "2026-06-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/aio/operations/__init__.py index 1f69bf806caf..487a10db1153 100644 --- a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/aio/operations/__init__.py @@ -16,12 +16,8 @@ from ._operations import DataPolicyManifestsOperations # type: ignore from ._operations import PolicyDefinitionsOperations # type: ignore from ._operations import PolicyDefinitionVersionsOperations # type: ignore -from ._operations import PolicyEnrollmentsOperations # type: ignore -from ._operations import PolicyExemptionsOperations # type: ignore from ._operations import PolicySetDefinitionsOperations # type: ignore from ._operations import PolicySetDefinitionVersionsOperations # type: ignore -from ._operations import VariablesOperations # type: ignore -from ._operations import VariableValuesOperations # type: ignore from ._operations import PolicyTokensOperations # type: ignore from ._patch import __all__ as _patch_all @@ -33,12 +29,8 @@ "DataPolicyManifestsOperations", "PolicyDefinitionsOperations", "PolicyDefinitionVersionsOperations", - "PolicyEnrollmentsOperations", - "PolicyExemptionsOperations", "PolicySetDefinitionsOperations", "PolicySetDefinitionVersionsOperations", - "VariablesOperations", - "VariableValuesOperations", "PolicyTokensOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore diff --git a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/aio/operations/_operations.py index aac633993d61..69acfd94a781 100644 --- a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/aio/operations/_operations.py @@ -73,22 +73,6 @@ build_policy_definitions_list_built_in_request, build_policy_definitions_list_by_management_group_request, build_policy_definitions_list_request, - build_policy_enrollments_create_or_update_request, - build_policy_enrollments_delete_request, - build_policy_enrollments_get_request, - build_policy_enrollments_list_for_management_group_request, - build_policy_enrollments_list_for_resource_group_request, - build_policy_enrollments_list_for_resource_request, - build_policy_enrollments_list_request, - build_policy_enrollments_update_request, - build_policy_exemptions_create_or_update_request, - build_policy_exemptions_delete_request, - build_policy_exemptions_get_request, - build_policy_exemptions_list_for_management_group_request, - build_policy_exemptions_list_for_resource_group_request, - build_policy_exemptions_list_for_resource_request, - build_policy_exemptions_list_request, - build_policy_exemptions_update_request, build_policy_set_definition_versions_create_or_update_at_management_group_request, build_policy_set_definition_versions_create_or_update_request, build_policy_set_definition_versions_delete_at_management_group_request, @@ -114,22 +98,6 @@ build_policy_set_definitions_list_request, build_policy_tokens_acquire_at_management_group_request, build_policy_tokens_acquire_request, - build_variable_values_create_or_update_at_management_group_request, - build_variable_values_create_or_update_request, - build_variable_values_delete_at_management_group_request, - build_variable_values_delete_request, - build_variable_values_get_at_management_group_request, - build_variable_values_get_request, - build_variable_values_list_for_management_group_request, - build_variable_values_list_request, - build_variables_create_or_update_at_management_group_request, - build_variables_create_or_update_request, - build_variables_delete_at_management_group_request, - build_variables_delete_request, - build_variables_get_at_management_group_request, - build_variables_get_request, - build_variables_list_for_management_group_request, - build_variables_list_request, ) from .._configuration import PolicyClientConfiguration @@ -1782,7 +1750,7 @@ def __init__(self, *args, **kwargs) -> None: @api_version_validation( method_added_on="2025-11-01", params_added_on={"2025-11-01": ["api_version", "policy_mode", "accept"]}, - api_versions_list=["2025-11-01", "2025-12-01-preview", "2026-01-01-preview"], + api_versions_list=["2025-11-01", "2025-12-01-preview", "2026-01-01-preview", "2026-06-01"], ) async def get_by_policy_mode(self, policy_mode: str, **kwargs: Any) -> _models.DataPolicyManifest: """Retrieves a data policy manifest. @@ -1854,7 +1822,7 @@ async def get_by_policy_mode(self, policy_mode: str, **kwargs: Any) -> _models.D @api_version_validation( method_added_on="2025-11-01", params_added_on={"2025-11-01": ["api_version", "filter", "accept"]}, - api_versions_list=["2025-11-01", "2025-12-01-preview", "2026-01-01-preview"], + api_versions_list=["2025-11-01", "2025-12-01-preview", "2026-01-01-preview", "2026-06-01"], ) def list(self, *, filter: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_models.DataPolicyManifest"]: """Retrieves data policy manifests. @@ -4229,14 +4197,14 @@ async def list_all(self, **kwargs: Any) -> _models.PolicyDefinitionVersionListRe return deserialized # type: ignore -class PolicyEnrollmentsOperations: # pylint: disable=docstring-missing-param +class PolicySetDefinitionsOperations: # pylint: disable=docstring-missing-param """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.resource.policy.aio.PolicyClient`'s - :attr:`policy_enrollments` attribute. + :attr:`policy_set_definitions` attribute. """ def __init__(self, *args, **kwargs) -> None: @@ -4247,23 +4215,20 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - @api_version_validation( - method_added_on="2026-01-01-preview", - params_added_on={"2026-01-01-preview": ["api_version", "scope", "policy_enrollment_name", "accept"]}, - api_versions_list=["2026-01-01-preview"], - ) - async def get(self, scope: str, policy_enrollment_name: str, **kwargs: Any) -> _models.PolicyEnrollment: - """Retrieves a policy enrollment. - - This operation retrieves a single policy enrollment, given its name and the scope it was - created at. + async def get( + self, policy_set_definition_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> _models.PolicySetDefinition: + """This operation retrieves the policy set definition in the given subscription with the given + name. - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_enrollment_name: The name of the policy enrollment. Required. - :type policy_enrollment_name: str - :return: PolicyEnrollment. The PolicyEnrollment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyEnrollment + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4277,11 +4242,12 @@ async def get(self, scope: str, policy_enrollment_name: str, **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.PolicyEnrollment] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) - _request = build_policy_enrollments_get_request( - scope=scope, - policy_enrollment_name=policy_enrollment_name, + _request = build_policy_set_definitions_get_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + expand=expand, api_version=self._config.api_version, headers=_headers, params=_params, @@ -4315,7 +4281,7 @@ async def get(self, scope: str, policy_enrollment_name: str, **kwargs: Any) -> _ if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.PolicyEnrollment, response.json()) + deserialized = _deserialize(_models.PolicySetDefinition, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -4325,128 +4291,93 @@ async def get(self, scope: str, policy_enrollment_name: str, **kwargs: Any) -> _ @overload async def create_or_update( self, - scope: str, - policy_enrollment_name: str, - parameters: _models.PolicyEnrollment, + policy_set_definition_name: str, + parameters: _models.PolicySetDefinition, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.PolicyEnrollment: - """Creates or updates a policy enrollment. - - This operation creates or updates a policy enrollment with the given scope and name. Policy - enrollments apply to all resources contained within their scope. For example, when you create a - policy enrollment at resource group scope for a policy assignment at the same or above level, - the enrollment applies to all applicable resources in the resource group. + ) -> _models.PolicySetDefinition: + """This operation creates or updates a policy set definition in the given subscription with the + given name. - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_enrollment_name: The name of the policy enrollment. Required. - :type policy_enrollment_name: str - :param parameters: The policy enrollment resource to create or replace. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyEnrollment + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinition :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PolicyEnrollment. The PolicyEnrollment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyEnrollment + :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create_or_update( self, - scope: str, - policy_enrollment_name: str, - parameters: _types.PolicyEnrollment, + policy_set_definition_name: str, + parameters: _types.PolicySetDefinition, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.PolicyEnrollment: - """Creates or updates a policy enrollment. - - This operation creates or updates a policy enrollment with the given scope and name. Policy - enrollments apply to all resources contained within their scope. For example, when you create a - policy enrollment at resource group scope for a policy assignment at the same or above level, - the enrollment applies to all applicable resources in the resource group. + ) -> _models.PolicySetDefinition: + """This operation creates or updates a policy set definition in the given subscription with the + given name. - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_enrollment_name: The name of the policy enrollment. Required. - :type policy_enrollment_name: str - :param parameters: The policy enrollment resource to create or replace. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicyEnrollment + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.types.PolicySetDefinition :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PolicyEnrollment. The PolicyEnrollment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyEnrollment + :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create_or_update( self, - scope: str, - policy_enrollment_name: str, + policy_set_definition_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.PolicyEnrollment: - """Creates or updates a policy enrollment. - - This operation creates or updates a policy enrollment with the given scope and name. Policy - enrollments apply to all resources contained within their scope. For example, when you create a - policy enrollment at resource group scope for a policy assignment at the same or above level, - the enrollment applies to all applicable resources in the resource group. + ) -> _models.PolicySetDefinition: + """This operation creates or updates a policy set definition in the given subscription with the + given name. - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_enrollment_name: The name of the policy enrollment. Required. - :type policy_enrollment_name: str - :param parameters: The policy enrollment resource to create or replace. Required. + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: PolicyEnrollment. The PolicyEnrollment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyEnrollment + :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - @api_version_validation( - method_added_on="2026-01-01-preview", - params_added_on={ - "2026-01-01-preview": ["api_version", "scope", "policy_enrollment_name", "content_type", "accept"] - }, - api_versions_list=["2026-01-01-preview"], - ) async def create_or_update( self, - scope: str, - policy_enrollment_name: str, - parameters: Union[_models.PolicyEnrollment, _types.PolicyEnrollment, IO[bytes]], + policy_set_definition_name: str, + parameters: Union[_models.PolicySetDefinition, _types.PolicySetDefinition, IO[bytes]], **kwargs: Any - ) -> _models.PolicyEnrollment: - """Creates or updates a policy enrollment. - - This operation creates or updates a policy enrollment with the given scope and name. Policy - enrollments apply to all resources contained within their scope. For example, when you create a - policy enrollment at resource group scope for a policy assignment at the same or above level, - the enrollment applies to all applicable resources in the resource group. + ) -> _models.PolicySetDefinition: + """This operation creates or updates a policy set definition in the given subscription with the + given name. - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_enrollment_name: The name of the policy enrollment. Required. - :type policy_enrollment_name: str - :param parameters: The policy enrollment resource to create or replace. Is either a - PolicyEnrollment type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyEnrollment or - ~azure.mgmt.resource.policy.types.PolicyEnrollment or IO[bytes] - :return: PolicyEnrollment. The PolicyEnrollment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyEnrollment + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Is either a PolicySetDefinition type + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinition or + ~azure.mgmt.resource.policy.types.PolicySetDefinition or IO[bytes] + :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4461,7 +4392,7 @@ async def create_or_update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyEnrollment] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _content = None @@ -4470,9 +4401,9 @@ async def create_or_update( else: _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_policy_enrollments_create_or_update_request( - scope=scope, - policy_enrollment_name=policy_enrollment_name, + _request = build_policy_set_definitions_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -4508,126 +4439,21 @@ async def create_or_update( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.PolicyEnrollment, response.json()) + deserialized = _deserialize(_models.PolicySetDefinition, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def update( - self, - scope: str, - policy_enrollment_name: str, - parameters: _models.PolicyEnrollmentUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicyEnrollment: - """Updates a policy enrollment. - - This operation updates a policy enrollment with the given scope and name. - - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_enrollment_name: The name of the policy enrollment. Required. - :type policy_enrollment_name: str - :param parameters: The properties to update in the policy enrollment. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyEnrollmentUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyEnrollment. The PolicyEnrollment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyEnrollment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - scope: str, - policy_enrollment_name: str, - parameters: _types.PolicyEnrollmentUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicyEnrollment: - """Updates a policy enrollment. - - This operation updates a policy enrollment with the given scope and name. - - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_enrollment_name: The name of the policy enrollment. Required. - :type policy_enrollment_name: str - :param parameters: The properties to update in the policy enrollment. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicyEnrollmentUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyEnrollment. The PolicyEnrollment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyEnrollment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - scope: str, - policy_enrollment_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicyEnrollment: - """Updates a policy enrollment. - - This operation updates a policy enrollment with the given scope and name. - - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_enrollment_name: The name of the policy enrollment. Required. - :type policy_enrollment_name: str - :param parameters: The properties to update in the policy enrollment. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyEnrollment. The PolicyEnrollment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyEnrollment - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - @api_version_validation( - method_added_on="2026-01-01-preview", - params_added_on={ - "2026-01-01-preview": ["api_version", "scope", "policy_enrollment_name", "content_type", "accept"] - }, - api_versions_list=["2026-01-01-preview"], - ) - async def update( - self, - scope: str, - policy_enrollment_name: str, - parameters: Union[_models.PolicyEnrollmentUpdate, _types.PolicyEnrollmentUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.PolicyEnrollment: - """Updates a policy enrollment. - - This operation updates a policy enrollment with the given scope and name. + async def delete(self, policy_set_definition_name: str, **kwargs: Any) -> None: + """This operation deletes the policy set definition in the given subscription with the given name. - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_enrollment_name: The name of the policy enrollment. Required. - :type policy_enrollment_name: str - :param parameters: The properties to update in the policy enrollment. Is either a - PolicyEnrollmentUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyEnrollmentUpdate or - ~azure.mgmt.resource.policy.types.PolicyEnrollmentUpdate or IO[bytes] - :return: PolicyEnrollment. The PolicyEnrollment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyEnrollment + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4638,25 +4464,15 @@ async def update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyEnrollment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_policy_enrollments_update_request( - scope=scope, - policy_enrollment_name=policy_enrollment_name, - content_type=content_type, + _request = build_policy_set_definitions_delete_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -4665,20 +4481,14 @@ async def update( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = _failsafe_deserialize( _models.ErrorResponse, @@ -4686,37 +4496,50 @@ async def update( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicyEnrollment, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - @api_version_validation( - method_added_on="2026-01-01-preview", - params_added_on={"2026-01-01-preview": ["api_version", "scope", "policy_enrollment_name"]}, - api_versions_list=["2026-01-01-preview"], - ) - async def delete(self, scope: str, policy_enrollment_name: str, **kwargs: Any) -> None: - """Deletes a policy enrollment. + return cls(pipeline_response, None, {}) # type: ignore - This operation deletes a policy enrollment, given its name and the scope it was created in. The - scope of a policy enrollment is the part of its ID preceding - '/providers/Microsoft.Authorization/policyEnrollments/{policyEnrollmentName}'. + @distributed_trace + def list( + self, *, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.PolicySetDefinition"]: + """This operation retrieves a list of all the policy set definitions in a given subscription that + match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType + -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list + includes all policy set definitions associated with the subscription, including those that + apply directly or from management groups that contain the given subscription. If + $filter=atExactScope() is provided, the returned list only includes all policy set definitions + that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned + list only includes all policy set definitions whose type match the {value}. Possible policyType + values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the + returned list only includes all policy set definitions whose category match the {value}. - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_enrollment_name: The name of the policy enrollment. Required. - :type policy_enrollment_name: str - :return: None - :rtype: None + :keyword filter: The filter to apply on the operation. Valid values for $filter are: + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy set definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy set definitions whose type + match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy set + definitions whose category match the {value}. Default value is None. + :paramtype filter: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :keyword top: Maximum number of records to return. When the $top filter is not provided, it + will return 500 records. Default value is None. + :paramtype top: int + :return: An iterator like instance of PolicySetDefinition + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicySetDefinition]] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4725,98 +4548,14 @@ async def delete(self, scope: str, policy_enrollment_name: str, **kwargs: Any) - } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) + def prepare_request(next_link=None): + if not next_link: - _request = build_policy_enrollments_delete_request( - scope=scope, - policy_enrollment_name=policy_enrollment_name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - @api_version_validation( - method_added_on="2026-01-01-preview", - params_added_on={ - "2026-01-01-preview": ["api_version", "subscription_id", "resource_group_name", "filter", "accept"] - }, - api_versions_list=["2026-01-01-preview"], - ) - def list_for_resource_group( - self, resource_group_name: str, *, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyEnrollment"]: - """Retrieves all policy enrollments that apply to a resource group. - - This operation retrieves the list of all policy enrollments associated with the given resource - group in the given subscription that match the optional given $filter. Valid values for $filter - are: 'atScope()' or 'atExactScope()'. If $filter is not provided, the unfiltered list includes - all policy enrollments associated with the resource group, including those that apply directly - or apply from containing scopes, as well as any applied to resources contained within the - resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atScope()' or 'atExactScope()'. If $filter is not provided, no filtering is performed. If - $filter is not provided, the unfiltered list includes all policy enrollments associated with - the scope, including those that apply directly or from containing scopes. If $filter=atScope() - is provided, the returned list includes all policy enrollments that apply to the scope, which - is everything in the unfiltered list except those applied to sub-scopes contained within the - given scope. If $filter=atExactScope() is provided, the returned list only includes all policy - enrollments that apply at the given scope. Default value is None. - :paramtype filter: str - :return: An iterator like instance of PolicyEnrollment - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyEnrollment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicyEnrollment]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_enrollments_list_for_resource_group_request( - resource_group_name=resource_group_name, + _request = build_policy_set_definitions_list_request( subscription_id=self._config.subscription_id, filter=filter, + expand=expand, + top=top, api_version=self._config.api_version, headers=_headers, params=_params, @@ -4856,7 +4595,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.PolicyEnrollment], + List[_models.PolicySetDefinition], deserialized.get("value", []), ) if cls: @@ -4884,43 +4623,22 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - @distributed_trace - @api_version_validation( - method_added_on="2026-01-01-preview", - params_added_on={"2026-01-01-preview": ["api_version", "management_group_id", "filter", "accept"]}, - api_versions_list=["2026-01-01-preview"], - ) - def list_for_management_group( - self, management_group_id: str, *, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyEnrollment"]: - """Retrieves all policy enrollments that apply to a management group. - - This operation retrieves the list of all policy enrollments applicable to the management group - that match the given $filter. Valid values for $filter are: 'atScope()' or 'atExactScope()'. If - $filter=atScope() is provided, the returned list includes all policy enrollments that are - assigned to the management group or the management group's ancestors. + @distributed_trace_async + async def get_built_in( + self, policy_set_definition_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> _models.PolicySetDefinition: + """This operation retrieves the built-in policy set definition with the given name. - :param management_group_id: The management group ID. Required. - :type management_group_id: str - :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atScope()' or 'atExactScope()'. If $filter is not provided, no filtering is performed. If - $filter is not provided, the unfiltered list includes all policy enrollments associated with - the scope, including those that apply directly or from containing scopes. If $filter=atScope() - is provided, the returned list includes all policy enrollments that apply to the scope, which - is everything in the unfiltered list except those applied to sub-scopes contained within the - given scope. If $filter=atExactScope() is provided, the returned list only includes all policy - enrollments that apply at the given scope. Default value is None. - :paramtype filter: str - :return: An iterator like instance of PolicyEnrollment - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyEnrollment] + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicyEnrollment]] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4929,113 +4647,87 @@ def list_for_management_group( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_enrollments_list_for_management_group_request( - management_group_id=management_group_id, - filter=filter, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) - return _request + _request = build_policy_set_definitions_get_built_in_request( + policy_set_definition_name=policy_set_definition_name, + expand=expand, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicyEnrollment], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - async def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, ) - response = pipeline_response.http_response + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicySetDefinition, response.json()) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - return AsyncItemPaged(get_next, extract_data) + return deserialized # type: ignore @distributed_trace - @api_version_validation( - method_added_on="2026-01-01-preview", - params_added_on={"2026-01-01-preview": ["api_version", "subscription_id", "filter", "accept"]}, - api_versions_list=["2026-01-01-preview"], - ) - def list(self, *, filter: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_models.PolicyEnrollment"]: - """Retrieves all policy enrollments that apply to a subscription. - - This operation retrieves the list of all policy enrollments associated with the given - subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' - or 'atExactScope()'. If $filter is not provided, the unfiltered list includes all policy - enrollments 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. + def list_built_in( + self, *, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.PolicySetDefinition"]: + """This operation retrieves a list of all the built-in policy set definitions that match the + optional given $filter. If $filter='category -eq {value}' is provided, the returned list only + includes all built-in policy set definitions whose category match the {value}. :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atScope()' or 'atExactScope()'. If $filter is not provided, no filtering is performed. If - $filter is not provided, the unfiltered list includes all policy enrollments associated with - the scope, including those that apply directly or from containing scopes. If $filter=atScope() - is provided, the returned list includes all policy enrollments that apply to the scope, which - is everything in the unfiltered list except those applied to sub-scopes contained within the - given scope. If $filter=atExactScope() is provided, the returned list only includes all policy - enrollments that apply at the given scope. Default value is None. + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy set definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy set definitions whose type + match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy set + definitions whose category match the {value}. Default value is None. :paramtype filter: str - :return: An iterator like instance of PolicyEnrollment + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :keyword top: Maximum number of records to return. When the $top filter is not provided, it + will return 500 records. Default value is None. + :paramtype top: int + :return: An iterator like instance of PolicySetDefinition :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyEnrollment] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.PolicyEnrollment]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.PolicySetDefinition]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5048,9 +4740,10 @@ def list(self, *, filter: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged def prepare_request(next_link=None): if not next_link: - _request = build_policy_enrollments_list_request( - subscription_id=self._config.subscription_id, + _request = build_policy_set_definitions_list_built_in_request( filter=filter, + expand=expand, + top=top, api_version=self._config.api_version, headers=_headers, params=_params, @@ -5090,7 +4783,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.PolicyEnrollment], + List[_models.PolicySetDefinition], deserialized.get("value", []), ) if cls: @@ -5118,211 +4811,23 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - @distributed_trace - @api_version_validation( - method_added_on="2026-01-01-preview", - params_added_on={ - "2026-01-01-preview": [ - "subscription_id", - "resource_group_name", - "resource_provider_namespace", - "parent_resource_path", - "resource_type", - "resource_name", - "api_version", - "filter", - "accept", - ] - }, - api_versions_list=["2026-01-01-preview"], - ) - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - *, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyEnrollment"]: - """Retrieves all policy enrollments that apply to a resource. - - This operation retrieves the list of all policy enrollments 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 'atExactScope()'. If $filter is not provided, the - unfiltered list includes all policy enrollments associated with the resource, including those - that apply directly or from all containing scopes, as well as any applied to resources - contained within the resource. Three parameters plus the resource name are used to identify a - specific resource. If the resource is not part of a parent resource (the more common case), the - parent resource path should not be provided (or provided as ''). For example a web app could be - specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', - {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent - resource, then all parameters should be provided. For example a virtual machine DNS name could - be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == - 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == - 'MyComputerName'). A convenient alternative to providing the namespace and type name separately - is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', - {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == - 'MyWebApp'). + @distributed_trace_async + async def get_at_management_group( + self, management_group_id: str, policy_set_definition_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> _models.PolicySetDefinition: + """This operation retrieves the policy set definition in the given management group with the given + name. - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :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). - Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource path. Use empty string if there is none. - Required. - :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). Required. - :type resource_type: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atScope()' or 'atExactScope()'. If $filter is not provided, no filtering is performed. If - $filter is not provided, the unfiltered list includes all policy enrollments associated with - the scope, including those that apply directly or from containing scopes. If $filter=atScope() - is provided, the returned list includes all policy enrollments that apply to the scope, which - is everything in the unfiltered list except those applied to sub-scopes contained within the - given scope. If $filter=atExactScope() is provided, the returned list only includes all policy - enrollments that apply at the given scope. Default value is None. - :paramtype filter: str - :return: An iterator like instance of PolicyEnrollment - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyEnrollment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicyEnrollment]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_enrollments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicyEnrollment], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class PolicyExemptionsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.resource.policy.aio.PolicyClient`'s - :attr:`policy_exemptions` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PolicyClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "scope", "policy_exemption_name", "accept"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - async def get(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> _models.PolicyExemption: - """Retrieves a policy exemption. - - This operation retrieves a single policy exemption, given its name and the scope it was created - at. - - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to get. Required. - :type policy_exemption_name: str - :return: PolicyExemption. The PolicyExemption is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5336,11 +4841,12 @@ async def get(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.PolicyExemption] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) - _request = build_policy_exemptions_get_request( - scope=scope, - policy_exemption_name=policy_exemption_name, + _request = build_policy_set_definitions_get_at_management_group_request( + management_group_id=management_group_id, + policy_set_definition_name=policy_set_definition_name, + expand=expand, api_version=self._config.api_version, headers=_headers, params=_params, @@ -5374,7 +4880,7 @@ async def get(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> _m if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.PolicyExemption, response.json()) + deserialized = _deserialize(_models.PolicySetDefinition, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -5382,130 +4888,107 @@ async def get(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> _m return deserialized # type: ignore @overload - async def create_or_update( + async def create_or_update_at_management_group( self, - scope: str, - policy_exemption_name: str, - parameters: _models.PolicyExemption, + management_group_id: str, + policy_set_definition_name: str, + parameters: _models.PolicySetDefinition, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.PolicyExemption: - """Creates or updates a policy exemption. - - This operation creates or updates a policy exemption with the given scope and name. Policy - exemptions apply to all resources contained within their scope. For example, when you create a - policy exemption at resource group scope for a policy assignment at the same or above level, - the exemption exempts to all applicable resources in the resource group. + ) -> _models.PolicySetDefinition: + """This operation creates or updates a policy set definition in the given management group with + the given name. - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to get. Required. - :type policy_exemption_name: str - :param parameters: Parameters for the policy exemption. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyExemption + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinition :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PolicyExemption. The PolicyExemption is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption + :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_or_update( + async def create_or_update_at_management_group( self, - scope: str, - policy_exemption_name: str, - parameters: _types.PolicyExemption, + management_group_id: str, + policy_set_definition_name: str, + parameters: _types.PolicySetDefinition, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.PolicyExemption: - """Creates or updates a policy exemption. - - This operation creates or updates a policy exemption with the given scope and name. Policy - exemptions apply to all resources contained within their scope. For example, when you create a - policy exemption at resource group scope for a policy assignment at the same or above level, - the exemption exempts to all applicable resources in the resource group. + ) -> _models.PolicySetDefinition: + """This operation creates or updates a policy set definition in the given management group with + the given name. - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to get. Required. - :type policy_exemption_name: str - :param parameters: Parameters for the policy exemption. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicyExemption + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.types.PolicySetDefinition :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PolicyExemption. The PolicyExemption is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption + :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_or_update( + async def create_or_update_at_management_group( self, - scope: str, - policy_exemption_name: str, + management_group_id: str, + policy_set_definition_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.PolicyExemption: - """Creates or updates a policy exemption. - - This operation creates or updates a policy exemption with the given scope and name. Policy - exemptions apply to all resources contained within their scope. For example, when you create a - policy exemption at resource group scope for a policy assignment at the same or above level, - the exemption exempts to all applicable resources in the resource group. + ) -> _models.PolicySetDefinition: + """This operation creates or updates a policy set definition in the given management group with + the given name. - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to get. Required. - :type policy_exemption_name: str - :param parameters: Parameters for the policy exemption. Required. + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: PolicyExemption. The PolicyExemption is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption + :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": ["api_version", "scope", "policy_exemption_name", "content_type", "accept"] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - async def create_or_update( + async def create_or_update_at_management_group( self, - scope: str, - policy_exemption_name: str, - parameters: Union[_models.PolicyExemption, _types.PolicyExemption, IO[bytes]], + management_group_id: str, + policy_set_definition_name: str, + parameters: Union[_models.PolicySetDefinition, _types.PolicySetDefinition, IO[bytes]], **kwargs: Any - ) -> _models.PolicyExemption: - """Creates or updates a policy exemption. - - This operation creates or updates a policy exemption with the given scope and name. Policy - exemptions apply to all resources contained within their scope. For example, when you create a - policy exemption at resource group scope for a policy assignment at the same or above level, - the exemption exempts to all applicable resources in the resource group. + ) -> _models.PolicySetDefinition: + """This operation creates or updates a policy set definition in the given management group with + the given name. - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to get. Required. - :type policy_exemption_name: str - :param parameters: Parameters for the policy exemption. Is either a PolicyExemption type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyExemption or - ~azure.mgmt.resource.policy.types.PolicyExemption or IO[bytes] - :return: PolicyExemption. The PolicyExemption is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Is either a PolicySetDefinition type + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinition or + ~azure.mgmt.resource.policy.types.PolicySetDefinition or IO[bytes] + :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5520,7 +5003,7 @@ async def create_or_update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyExemption] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _content = None @@ -5529,9 +5012,9 @@ async def create_or_update( else: _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_policy_exemptions_create_or_update_request( - scope=scope, - policy_exemption_name=policy_exemption_name, + _request = build_policy_set_definitions_create_or_update_at_management_group_request( + management_group_id=management_group_id, + policy_set_definition_name=policy_set_definition_name, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -5567,213 +5050,26 @@ async def create_or_update( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.PolicyExemption, response.json()) + deserialized = _deserialize(_models.PolicySetDefinition, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def update( - self, - scope: str, - policy_exemption_name: str, - parameters: _models.PolicyExemptionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicyExemption: - """Updates a policy exemption. - - This operation updates a policy exemption with the given scope and name. + @distributed_trace_async + async def delete_at_management_group( + self, management_group_id: str, policy_set_definition_name: str, **kwargs: Any + ) -> None: + """This operation deletes the policy set definition in the given management group with the given + name. - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to get. Required. - :type policy_exemption_name: str - :param parameters: Parameters for policy exemption patch request. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyExemptionUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyExemption. The PolicyExemption is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - scope: str, - policy_exemption_name: str, - parameters: _types.PolicyExemptionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicyExemption: - """Updates a policy exemption. - - This operation updates a policy exemption with the given scope and name. - - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to get. Required. - :type policy_exemption_name: str - :param parameters: Parameters for policy exemption patch request. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicyExemptionUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyExemption. The PolicyExemption is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - scope: str, - policy_exemption_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicyExemption: - """Updates a policy exemption. - - This operation updates a policy exemption with the given scope and name. - - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to get. Required. - :type policy_exemption_name: str - :param parameters: Parameters for policy exemption patch request. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyExemption. The PolicyExemption is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": ["api_version", "scope", "policy_exemption_name", "content_type", "accept"] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - async def update( - self, - scope: str, - policy_exemption_name: str, - parameters: Union[_models.PolicyExemptionUpdate, _types.PolicyExemptionUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.PolicyExemption: - """Updates a policy exemption. - - This operation updates a policy exemption with the given scope and name. - - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to get. Required. - :type policy_exemption_name: str - :param parameters: Parameters for policy exemption patch request. Is either a - PolicyExemptionUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyExemptionUpdate or - ~azure.mgmt.resource.policy.types.PolicyExemptionUpdate or IO[bytes] - :return: PolicyExemption. The PolicyExemption is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyExemption] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_policy_exemptions_update_request( - scope=scope, - policy_exemption_name=policy_exemption_name, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicyExemption, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "scope", "policy_exemption_name"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - async def delete(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> None: - """Deletes a policy exemption. - - This operation deletes a policy exemption, given its name and the scope it was created in. The - scope of a policy exemption is the part of its ID preceding - '/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'. - - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to get. Required. - :type policy_exemption_name: str - :return: None - :rtype: None + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5789,9 +5085,9 @@ async def delete(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_policy_exemptions_delete_request( - scope=scope, - policy_exemption_name=policy_exemption_name, + _request = build_policy_set_definitions_delete_at_management_group_request( + management_group_id=management_group_id, + policy_set_definition_name=policy_set_definition_name, api_version=self._config.api_version, headers=_headers, params=_params, @@ -5820,2868 +5116,55 @@ async def delete(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": ["api_version", "subscription_id", "resource_group_name", "filter", "accept"] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def list_for_resource_group( - self, resource_group_name: str, *, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyExemption"]: - """Retrieves all policy exemptions that apply to a resource group. - - This operation retrieves the list of all policy exemptions associated with the given resource - group in the given subscription that match the optional given $filter. Valid values for $filter - are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If - $filter is not provided, the unfiltered list includes all policy exemptions associated with the - resource group, including those that apply directly or apply from containing scopes, as well as - any applied to resources contained within the resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If - $filter is not provided, no filtering is performed. If $filter is not provided, the unfiltered - list includes all policy exemptions associated with the scope, including those that apply - directly or apply from containing scopes. If $filter=atScope() is provided, the returned list - only includes all policy exemptions that apply to the scope, which is everything in the - unfiltered list except those applied to sub scopes contained within the given scope. If - $filter=atExactScope() is provided, the returned list only includes all policy exemptions that - at the given scope. If $filter=excludeExpired() is provided, the returned list only includes - all policy exemptions that either haven't expired or didn't set expiration date. If - $filter=policyAssignmentId eq '{value}' is provided. the returned list only includes all policy - exemptions that are associated with the give policyAssignmentId. Default value is None. - :paramtype filter: str - :return: An iterator like instance of PolicyExemption - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyExemption] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicyExemption]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_exemptions_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicyExemption], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "management_group_id", "filter", "accept"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def list_for_management_group( - self, management_group_id: str, *, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyExemption"]: - """Retrieves all policy exemptions that apply to a management group. - - This operation retrieves the list of all policy exemptions applicable to the management group - that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', - 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter=atScope() is provided, the - returned list includes all policy exemptions that are assigned to the management group or the - management group's ancestors. - - :param management_group_id: The management group ID. Required. - :type management_group_id: str - :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If - $filter is not provided, no filtering is performed. If $filter is not provided, the unfiltered - list includes all policy exemptions associated with the scope, including those that apply - directly or apply from containing scopes. If $filter=atScope() is provided, the returned list - only includes all policy exemptions that apply to the scope, which is everything in the - unfiltered list except those applied to sub scopes contained within the given scope. If - $filter=atExactScope() is provided, the returned list only includes all policy exemptions that - at the given scope. If $filter=excludeExpired() is provided, the returned list only includes - all policy exemptions that either haven't expired or didn't set expiration date. If - $filter=policyAssignmentId eq '{value}' is provided. the returned list only includes all policy - exemptions that are associated with the give policyAssignmentId. Default value is None. - :paramtype filter: str - :return: An iterator like instance of PolicyExemption - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyExemption] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicyExemption]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_exemptions_list_for_management_group_request( - management_group_id=management_group_id, - filter=filter, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicyExemption], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "subscription_id", "filter", "accept"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def list(self, *, filter: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_models.PolicyExemption"]: - """Retrieves all policy exemptions that apply to a subscription. - - This operation retrieves the list of all policy exemptions associated with the given - subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', - 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not - provided, the unfiltered list includes all policy exemptions associated with the subscription, - including those that apply directly or from management groups that contain the given - subscription, as well as any applied to objects contained within the subscription. - - :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If - $filter is not provided, no filtering is performed. If $filter is not provided, the unfiltered - list includes all policy exemptions associated with the scope, including those that apply - directly or apply from containing scopes. If $filter=atScope() is provided, the returned list - only includes all policy exemptions that apply to the scope, which is everything in the - unfiltered list except those applied to sub scopes contained within the given scope. If - $filter=atExactScope() is provided, the returned list only includes all policy exemptions that - at the given scope. If $filter=excludeExpired() is provided, the returned list only includes - all policy exemptions that either haven't expired or didn't set expiration date. If - $filter=policyAssignmentId eq '{value}' is provided. the returned list only includes all policy - exemptions that are associated with the give policyAssignmentId. Default value is None. - :paramtype filter: str - :return: An iterator like instance of PolicyExemption - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyExemption] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicyExemption]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_exemptions_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicyExemption], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": [ - "subscription_id", - "resource_group_name", - "resource_provider_namespace", - "parent_resource_path", - "resource_type", - "resource_name", - "api_version", - "filter", - "accept", - ] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def list_for_resource( + def list_by_management_group( self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, + management_group_id: str, *, filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyExemption"]: - """Retrieves all policy exemptions that apply to a resource. - - This operation retrieves the list of all policy exemptions associated with the specified - resource in the given resource group and subscription that match the optional given $filter. - Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or - 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all - policy exemptions associated with the resource, including those that apply directly or from all - containing scopes, as well as any applied to resources contained within the resource. Three - parameters plus the resource name are used to identify a specific resource. If the resource is - not part of a parent resource (the more common case), the parent resource path should not be - provided (or provided as ''). For example a web app could be specified as - ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == - 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all - parameters should be provided. For example a virtual machine DNS name could be specified as - ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == - 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == - 'MyComputerName'). A convenient alternative to providing the namespace and type name separately - is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', - {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == - 'MyWebApp'). - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :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). - Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource path. Use empty string if there is none. - Required. - :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). Required. - :type resource_type: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If - $filter is not provided, no filtering is performed. If $filter is not provided, the unfiltered - list includes all policy exemptions associated with the scope, including those that apply - directly or apply from containing scopes. If $filter=atScope() is provided, the returned list - only includes all policy exemptions that apply to the scope, which is everything in the - unfiltered list except those applied to sub scopes contained within the given scope. If - $filter=atExactScope() is provided, the returned list only includes all policy exemptions that - at the given scope. If $filter=excludeExpired() is provided, the returned list only includes - all policy exemptions that either haven't expired or didn't set expiration date. If - $filter=policyAssignmentId eq '{value}' is provided. the returned list only includes all policy - exemptions that are associated with the give policyAssignmentId. Default value is None. - :paramtype filter: str - :return: An iterator like instance of PolicyExemption - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyExemption] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicyExemption]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_exemptions_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicyExemption], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class PolicySetDefinitionsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.resource.policy.aio.PolicyClient`'s - :attr:`policy_set_definitions` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PolicyClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, policy_set_definition_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> _models.PolicySetDefinition: - """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. Required. - :type policy_set_definition_name: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) - - _request = build_policy_set_definitions_get_request( - policy_set_definition_name=policy_set_definition_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicySetDefinition, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - policy_set_definition_name: str, - parameters: _models.PolicySetDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicySetDefinition: - """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 get. Required. - :type policy_set_definition_name: str - :param parameters: The policy set definition properties. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - policy_set_definition_name: str, - parameters: _types.PolicySetDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicySetDefinition: - """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 get. Required. - :type policy_set_definition_name: str - :param parameters: The policy set definition properties. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicySetDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - policy_set_definition_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicySetDefinition: - """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 get. Required. - :type policy_set_definition_name: str - :param parameters: The policy set definition properties. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - policy_set_definition_name: str, - parameters: Union[_models.PolicySetDefinition, _types.PolicySetDefinition, IO[bytes]], - **kwargs: Any - ) -> _models.PolicySetDefinition: - """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 get. Required. - :type policy_set_definition_name: str - :param parameters: The policy set definition properties. Is either a PolicySetDefinition type - or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinition or - ~azure.mgmt.resource.policy.types.PolicySetDefinition or IO[bytes] - :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_policy_set_definitions_create_or_update_request( - policy_set_definition_name=policy_set_definition_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicySetDefinition, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete(self, policy_set_definition_name: str, **kwargs: Any) -> None: - """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 get. Required. - :type policy_set_definition_name: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_policy_set_definitions_delete_request( - policy_set_definition_name=policy_set_definition_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def list( - self, *, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.PolicySetDefinition"]: - """This operation retrieves a list of all the policy set definitions in a given subscription that - match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType - -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list - includes all policy set definitions associated with the subscription, including those that - apply directly or from management groups that contain the given subscription. If - $filter=atExactScope() is provided, the returned list only includes all policy set definitions - that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned - list only includes all policy set definitions whose type match the {value}. Possible policyType - values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the - returned list only includes all policy set definitions whose category match the {value}. - - :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not - provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list - only includes all policy set definitions that at the given scope. If $filter='policyType -eq - {value}' is provided, the returned list only includes all policy set definitions whose type - match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If - $filter='category -eq {value}' is provided, the returned list only includes all policy set - definitions whose category match the {value}. Default value is None. - :paramtype filter: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :keyword top: Maximum number of records to return. When the $top filter is not provided, it - will return 500 records. Default value is None. - :paramtype top: int - :return: An iterator like instance of PolicySetDefinition - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicySetDefinition]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_set_definitions_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - expand=expand, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicySetDefinition], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get_built_in( - self, policy_set_definition_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> _models.PolicySetDefinition: - """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. Required. - :type policy_set_definition_name: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) - - _request = build_policy_set_definitions_get_built_in_request( - policy_set_definition_name=policy_set_definition_name, - expand=expand, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicySetDefinition, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_built_in( - self, *, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.PolicySetDefinition"]: - """This operation retrieves a list of all the built-in policy set definitions that match the - optional given $filter. If $filter='category -eq {value}' is provided, the returned list only - includes all built-in policy set definitions whose category match the {value}. - - :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not - provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list - only includes all policy set definitions that at the given scope. If $filter='policyType -eq - {value}' is provided, the returned list only includes all policy set definitions whose type - match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If - $filter='category -eq {value}' is provided, the returned list only includes all policy set - definitions whose category match the {value}. Default value is None. - :paramtype filter: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :keyword top: Maximum number of records to return. When the $top filter is not provided, it - will return 500 records. Default value is None. - :paramtype top: int - :return: An iterator like instance of PolicySetDefinition - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicySetDefinition]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_set_definitions_list_built_in_request( - filter=filter, - expand=expand, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicySetDefinition], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get_at_management_group( - self, management_group_id: str, policy_set_definition_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> _models.PolicySetDefinition: - """This operation retrieves the policy set definition in the given management group with the given - name. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param policy_set_definition_name: The name of the policy set definition to get. Required. - :type policy_set_definition_name: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) - - _request = build_policy_set_definitions_get_at_management_group_request( - management_group_id=management_group_id, - policy_set_definition_name=policy_set_definition_name, - expand=expand, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicySetDefinition, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update_at_management_group( - self, - management_group_id: str, - policy_set_definition_name: str, - parameters: _models.PolicySetDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicySetDefinition: - """This operation creates or updates a policy set definition in the given management group with - the given name. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param policy_set_definition_name: The name of the policy set definition to get. Required. - :type policy_set_definition_name: str - :param parameters: The policy set definition properties. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update_at_management_group( - self, - management_group_id: str, - policy_set_definition_name: str, - parameters: _types.PolicySetDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicySetDefinition: - """This operation creates or updates a policy set definition in the given management group with - the given name. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param policy_set_definition_name: The name of the policy set definition to get. Required. - :type policy_set_definition_name: str - :param parameters: The policy set definition properties. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicySetDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update_at_management_group( - self, - management_group_id: str, - policy_set_definition_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicySetDefinition: - """This operation creates or updates a policy set definition in the given management group with - the given name. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param policy_set_definition_name: The name of the policy set definition to get. Required. - :type policy_set_definition_name: str - :param parameters: The policy set definition properties. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update_at_management_group( - self, - management_group_id: str, - policy_set_definition_name: str, - parameters: Union[_models.PolicySetDefinition, _types.PolicySetDefinition, IO[bytes]], - **kwargs: Any - ) -> _models.PolicySetDefinition: - """This operation creates or updates a policy set definition in the given management group with - the given name. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param policy_set_definition_name: The name of the policy set definition to get. Required. - :type policy_set_definition_name: str - :param parameters: The policy set definition properties. Is either a PolicySetDefinition type - or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinition or - ~azure.mgmt.resource.policy.types.PolicySetDefinition or IO[bytes] - :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_policy_set_definitions_create_or_update_at_management_group_request( - management_group_id=management_group_id, - policy_set_definition_name=policy_set_definition_name, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicySetDefinition, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete_at_management_group( - self, management_group_id: str, policy_set_definition_name: str, **kwargs: Any - ) -> None: - """This operation deletes the policy set definition in the given management group with the given - name. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param policy_set_definition_name: The name of the policy set definition to get. Required. - :type policy_set_definition_name: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_policy_set_definitions_delete_at_management_group_request( - management_group_id=management_group_id, - policy_set_definition_name=policy_set_definition_name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def list_by_management_group( - self, - management_group_id: str, - *, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicySetDefinition"]: - """This operation retrieves a list of all the policy set definitions in a given management group - that match the optional given $filter. Valid values for $filter are: 'atExactScope()', - 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered - list includes all policy set definitions associated with the management group, including those - that apply directly or from management groups that contain the given management group. If - $filter=atExactScope() is provided, the returned list only includes all policy set definitions - that at the given management group. If $filter='policyType -eq {value}' is provided, the - returned list only includes all policy set definitions whose type match the {value}. Possible - policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is - provided, the returned list only includes all policy set definitions whose category match the - {value}. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not - provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list - only includes all policy set definitions that at the given scope. If $filter='policyType -eq - {value}' is provided, the returned list only includes all policy set definitions whose type - match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If - $filter='category -eq {value}' is provided, the returned list only includes all policy set - definitions whose category match the {value}. Default value is None. - :paramtype filter: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :keyword top: Maximum number of records to return. When the $top filter is not provided, it - will return 500 records. Default value is None. - :paramtype top: int - :return: An iterator like instance of PolicySetDefinition - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicySetDefinition]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_set_definitions_list_by_management_group_request( - management_group_id=management_group_id, - filter=filter, - expand=expand, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicySetDefinition], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class PolicySetDefinitionVersionsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.resource.policy.aio.PolicyClient`'s - :attr:`policy_set_definition_versions` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PolicyClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, - policy_set_definition_name: str, - policy_definition_version: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.PolicySetDefinitionVersion: - """This operation retrieves the policy set definition version in the given subscription with the - given name and version. - - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with - MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) - - _request = build_policy_set_definition_versions_get_request( - policy_set_definition_name=policy_set_definition_name, - policy_definition_version=policy_definition_version, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicySetDefinitionVersion, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - policy_set_definition_name: str, - policy_definition_version: str, - parameters: _models.PolicySetDefinitionVersion, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicySetDefinitionVersion: - """This operation creates or updates a policy set definition version in the given subscription - with the given name and version. - - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :param parameters: The policy set definition properties. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with - MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - policy_set_definition_name: str, - policy_definition_version: str, - parameters: _types.PolicySetDefinitionVersion, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicySetDefinitionVersion: - """This operation creates or updates a policy set definition version in the given subscription - with the given name and version. - - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :param parameters: The policy set definition properties. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicySetDefinitionVersion - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with - MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - policy_set_definition_name: str, - policy_definition_version: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicySetDefinitionVersion: - """This operation creates or updates a policy set definition version in the given subscription - with the given name and version. - - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :param parameters: The policy set definition properties. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with - MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - policy_set_definition_name: str, - policy_definition_version: str, - parameters: Union[_models.PolicySetDefinitionVersion, _types.PolicySetDefinitionVersion, IO[bytes]], - **kwargs: Any - ) -> _models.PolicySetDefinitionVersion: - """This operation creates or updates a policy set definition version in the given subscription - with the given name and version. - - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :param parameters: The policy set definition properties. Is either a PolicySetDefinitionVersion - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion or - ~azure.mgmt.resource.policy.types.PolicySetDefinitionVersion or IO[bytes] - :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with - MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_policy_set_definition_versions_create_or_update_request( - policy_set_definition_name=policy_set_definition_name, - policy_definition_version=policy_definition_version, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicySetDefinitionVersion, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete(self, policy_set_definition_name: str, policy_definition_version: str, **kwargs: Any) -> None: - """This operation deletes the policy set definition version in the given subscription with the - given name and version. - - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_policy_set_definition_versions_delete_request( - policy_set_definition_name=policy_set_definition_name, - policy_definition_version=policy_definition_version, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def list( - self, policy_set_definition_name: str, *, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.PolicySetDefinitionVersion"]: - """This operation retrieves a list of all the policy set definition versions for the given policy - set definition. - - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :keyword top: Maximum number of records to return. When the $top filter is not provided, it - will return 500 records. Default value is None. - :paramtype top: int - :return: An iterator like instance of PolicySetDefinitionVersion - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicySetDefinitionVersion]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_set_definition_versions_list_request( - policy_set_definition_name=policy_set_definition_name, - subscription_id=self._config.subscription_id, - expand=expand, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicySetDefinitionVersion], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get_built_in( - self, - policy_set_definition_name: str, - policy_definition_version: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.PolicySetDefinitionVersion: - """This operation retrieves the built-in policy set definition version with the given name and - version. - - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with - MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) - - _request = build_policy_set_definition_versions_get_built_in_request( - policy_set_definition_name=policy_set_definition_name, - policy_definition_version=policy_definition_version, - expand=expand, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicySetDefinitionVersion, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_built_in( - self, policy_set_definition_name: str, *, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.PolicySetDefinitionVersion"]: - """This operation retrieves a list of all the built-in policy set definition versions for the - given built-in policy set definition. - - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :keyword top: Maximum number of records to return. When the $top filter is not provided, it - will return 500 records. Default value is None. - :paramtype top: int - :return: An iterator like instance of PolicySetDefinitionVersion - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicySetDefinitionVersion]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_set_definition_versions_list_built_in_request( - policy_set_definition_name=policy_set_definition_name, - expand=expand, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicySetDefinitionVersion], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get_at_management_group( - self, - management_group_name: str, - policy_set_definition_name: str, - policy_definition_version: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.PolicySetDefinitionVersion: - """This operation retrieves the policy set definition version in the given management group with - the given name and version. - - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with - MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) - - _request = build_policy_set_definition_versions_get_at_management_group_request( - management_group_name=management_group_name, - policy_set_definition_name=policy_set_definition_name, - policy_definition_version=policy_definition_version, - expand=expand, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicySetDefinitionVersion, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update_at_management_group( - self, - management_group_name: str, - policy_set_definition_name: str, - policy_definition_version: str, - parameters: _models.PolicySetDefinitionVersion, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicySetDefinitionVersion: - """This operation creates or updates a policy set definition version in the given management group - with the given name and version. - - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :param parameters: The policy set definition version properties. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with - MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update_at_management_group( - self, - management_group_name: str, - policy_set_definition_name: str, - policy_definition_version: str, - parameters: _types.PolicySetDefinitionVersion, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicySetDefinitionVersion: - """This operation creates or updates a policy set definition version in the given management group - with the given name and version. - - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :param parameters: The policy set definition version properties. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicySetDefinitionVersion - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with - MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update_at_management_group( - self, - management_group_name: str, - policy_set_definition_name: str, - policy_definition_version: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicySetDefinitionVersion: - """This operation creates or updates a policy set definition version in the given management group - with the given name and version. - - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :param parameters: The policy set definition version properties. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with - MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update_at_management_group( - self, - management_group_name: str, - policy_set_definition_name: str, - policy_definition_version: str, - parameters: Union[_models.PolicySetDefinitionVersion, _types.PolicySetDefinitionVersion, IO[bytes]], - **kwargs: Any - ) -> _models.PolicySetDefinitionVersion: - """This operation creates or updates a policy set definition version in the given management group - with the given name and version. - - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :param parameters: The policy set definition version properties. Is either a - PolicySetDefinitionVersion type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion or - ~azure.mgmt.resource.policy.types.PolicySetDefinitionVersion or IO[bytes] - :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with - MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_policy_set_definition_versions_create_or_update_at_management_group_request( - management_group_name=management_group_name, - policy_set_definition_name=policy_set_definition_name, - policy_definition_version=policy_definition_version, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicySetDefinitionVersion, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete_at_management_group( - self, management_group_name: str, policy_set_definition_name: str, policy_definition_version: str, **kwargs: Any - ) -> None: - """This operation deletes the policy set definition version in the given management group with the - given name and version. - - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_policy_set_definition_versions_delete_at_management_group_request( - management_group_name=management_group_name, - policy_set_definition_name=policy_set_definition_name, - policy_definition_version=policy_definition_version, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def list_by_management_group( - self, - management_group_name: str, - policy_set_definition_name: str, - *, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicySetDefinitionVersion"]: - """This operation retrieves a list of all the policy set definition versions for the given policy - set definition in a given management group. - - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :keyword top: Maximum number of records to return. When the $top filter is not provided, it - will return 500 records. Default value is None. - :paramtype top: int - :return: An iterator like instance of PolicySetDefinitionVersion - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicySetDefinitionVersion]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_set_definition_versions_list_by_management_group_request( - management_group_name=management_group_name, - policy_set_definition_name=policy_set_definition_name, - expand=expand, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicySetDefinitionVersion], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def list_all_builtins(self, **kwargs: Any) -> _models.PolicySetDefinitionVersionListResult: - """Lists all built-in policy set definition versions. - - This operation lists all the built-in policy set definition versions for all built-in policy - set definitions. - - :return: PolicySetDefinitionVersionListResult. The PolicySetDefinitionVersionListResult is - compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersionListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) - - _request = build_policy_set_definition_versions_list_all_builtins_request( - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicySetDefinitionVersionListResult, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def list_all_at_management_group( - self, management_group_name: str, **kwargs: Any - ) -> _models.PolicySetDefinitionVersionListResult: - """Lists all policy set definition versions at management group scope. - - This operation lists all the policy set definition versions for all policy set definitions at - the management group scope. - - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :return: PolicySetDefinitionVersionListResult. The PolicySetDefinitionVersionListResult is - compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersionListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) - - _request = build_policy_set_definition_versions_list_all_at_management_group_request( - management_group_name=management_group_name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicySetDefinitionVersionListResult, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def list_all(self, **kwargs: Any) -> _models.PolicySetDefinitionVersionListResult: - """Lists all policy set definition versions within a subscription. - - This operation lists all the policy set definition versions for all policy set definitions - within a subscription. - - :return: PolicySetDefinitionVersionListResult. The PolicySetDefinitionVersionListResult is - compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersionListResult + ) -> AsyncItemPaged["_models.PolicySetDefinition"]: + """This operation retrieves a list of all the policy set definitions in a given management group + that match the optional given $filter. Valid values for $filter are: 'atExactScope()', + 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered + list includes all policy set definitions associated with the management group, including those + that apply directly or from management groups that contain the given management group. If + $filter=atExactScope() is provided, the returned list only includes all policy set definitions + that at the given management group. If $filter='policyType -eq {value}' is provided, the + returned list only includes all policy set definitions whose type match the {value}. Possible + policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is + provided, the returned list only includes all policy set definitions whose category match the + {value}. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :keyword filter: The filter to apply on the operation. Valid values for $filter are: + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy set definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy set definitions whose type + match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy set + definitions whose category match the {value}. Default value is None. + :paramtype filter: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :keyword top: Maximum number of records to return. When the $top filter is not provided, it + will return 500 records. Default value is None. + :paramtype top: int + :return: An iterator like instance of PolicySetDefinition + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicySetDefinition]] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -8690,62 +5173,90 @@ async def list_all(self, **kwargs: Any) -> _models.PolicySetDefinitionVersionLis } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} + def prepare_request(next_link=None): + if not next_link: - cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) + _request = build_policy_set_definitions_list_by_management_group_request( + management_group_id=management_group_id, + filter=filter, + expand=expand, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_policy_set_definition_versions_list_all_request( - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + return _request - response = pipeline_response.http_response + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicySetDefinition], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response = pipeline_response.http_response - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicySetDefinitionVersionListResult, response.json()) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return AsyncItemPaged(get_next, extract_data) -class VariablesOperations: # pylint: disable=docstring-missing-param +class PolicySetDefinitionVersionsOperations: # pylint: disable=docstring-missing-param """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.resource.policy.aio.PolicyClient`'s - :attr:`variables` attribute. + :attr:`policy_set_definition_versions` attribute. """ def __init__(self, *args, **kwargs) -> None: @@ -8756,21 +5267,30 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "subscription_id", "variable_name", "accept"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - async def get(self, variable_name: str, **kwargs: Any) -> _models.Variable: - """Retrieves a variable. - - This operation retrieves a single variable, given its name and the subscription it was created - at. + async def get( + self, + policy_set_definition_name: str, + policy_definition_version: str, + *, + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.PolicySetDefinitionVersion: + """This operation retrieves the policy set definition version in the given subscription with the + given name and version. - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :return: Variable. The Variable is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.Variable + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -8784,11 +5304,13 @@ async def get(self, variable_name: str, **kwargs: Any) -> _models.Variable: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Variable] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) - _request = build_variables_get_request( - variable_name=variable_name, + _request = build_policy_set_definition_versions_get_request( + policy_set_definition_name=policy_set_definition_name, + policy_definition_version=policy_definition_version, subscription_id=self._config.subscription_id, + expand=expand, api_version=self._config.api_version, headers=_headers, params=_params, @@ -8822,7 +5344,7 @@ async def get(self, variable_name: str, **kwargs: Any) -> _models.Variable: if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Variable, response.json()) + deserialized = _deserialize(_models.PolicySetDefinitionVersion, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -8831,91 +5353,118 @@ async def get(self, variable_name: str, **kwargs: Any) -> _models.Variable: @overload async def create_or_update( - self, variable_name: str, parameters: _models.Variable, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Variable: - """Creates or updates a variable. - - This operation creates or updates a variable with the given subscription and name. Policy - variables can only be used by a policy definition at the scope they are created or below. + self, + policy_set_definition_name: str, + policy_definition_version: str, + parameters: _models.PolicySetDefinitionVersion, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given subscription + with the given name and version. - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param parameters: Parameters for the variable. Required. - :type parameters: ~azure.mgmt.resource.policy.models.Variable + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :param parameters: The policy set definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: Variable. The Variable is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.Variable + :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create_or_update( - self, variable_name: str, parameters: _types.Variable, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Variable: - """Creates or updates a variable. - - This operation creates or updates a variable with the given subscription and name. Policy - variables can only be used by a policy definition at the scope they are created or below. + self, + policy_set_definition_name: str, + policy_definition_version: str, + parameters: _types.PolicySetDefinitionVersion, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given subscription + with the given name and version. - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param parameters: Parameters for the variable. Required. - :type parameters: ~azure.mgmt.resource.policy.types.Variable + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :param parameters: The policy set definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.types.PolicySetDefinitionVersion :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: Variable. The Variable is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.Variable + :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create_or_update( - self, variable_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Variable: - """Creates or updates a variable. - - This operation creates or updates a variable with the given subscription and name. Policy - variables can only be used by a policy definition at the scope they are created or below. + self, + policy_set_definition_name: str, + policy_definition_version: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given subscription + with the given name and version. - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param parameters: Parameters for the variable. Required. + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :param parameters: The policy set definition properties. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: Variable. The Variable is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.Variable + :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": ["api_version", "subscription_id", "variable_name", "content_type", "accept"] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) async def create_or_update( - self, variable_name: str, parameters: Union[_models.Variable, _types.Variable, IO[bytes]], **kwargs: Any - ) -> _models.Variable: - """Creates or updates a variable. - - This operation creates or updates a variable with the given subscription and name. Policy - variables can only be used by a policy definition at the scope they are created or below. + self, + policy_set_definition_name: str, + policy_definition_version: str, + parameters: Union[_models.PolicySetDefinitionVersion, _types.PolicySetDefinitionVersion, IO[bytes]], + **kwargs: Any + ) -> _models.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given subscription + with the given name and version. - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param parameters: Parameters for the variable. Is either a Variable type or a IO[bytes] type. + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. Required. - :type parameters: ~azure.mgmt.resource.policy.models.Variable or - ~azure.mgmt.resource.policy.types.Variable or IO[bytes] - :return: Variable. The Variable is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.Variable + :type policy_definition_version: str + :param parameters: The policy set definition properties. Is either a PolicySetDefinitionVersion + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion or + ~azure.mgmt.resource.policy.types.PolicySetDefinitionVersion or IO[bytes] + :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -8930,7 +5479,7 @@ async def create_or_update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Variable] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) content_type = content_type or "application/json" _content = None @@ -8939,8 +5488,9 @@ async def create_or_update( else: _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_variables_create_or_update_request( - variable_name=variable_name, + _request = build_policy_set_definition_versions_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + policy_definition_version=policy_definition_version, subscription_id=self._config.subscription_id, content_type=content_type, api_version=self._config.api_version, @@ -8977,7 +5527,7 @@ async def create_or_update( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Variable, response.json()) + deserialized = _deserialize(_models.PolicySetDefinitionVersion, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -8985,20 +5535,16 @@ async def create_or_update( return deserialized # type: ignore @distributed_trace_async - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "subscription_id", "variable_name"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - async def delete(self, variable_name: str, **kwargs: Any) -> None: - """Deletes a variable. - - This operation deletes a variable, given its name and the subscription it was created in. The - scope of a variable is the part of its ID preceding - '/providers/Microsoft.Authorization/variables/{variableName}'. + async def delete(self, policy_set_definition_name: str, policy_definition_version: str, **kwargs: Any) -> None: + """This operation deletes the policy set definition version in the given subscription with the + given name and version. - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -9016,8 +5562,9 @@ async def delete(self, variable_name: str, **kwargs: Any) -> None: cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_variables_delete_request( - variable_name=variable_name, + _request = build_policy_set_definition_versions_delete_request( + policy_set_definition_name=policy_set_definition_name, + policy_definition_version=policy_definition_version, subscription_id=self._config.subscription_id, api_version=self._config.api_version, headers=_headers, @@ -9047,24 +5594,30 @@ async def delete(self, variable_name: str, **kwargs: Any) -> None: return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "subscription_id", "accept"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Variable"]: - """Retrieves all variables that are at this subscription level. - - This operation retrieves the list of all variables associated with the given subscription. + def list( + self, policy_set_definition_name: str, *, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.PolicySetDefinitionVersion"]: + """This operation retrieves a list of all the policy set definition versions for the given policy + set definition. - :return: An iterator like instance of Variable - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.Variable] + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :keyword top: Maximum number of records to return. When the $top filter is not provided, it + will return 500 records. Default value is None. + :paramtype top: int + :return: An iterator like instance of PolicySetDefinitionVersion + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Variable]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.PolicySetDefinitionVersion]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -9077,8 +5630,11 @@ def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Variable"]: def prepare_request(next_link=None): if not next_link: - _request = build_variables_list_request( + _request = build_policy_set_definition_versions_list_request( + policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, + expand=expand, + top=top, api_version=self._config.api_version, headers=_headers, params=_params, @@ -9118,7 +5674,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.Variable], + List[_models.PolicySetDefinitionVersion], deserialized.get("value", []), ) if cls: @@ -9147,287 +5703,30 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "management_group_id", "variable_name", "accept"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - async def get_at_management_group( - self, management_group_id: str, variable_name: str, **kwargs: Any - ) -> _models.Variable: - """Retrieves a variable. - - This operation retrieves a single variable, given its name and the management group it was - created at. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :return: Variable. The Variable is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.Variable - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.Variable] = kwargs.pop("cls", None) - - _request = build_variables_get_at_management_group_request( - management_group_id=management_group_id, - variable_name=variable_name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.Variable, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - parameters: _models.Variable, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Variable: - """Creates or updates a variable. - - This operation creates or updates a variable with the given management group and name. Policy - variables can only be used by a policy definition at the scope they are created or below. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param parameters: Parameters for the variable. Required. - :type parameters: ~azure.mgmt.resource.policy.models.Variable - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Variable. The Variable is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.Variable - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - parameters: _types.Variable, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Variable: - """Creates or updates a variable. - - This operation creates or updates a variable with the given management group and name. Policy - variables can only be used by a policy definition at the scope they are created or below. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param parameters: Parameters for the variable. Required. - :type parameters: ~azure.mgmt.resource.policy.types.Variable - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Variable. The Variable is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.Variable - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update_at_management_group( + async def get_built_in( self, - management_group_id: str, - variable_name: str, - parameters: IO[bytes], + policy_set_definition_name: str, + policy_definition_version: str, *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Variable: - """Creates or updates a variable. - - This operation creates or updates a variable with the given management group and name. Policy - variables can only be used by a policy definition at the scope they are created or below. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param parameters: Parameters for the variable. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: Variable. The Variable is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.Variable - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": ["api_version", "management_group_id", "variable_name", "content_type", "accept"] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - async def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - parameters: Union[_models.Variable, _types.Variable, IO[bytes]], + expand: Optional[str] = None, **kwargs: Any - ) -> _models.Variable: - """Creates or updates a variable. - - This operation creates or updates a variable with the given management group and name. Policy - variables can only be used by a policy definition at the scope they are created or below. + ) -> _models.PolicySetDefinitionVersion: + """This operation retrieves the built-in policy set definition version with the given name and + version. - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param parameters: Parameters for the variable. Is either a Variable type or a IO[bytes] type. + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. Required. - :type parameters: ~azure.mgmt.resource.policy.models.Variable or - ~azure.mgmt.resource.policy.types.Variable or IO[bytes] - :return: Variable. The Variable is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.Variable - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Variable] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_variables_create_or_update_at_management_group_request( - management_group_id=management_group_id, - variable_name=variable_name, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.Variable, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "management_group_id", "variable_name"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - async def delete_at_management_group(self, management_group_id: str, variable_name: str, **kwargs: Any) -> None: - """Deletes a variable. - - This operation deletes a variable, given its name and the management group it was created in. - The scope of a variable is the part of its ID preceding - '/providers/Microsoft.Authorization/variables/{variableName}'. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :return: None - :rtype: None + :type policy_definition_version: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -9441,11 +5740,12 @@ async def delete_at_management_group(self, management_group_id: str, variable_na _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) - _request = build_variables_delete_at_management_group_request( - management_group_id=management_group_id, - variable_name=variable_name, + _request = build_policy_set_definition_versions_get_built_in_request( + policy_set_definition_name=policy_set_definition_name, + policy_definition_version=policy_definition_version, + expand=expand, api_version=self._config.api_version, headers=_headers, params=_params, @@ -9455,14 +5755,20 @@ async def delete_at_management_group(self, management_group_id: str, variable_na } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _failsafe_deserialize( _models.ErrorResponse, @@ -9470,30 +5776,41 @@ async def delete_at_management_group(self, management_group_id: str, variable_na ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicySetDefinitionVersion, response.json()) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore - @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "management_group_id", "accept"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def list_for_management_group(self, management_group_id: str, **kwargs: Any) -> AsyncItemPaged["_models.Variable"]: - """Retrieves all variables that are at this management group level. + return deserialized # type: ignore - This operation retrieves the list of all variables applicable to the management group. + @distributed_trace + def list_built_in( + self, policy_set_definition_name: str, *, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.PolicySetDefinitionVersion"]: + """This operation retrieves a list of all the built-in policy set definition versions for the + given built-in policy set definition. - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :return: An iterator like instance of Variable - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.Variable] + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :keyword top: Maximum number of records to return. When the $top filter is not provided, it + will return 500 records. Default value is None. + :paramtype top: int + :return: An iterator like instance of PolicySetDefinitionVersion + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Variable]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.PolicySetDefinitionVersion]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -9506,8 +5823,10 @@ def list_for_management_group(self, management_group_id: str, **kwargs: Any) -> def prepare_request(next_link=None): if not next_link: - _request = build_variables_list_for_management_group_request( - management_group_id=management_group_id, + _request = build_policy_set_definition_versions_list_built_in_request( + policy_set_definition_name=policy_set_definition_name, + expand=expand, + top=top, api_version=self._config.api_version, headers=_headers, params=_params, @@ -9547,7 +5866,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.Variable], + List[_models.PolicySetDefinitionVersion], deserialized.get("value", []), ) if cls: @@ -9575,44 +5894,35 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - -class VariableValuesOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.resource.policy.aio.PolicyClient`'s - :attr:`variable_values` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PolicyClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": ["api_version", "subscription_id", "variable_name", "variable_value_name", "accept"] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - async def get(self, variable_name: str, variable_value_name: str, **kwargs: Any) -> _models.VariableValue: - """Retrieves a variable value. - - This operation retrieves a single variable value; given its name, subscription it was created - at and the variable it's created for. - - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str - :return: VariableValue. The VariableValue is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + async def get_at_management_group( + self, + management_group_name: str, + policy_set_definition_name: str, + policy_definition_version: str, + *, + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.PolicySetDefinitionVersion: + """This operation retrieves the policy set definition version in the given management group with + the given name and version. + + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -9626,12 +5936,13 @@ async def get(self, variable_name: str, variable_value_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.VariableValue] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) - _request = build_variable_values_get_request( - variable_name=variable_name, - variable_value_name=variable_value_name, - subscription_id=self._config.subscription_id, + _request = build_policy_set_definition_versions_get_at_management_group_request( + management_group_name=management_group_name, + policy_set_definition_name=policy_set_definition_name, + policy_definition_version=policy_definition_version, + expand=expand, api_version=self._config.api_version, headers=_headers, params=_params, @@ -9665,7 +5976,7 @@ async def get(self, variable_name: str, variable_value_name: str, **kwargs: Any) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.VariableValue, response.json()) + deserialized = _deserialize(_models.PolicySetDefinitionVersion, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -9673,129 +5984,135 @@ async def get(self, variable_name: str, variable_value_name: str, **kwargs: Any) return deserialized # type: ignore @overload - async def create_or_update( + async def create_or_update_at_management_group( self, - variable_name: str, - variable_value_name: str, - parameters: _models.VariableValue, + management_group_name: str, + policy_set_definition_name: str, + policy_definition_version: str, + parameters: _models.PolicySetDefinitionVersion, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VariableValue: - """Creates or updates a variable value. - - This operation creates or updates a variable value with the given subscription and name for a - given variable. Variable values are scoped to the variable for which they are created for. - - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str - :param parameters: Parameters for the variable value. Required. - :type parameters: ~azure.mgmt.resource.policy.models.VariableValue + ) -> _models.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given management group + with the given name and version. + + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :param parameters: The policy set definition version properties. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: VariableValue. The VariableValue is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_or_update( + async def create_or_update_at_management_group( self, - variable_name: str, - variable_value_name: str, - parameters: _types.VariableValue, + management_group_name: str, + policy_set_definition_name: str, + policy_definition_version: str, + parameters: _types.PolicySetDefinitionVersion, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VariableValue: - """Creates or updates a variable value. - - This operation creates or updates a variable value with the given subscription and name for a - given variable. Variable values are scoped to the variable for which they are created for. - - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str - :param parameters: Parameters for the variable value. Required. - :type parameters: ~azure.mgmt.resource.policy.types.VariableValue + ) -> _models.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given management group + with the given name and version. + + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :param parameters: The policy set definition version properties. Required. + :type parameters: ~azure.mgmt.resource.policy.types.PolicySetDefinitionVersion :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: VariableValue. The VariableValue is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_or_update( + async def create_or_update_at_management_group( self, - variable_name: str, - variable_value_name: str, + management_group_name: str, + policy_set_definition_name: str, + policy_definition_version: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VariableValue: - """Creates or updates a variable value. - - This operation creates or updates a variable value with the given subscription and name for a - given variable. Variable values are scoped to the variable for which they are created for. + ) -> _models.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given management group + with the given name and version. - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str - :param parameters: Parameters for the variable value. Required. + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :param parameters: The policy set definition version properties. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: VariableValue. The VariableValue is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": [ - "api_version", - "subscription_id", - "variable_name", - "variable_value_name", - "content_type", - "accept", - ] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - async def create_or_update( + async def create_or_update_at_management_group( self, - variable_name: str, - variable_value_name: str, - parameters: Union[_models.VariableValue, _types.VariableValue, IO[bytes]], + management_group_name: str, + policy_set_definition_name: str, + policy_definition_version: str, + parameters: Union[_models.PolicySetDefinitionVersion, _types.PolicySetDefinitionVersion, IO[bytes]], **kwargs: Any - ) -> _models.VariableValue: - """Creates or updates a variable value. - - This operation creates or updates a variable value with the given subscription and name for a - given variable. Variable values are scoped to the variable for which they are created for. + ) -> _models.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given management group + with the given name and version. - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str - :param parameters: Parameters for the variable value. Is either a VariableValue type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.VariableValue or - ~azure.mgmt.resource.policy.types.VariableValue or IO[bytes] - :return: VariableValue. The VariableValue is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :param parameters: The policy set definition version properties. Is either a + PolicySetDefinitionVersion type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion or + ~azure.mgmt.resource.policy.types.PolicySetDefinitionVersion or IO[bytes] + :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -9810,7 +6127,7 @@ async def create_or_update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VariableValue] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) content_type = content_type or "application/json" _content = None @@ -9819,10 +6136,10 @@ async def create_or_update( else: _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_variable_values_create_or_update_request( - variable_name=variable_name, - variable_value_name=variable_value_name, - subscription_id=self._config.subscription_id, + _request = build_policy_set_definition_versions_create_or_update_at_management_group_request( + management_group_name=management_group_name, + policy_set_definition_name=policy_set_definition_name, + policy_definition_version=policy_definition_version, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -9858,7 +6175,7 @@ async def create_or_update( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.VariableValue, response.json()) + deserialized = _deserialize(_models.PolicySetDefinitionVersion, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -9866,24 +6183,21 @@ async def create_or_update( return deserialized # type: ignore @distributed_trace_async - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": ["api_version", "subscription_id", "variable_name", "variable_value_name"] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - async def delete(self, variable_name: str, variable_value_name: str, **kwargs: Any) -> None: - """Deletes a variable value. - - This operation deletes a variable value, given its name, the subscription it was created in, - and the variable it belongs to. The scope of a variable value is the part of its ID preceding - '/providers/Microsoft.Authorization/variables/{variableName}'. + async def delete_at_management_group( + self, management_group_name: str, policy_set_definition_name: str, policy_definition_version: str, **kwargs: Any + ) -> None: + """This operation deletes the policy set definition version in the given management group with the + given name and version. - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -9901,10 +6215,10 @@ async def delete(self, variable_name: str, variable_value_name: str, **kwargs: A cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_variable_values_delete_request( - variable_name=variable_name, - variable_value_name=variable_value_name, - subscription_id=self._config.subscription_id, + _request = build_policy_set_definition_versions_delete_at_management_group_request( + management_group_name=management_group_name, + policy_set_definition_name=policy_set_definition_name, + policy_definition_version=policy_definition_version, api_version=self._config.api_version, headers=_headers, params=_params, @@ -9933,28 +6247,39 @@ async def delete(self, variable_name: str, variable_value_name: str, **kwargs: A return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "subscription_id", "variable_name", "accept"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def list(self, variable_name: str, **kwargs: Any) -> AsyncItemPaged["_models.VariableValue"]: - """List variable values for a variable. - - This operation retrieves the list of all variable values associated with the given variable - that is at a subscription level. + def list_by_management_group( + self, + management_group_name: str, + policy_set_definition_name: str, + *, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicySetDefinitionVersion"]: + """This operation retrieves a list of all the policy set definition versions for the given policy + set definition in a given management group. - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :return: An iterator like instance of VariableValue + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :keyword top: Maximum number of records to return. When the $top filter is not provided, it + will return 500 records. Default value is None. + :paramtype top: int + :return: An iterator like instance of PolicySetDefinitionVersion :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.VariableValue] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.VariableValue]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.PolicySetDefinitionVersion]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -9967,9 +6292,11 @@ def list(self, variable_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Var def prepare_request(next_link=None): if not next_link: - _request = build_variable_values_list_request( - variable_name=variable_name, - subscription_id=self._config.subscription_id, + _request = build_policy_set_definition_versions_list_by_management_group_request( + management_group_name=management_group_name, + policy_set_definition_name=policy_set_definition_name, + expand=expand, + top=top, api_version=self._config.api_version, headers=_headers, params=_params, @@ -10009,7 +6336,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.VariableValue], + List[_models.PolicySetDefinitionVersion], deserialized.get("value", []), ) if cls: @@ -10038,35 +6365,15 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": [ - "api_version", - "management_group_id", - "variable_name", - "variable_value_name", - "accept", - ] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - async def get_at_management_group( - self, management_group_id: str, variable_name: str, variable_value_name: str, **kwargs: Any - ) -> _models.VariableValue: - """Retrieves a variable value. + async def list_all_builtins(self, **kwargs: Any) -> _models.PolicySetDefinitionVersionListResult: + """Lists all built-in policy set definition versions. - This operation retrieves a single variable value; given its name, management group it was - created at and the variable it's created for. + This operation lists all the built-in policy set definition versions for all built-in policy + set definitions. - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str - :return: VariableValue. The VariableValue is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :return: PolicySetDefinitionVersionListResult. The PolicySetDefinitionVersionListResult is + compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersionListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -10080,12 +6387,9 @@ async def get_at_management_group( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.VariableValue] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) - _request = build_variable_values_get_at_management_group_request( - management_group_id=management_group_id, - variable_name=variable_name, - variable_value_name=variable_value_name, + _request = build_policy_set_definition_versions_list_all_builtins_request( api_version=self._config.api_version, headers=_headers, params=_params, @@ -10119,149 +6423,28 @@ async def get_at_management_group( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.VariableValue, response.json()) + deserialized = _deserialize(_models.PolicySetDefinitionVersionListResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - variable_value_name: str, - parameters: _models.VariableValue, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.VariableValue: - """Creates or updates a variable value. - - This operation creates or updates a variable value with the given management group and name for - a given variable. Variable values are scoped to the variable for which they are created for. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str - :param parameters: Parameters for the variable value. Required. - :type parameters: ~azure.mgmt.resource.policy.models.VariableValue - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: VariableValue. The VariableValue is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.VariableValue - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - variable_value_name: str, - parameters: _types.VariableValue, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.VariableValue: - """Creates or updates a variable value. - - This operation creates or updates a variable value with the given management group and name for - a given variable. Variable values are scoped to the variable for which they are created for. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str - :param parameters: Parameters for the variable value. Required. - :type parameters: ~azure.mgmt.resource.policy.types.VariableValue - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: VariableValue. The VariableValue is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.VariableValue - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - variable_value_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.VariableValue: - """Creates or updates a variable value. - - This operation creates or updates a variable value with the given management group and name for - a given variable. Variable values are scoped to the variable for which they are created for. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str - :param parameters: Parameters for the variable value. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: VariableValue. The VariableValue is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.VariableValue - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": [ - "api_version", - "management_group_id", - "variable_name", - "variable_value_name", - "content_type", - "accept", - ] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - async def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - variable_value_name: str, - parameters: Union[_models.VariableValue, _types.VariableValue, IO[bytes]], - **kwargs: Any - ) -> _models.VariableValue: - """Creates or updates a variable value. + async def list_all_at_management_group( + self, management_group_name: str, **kwargs: Any + ) -> _models.PolicySetDefinitionVersionListResult: + """Lists all policy set definition versions at management group scope. - This operation creates or updates a variable value with the given management group and name for - a given variable. Variable values are scoped to the variable for which they are created for. + This operation lists all the policy set definition versions for all policy set definitions at + the management group scope. - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str - :param parameters: Parameters for the variable value. Is either a VariableValue type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.VariableValue or - ~azure.mgmt.resource.policy.types.VariableValue or IO[bytes] - :return: VariableValue. The VariableValue is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :return: PolicySetDefinitionVersionListResult. The PolicySetDefinitionVersionListResult is + compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersionListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -10272,26 +6455,14 @@ async def create_or_update_at_management_group( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VariableValue] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) - _request = build_variable_values_create_or_update_at_management_group_request( - management_group_id=management_group_id, - variable_name=variable_name, - variable_value_name=variable_value_name, - content_type=content_type, + _request = build_policy_set_definition_versions_list_all_at_management_group_request( + management_group_name=management_group_name, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -10308,7 +6479,7 @@ async def create_or_update_at_management_group( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: if _stream: try: await response.read() # Load the body in memory and close the socket @@ -10324,7 +6495,7 @@ async def create_or_update_at_management_group( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.VariableValue, response.json()) + deserialized = _deserialize(_models.PolicySetDefinitionVersionListResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -10332,30 +6503,15 @@ async def create_or_update_at_management_group( return deserialized # type: ignore @distributed_trace_async - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": ["api_version", "management_group_id", "variable_name", "variable_value_name"] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - async def delete_at_management_group( - self, management_group_id: str, variable_name: str, variable_value_name: str, **kwargs: Any - ) -> None: - """Deletes a variable value. + async def list_all(self, **kwargs: Any) -> _models.PolicySetDefinitionVersionListResult: + """Lists all policy set definition versions within a subscription. - This operation deletes a variable value, given its name, the management group it was created - in, and the variable it belongs to. The scope of a variable value is the part of its ID - preceding '/providers/Microsoft.Authorization/variables/{variableName}'. + This operation lists all the policy set definition versions for all policy set definitions + within a subscription. - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str - :return: None - :rtype: None + :return: PolicySetDefinitionVersionListResult. The PolicySetDefinitionVersionListResult is + compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersionListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -10369,12 +6525,10 @@ async def delete_at_management_group( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) - _request = build_variable_values_delete_at_management_group_request( - management_group_id=management_group_id, - variable_name=variable_name, - variable_value_name=variable_value_name, + _request = build_policy_set_definition_versions_list_all_request( + subscription_id=self._config.subscription_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -10384,14 +6538,20 @@ async def delete_at_management_group( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _failsafe_deserialize( _models.ErrorResponse, @@ -10399,117 +6559,15 @@ async def delete_at_management_group( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "management_group_id", "variable_name", "accept"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def list_for_management_group( - self, management_group_id: str, variable_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VariableValue"]: - """List variable values at management group level. - - This operation retrieves the list of all variable values applicable the variable indicated at - the management group scope. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :return: An iterator like instance of VariableValue - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.VariableValue] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.VariableValue]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_variable_values_list_for_management_group_request( - management_group_id=management_group_id, - variable_name=variable_name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.VariableValue], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicySetDefinitionVersionListResult, response.json()) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - return AsyncItemPaged(get_next, extract_data) + return deserialized # type: ignore class PolicyTokensOperations: # pylint: disable=docstring-missing-param diff --git a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/models/__init__.py b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/models/__init__.py index ace7a9482ff4..5de94663bf75 100644 --- a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/models/__init__.py @@ -47,14 +47,6 @@ PolicyDefinitionVersion, PolicyDefinitionVersionListResult, PolicyDefinitionVersionProperties, - PolicyEnrollment, - PolicyEnrollmentProperties, - PolicyEnrollmentUpdate, - PolicyEnrollmentUpdateProperties, - PolicyExemption, - PolicyExemptionProperties, - PolicyExemptionUpdate, - PolicyExemptionUpdateProperties, PolicyLogInfo, PolicySetDefinition, PolicySetDefinitionProperties, @@ -65,10 +57,6 @@ PolicyTokenOperation, PolicyTokenRequest, PolicyTokenResponse, - PolicyVariableColumn, - PolicyVariableProperties, - PolicyVariableValueColumnValue, - PolicyVariableValueProperties, ProxyResource, Resource, ResourceSelector, @@ -77,8 +65,6 @@ SelfServeExemptionSettings, SystemData, UserAssignedIdentitiesValue, - Variable, - VariableValue, ) from ._enums import ( # type: ignore @@ -86,12 +72,9 @@ AliasPathTokenType, AliasPatternType, AliasType, - AssignmentScopeValidation, AssignmentType, CreatedByType, EnforcementMode, - ExemptionCategory, - ExemptionManagementMode, ExternalEndpointResult, OverrideKind, ParameterType, @@ -139,14 +122,6 @@ "PolicyDefinitionVersion", "PolicyDefinitionVersionListResult", "PolicyDefinitionVersionProperties", - "PolicyEnrollment", - "PolicyEnrollmentProperties", - "PolicyEnrollmentUpdate", - "PolicyEnrollmentUpdateProperties", - "PolicyExemption", - "PolicyExemptionProperties", - "PolicyExemptionUpdate", - "PolicyExemptionUpdateProperties", "PolicyLogInfo", "PolicySetDefinition", "PolicySetDefinitionProperties", @@ -157,10 +132,6 @@ "PolicyTokenOperation", "PolicyTokenRequest", "PolicyTokenResponse", - "PolicyVariableColumn", - "PolicyVariableProperties", - "PolicyVariableValueColumnValue", - "PolicyVariableValueProperties", "ProxyResource", "Resource", "ResourceSelector", @@ -169,18 +140,13 @@ "SelfServeExemptionSettings", "SystemData", "UserAssignedIdentitiesValue", - "Variable", - "VariableValue", "AliasPathAttributes", "AliasPathTokenType", "AliasPatternType", "AliasType", - "AssignmentScopeValidation", "AssignmentType", "CreatedByType", "EnforcementMode", - "ExemptionCategory", - "ExemptionManagementMode", "ExternalEndpointResult", "OverrideKind", "ParameterType", diff --git a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/models/_enums.py b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/models/_enums.py index d82935735730..a6658bb2fc64 100644 --- a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/models/_enums.py +++ b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/models/_enums.py @@ -60,16 +60,6 @@ class AliasType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Alias value is secret.""" -class AssignmentScopeValidation(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The option to validate whether the exemption or enrollment is at or under the assignment scope.""" - - DEFAULT = "Default" - """This option will validate the exemption is at or under the assignment scope.""" - DO_NOT_VALIDATE = "DoNotValidate" - """This option will bypass the validation the exemption scope is at or under the policy assignment - scope.""" - - class AssignmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of policy assignment. Possible values are NotSpecified, System, SystemHidden, and Custom. Immutable. @@ -111,29 +101,6 @@ class EnforcementMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): of the policy enrollment resource.""" -class ExemptionCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The policy exemption category. Possible values are Waiver and Mitigated.""" - - WAIVER = "Waiver" - """This category of exemptions usually means the scope is not applicable for the policy.""" - MITIGATED = "Mitigated" - """This category of exemptions usually means the mitigation actions have been applied to the - scope.""" - - -class ExemptionManagementMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The mode indicating how the policy exemption is managed. Possible values are Admin and - UserSelfServe. - """ - - ADMIN = "Admin" - """This mode means the exemption is managed by an administrator and requires permission for the - policy exemption action.""" - USER_SELF_SERVE = "UserSelfServe" - """This mode means the exemption is managed by the user it applies to, through the self-serve - exemption settings on the policy assignment.""" - - class ExternalEndpointResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The result of the external endpoint. Possible values are Succeeded and Failed.""" @@ -237,6 +204,8 @@ class SelectorKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The selector kind to filter policies by the resource without location.""" POLICY_DEFINITION_REFERENCE_ID = "policyDefinitionReferenceId" """The selector kind to filter policies by the policy definition reference ID.""" + RESOURCE_ROLLOUT_PERCENTAGE = "resourceRolloutPercentage" + """The selector kind to filter policies by the resource rollout percentage.""" USER_PRINCIPAL_ID = "userPrincipalId" """The selector kind to filter policies by the user principal ID.""" GROUP_PRINCIPAL_ID = "groupPrincipalId" diff --git a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/models/_models.py b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/models/_models.py index 229f2b0619ec..4159f6a8e0ac 100644 --- a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/models/_models.py +++ b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/models/_models.py @@ -1914,535 +1914,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class PolicyEnrollment(ExtensionResource): # pylint: disable=docstring-keyword-should-match-keyword-only - """The policy enrollment. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.resource.policy.models.SystemData - :ivar properties: The properties of the policy enrollment. - :vartype properties: ~azure.mgmt.resource.policy.models.PolicyEnrollmentProperties - :ivar e_tag: The ETag for the policy enrollment. - :vartype e_tag: str - """ - - properties: Optional["_models.PolicyEnrollmentProperties"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The properties of the policy enrollment.""" - e_tag: Optional[str] = rest_field(name="eTag", visibility=["read", "create", "update", "delete", "query"]) - """The ETag for the policy enrollment.""" - - __flattened_items = [ - "policy_assignment_id", - "policy_assignment_instance_id", - "policy_definition_reference_ids", - "display_name", - "description", - "metadata", - "assignment_scope_validation", - "resource_selectors", - ] - - @overload - def __init__( - self, - *, - properties: Optional["_models.PolicyEnrollmentProperties"] = None, - e_tag: Optional[str] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} - super().__init__(*args, **kwargs) - for k, v in _flattened_input.items(): - setattr(self, k, v) - - def __getattr__(self, name: str) -> Any: - if name in self.__flattened_items: - if self.properties is None: - return None - return getattr(self.properties, name) - raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - - def __setattr__(self, key: str, value: Any) -> None: - if key in self.__flattened_items: - if self.properties is None: - self.properties = self._attr_to_rest_field["properties"]._class_type() - setattr(self.properties, key, value) - else: - super().__setattr__(key, value) - - -class PolicyEnrollmentProperties(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """The policy enrollment properties. - - :ivar policy_assignment_id: The ID of the policy assignment that is being enrolled. Required. - :vartype policy_assignment_id: str - :ivar policy_assignment_instance_id: The policy assignment instance ID associated with this - enrollment. The value is set to the instance ID of the policy assignment the policyAssignmentId - references when the enrollment is created or updated. The format is a GUID string. - :vartype policy_assignment_instance_id: str - :ivar policy_definition_reference_ids: The policy definition reference IDs for policy - definitions in an assigned policy set definition. These IDs correspond to a subset of - ``policyDefinitions[*].policyDefinitionReferenceId`` in the policy set definition. When - specified and not empty, only the referenced policy definitions will be enrolled to. Otherwise, - the entire policy set is enrolled to. - :vartype policy_definition_reference_ids: list[str] - :ivar display_name: The display name of the policy enrollment. - :vartype display_name: str - :ivar description: The description of the policy enrollment. - :vartype description: str - :ivar metadata: The policy enrollment metadata. Metadata is an open ended object and is - typically a collection of key value pairs. - :vartype metadata: any - :ivar assignment_scope_validation: The option whether to validate the enrollment is at or under - the assignment scope. Known values are: "Default" and "DoNotValidate". - :vartype assignment_scope_validation: str or - ~azure.mgmt.resource.policy.models.AssignmentScopeValidation - :ivar resource_selectors: The resource selector list to filter policies by resource properties. - :vartype resource_selectors: list[~azure.mgmt.resource.policy.models.ResourceSelector] - """ - - policy_assignment_id: str = rest_field( - name="policyAssignmentId", visibility=["read", "create", "update", "delete", "query"] - ) - """The ID of the policy assignment that is being enrolled. Required.""" - policy_assignment_instance_id: Optional[str] = rest_field(name="policyAssignmentInstanceId", visibility=["read"]) - """The policy assignment instance ID associated with this enrollment. The value is set to the - instance ID of the policy assignment the policyAssignmentId references when the enrollment is - created or updated. The format is a GUID string.""" - policy_definition_reference_ids: Optional[list[str]] = rest_field( - name="policyDefinitionReferenceIds", visibility=["read", "create", "update", "delete", "query"] - ) - """The policy definition reference IDs for policy definitions in an assigned policy set - definition. These IDs correspond to a subset of - ``policyDefinitions[*].policyDefinitionReferenceId`` in the policy set definition. When - specified and not empty, only the referenced policy definitions will be enrolled to. Otherwise, - the entire policy set is enrolled to.""" - display_name: Optional[str] = rest_field( - name="displayName", visibility=["read", "create", "update", "delete", "query"] - ) - """The display name of the policy enrollment.""" - description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The description of the policy enrollment.""" - metadata: Optional[Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The policy enrollment metadata. Metadata is an open ended object and is typically a collection - of key value pairs.""" - assignment_scope_validation: Optional[Union[str, "_models.AssignmentScopeValidation"]] = rest_field( - name="assignmentScopeValidation", visibility=["read", "create", "update", "delete", "query"] - ) - """The option whether to validate the enrollment is at or under the assignment scope. Known values - are: \"Default\" and \"DoNotValidate\".""" - resource_selectors: Optional[list["_models.ResourceSelector"]] = rest_field( - name="resourceSelectors", visibility=["read", "create", "update", "delete", "query"] - ) - """The resource selector list to filter policies by resource properties.""" - - @overload - def __init__( - self, - *, - policy_assignment_id: str, - policy_definition_reference_ids: Optional[list[str]] = None, - display_name: Optional[str] = None, - description: Optional[str] = None, - metadata: Optional[Any] = None, - assignment_scope_validation: Optional[Union[str, "_models.AssignmentScopeValidation"]] = None, - resource_selectors: Optional[list["_models.ResourceSelector"]] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - - -class PolicyEnrollmentUpdate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """The policy enrollment for Patch request. - - :ivar properties: The policy enrollment properties for Patch request. - :vartype properties: ~azure.mgmt.resource.policy.models.PolicyEnrollmentUpdateProperties - """ - - properties: Optional["_models.PolicyEnrollmentUpdateProperties"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The policy enrollment properties for Patch request.""" - - __flattened_items = ["assignment_scope_validation", "resource_selectors"] - - @overload - def __init__( - self, - *, - properties: Optional["_models.PolicyEnrollmentUpdateProperties"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} - super().__init__(*args, **kwargs) - for k, v in _flattened_input.items(): - setattr(self, k, v) - - def __getattr__(self, name: str) -> Any: - if name in self.__flattened_items: - if self.properties is None: - return None - return getattr(self.properties, name) - raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - - def __setattr__(self, key: str, value: Any) -> None: - if key in self.__flattened_items: - if self.properties is None: - self.properties = self._attr_to_rest_field["properties"]._class_type() - setattr(self.properties, key, value) - else: - super().__setattr__(key, value) - - -class PolicyEnrollmentUpdateProperties(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """The policy enrollment properties for Patch request. - - :ivar assignment_scope_validation: The option whether to validate the enrollment is at or under - the assignment scope. Known values are: "Default" and "DoNotValidate". - :vartype assignment_scope_validation: str or - ~azure.mgmt.resource.policy.models.AssignmentScopeValidation - :ivar resource_selectors: The resource selector list to filter policies by resource properties. - :vartype resource_selectors: list[~azure.mgmt.resource.policy.models.ResourceSelector] - """ - - assignment_scope_validation: Optional[Union[str, "_models.AssignmentScopeValidation"]] = rest_field( - name="assignmentScopeValidation", visibility=["read", "create", "update", "delete", "query"] - ) - """The option whether to validate the enrollment is at or under the assignment scope. Known values - are: \"Default\" and \"DoNotValidate\".""" - resource_selectors: Optional[list["_models.ResourceSelector"]] = rest_field( - name="resourceSelectors", visibility=["read", "create", "update", "delete", "query"] - ) - """The resource selector list to filter policies by resource properties.""" - - @overload - def __init__( - self, - *, - assignment_scope_validation: Optional[Union[str, "_models.AssignmentScopeValidation"]] = None, - resource_selectors: Optional[list["_models.ResourceSelector"]] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - - -class PolicyExemption(ExtensionResource): # pylint: disable=docstring-keyword-should-match-keyword-only - """The policy exemption. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.resource.policy.models.SystemData - :ivar properties: Properties for the policy exemption. - :vartype properties: ~azure.mgmt.resource.policy.models.PolicyExemptionProperties - """ - - properties: Optional["_models.PolicyExemptionProperties"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """Properties for the policy exemption.""" - - __flattened_items = [ - "policy_assignment_id", - "policy_definition_reference_ids", - "exemption_category", - "expires_on", - "display_name", - "description", - "metadata", - "resource_selectors", - "assignment_scope_validation", - "exemption_management_mode", - ] - - @overload - def __init__( - self, - *, - properties: Optional["_models.PolicyExemptionProperties"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} - super().__init__(*args, **kwargs) - for k, v in _flattened_input.items(): - setattr(self, k, v) - - def __getattr__(self, name: str) -> Any: - if name in self.__flattened_items: - if self.properties is None: - return None - return getattr(self.properties, name) - raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - - def __setattr__(self, key: str, value: Any) -> None: - if key in self.__flattened_items: - if self.properties is None: - self.properties = self._attr_to_rest_field["properties"]._class_type() - setattr(self.properties, key, value) - else: - super().__setattr__(key, value) - - -class PolicyExemptionProperties(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """The policy exemption properties. - - :ivar policy_assignment_id: The ID of the policy assignment that is being exempted. Required. - :vartype policy_assignment_id: str - :ivar policy_definition_reference_ids: The policy definition reference ID list when the - associated policy assignment is an assignment of a policy set definition. - :vartype policy_definition_reference_ids: list[str] - :ivar exemption_category: The policy exemption category. Possible values are Waiver and - Mitigated. Required. Known values are: "Waiver" and "Mitigated". - :vartype exemption_category: str or ~azure.mgmt.resource.policy.models.ExemptionCategory - :ivar expires_on: The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) of - the policy exemption. - :vartype expires_on: ~datetime.datetime - :ivar display_name: The display name of the policy exemption. - :vartype display_name: str - :ivar description: The description of the policy exemption. - :vartype description: str - :ivar metadata: The policy exemption metadata. Metadata is an open ended object and is - typically a collection of key value pairs. - :vartype metadata: any - :ivar resource_selectors: The resource selector list to filter policies by resource properties. - :vartype resource_selectors: list[~azure.mgmt.resource.policy.models.ResourceSelector] - :ivar assignment_scope_validation: The option whether validate the exemption is at or under the - assignment scope. Known values are: "Default" and "DoNotValidate". - :vartype assignment_scope_validation: str or - ~azure.mgmt.resource.policy.models.AssignmentScopeValidation - :ivar exemption_management_mode: The mode indicating how the policy exemption is managed. Known - values are: "Admin" and "UserSelfServe". - :vartype exemption_management_mode: str or - ~azure.mgmt.resource.policy.models.ExemptionManagementMode - """ - - policy_assignment_id: str = rest_field( - name="policyAssignmentId", visibility=["read", "create", "update", "delete", "query"] - ) - """The ID of the policy assignment that is being exempted. Required.""" - policy_definition_reference_ids: Optional[list[str]] = rest_field( - name="policyDefinitionReferenceIds", visibility=["read", "create", "update", "delete", "query"] - ) - """The policy definition reference ID list when the associated policy assignment is an assignment - of a policy set definition.""" - exemption_category: Union[str, "_models.ExemptionCategory"] = rest_field( - name="exemptionCategory", visibility=["read", "create", "update", "delete", "query"] - ) - """The policy exemption category. Possible values are Waiver and Mitigated. Required. Known values - are: \"Waiver\" and \"Mitigated\".""" - expires_on: Optional[datetime.datetime] = rest_field( - name="expiresOn", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) - """The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) of the policy - exemption.""" - display_name: Optional[str] = rest_field( - name="displayName", visibility=["read", "create", "update", "delete", "query"] - ) - """The display name of the policy exemption.""" - description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The description of the policy exemption.""" - metadata: Optional[Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The policy exemption metadata. Metadata is an open ended object and is typically a collection - of key value pairs.""" - resource_selectors: Optional[list["_models.ResourceSelector"]] = rest_field( - name="resourceSelectors", visibility=["read", "create", "update", "delete", "query"] - ) - """The resource selector list to filter policies by resource properties.""" - assignment_scope_validation: Optional[Union[str, "_models.AssignmentScopeValidation"]] = rest_field( - name="assignmentScopeValidation", visibility=["read", "create", "update", "delete", "query"] - ) - """The option whether validate the exemption is at or under the assignment scope. Known values - are: \"Default\" and \"DoNotValidate\".""" - exemption_management_mode: Optional[Union[str, "_models.ExemptionManagementMode"]] = rest_field( - name="exemptionManagementMode", visibility=["read", "create", "update", "delete", "query"] - ) - """The mode indicating how the policy exemption is managed. Known values are: \"Admin\" and - \"UserSelfServe\".""" - - @overload - def __init__( - self, - *, - policy_assignment_id: str, - exemption_category: Union[str, "_models.ExemptionCategory"], - policy_definition_reference_ids: Optional[list[str]] = None, - expires_on: Optional[datetime.datetime] = None, - display_name: Optional[str] = None, - description: Optional[str] = None, - metadata: Optional[Any] = None, - resource_selectors: Optional[list["_models.ResourceSelector"]] = None, - assignment_scope_validation: Optional[Union[str, "_models.AssignmentScopeValidation"]] = None, - exemption_management_mode: Optional[Union[str, "_models.ExemptionManagementMode"]] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - - -class PolicyExemptionUpdate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """The policy exemption for Patch request. - - :ivar properties: The policy exemption properties for Patch request. - :vartype properties: ~azure.mgmt.resource.policy.models.PolicyExemptionUpdateProperties - """ - - properties: Optional["_models.PolicyExemptionUpdateProperties"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The policy exemption properties for Patch request.""" - - __flattened_items = ["resource_selectors", "assignment_scope_validation", "exemption_management_mode"] - - @overload - def __init__( - self, - *, - properties: Optional["_models.PolicyExemptionUpdateProperties"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} - super().__init__(*args, **kwargs) - for k, v in _flattened_input.items(): - setattr(self, k, v) - - def __getattr__(self, name: str) -> Any: - if name in self.__flattened_items: - if self.properties is None: - return None - return getattr(self.properties, name) - raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - - def __setattr__(self, key: str, value: Any) -> None: - if key in self.__flattened_items: - if self.properties is None: - self.properties = self._attr_to_rest_field["properties"]._class_type() - setattr(self.properties, key, value) - else: - super().__setattr__(key, value) - - -class PolicyExemptionUpdateProperties(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """The policy exemption properties for Patch request. - - :ivar resource_selectors: The resource selector list to filter policies by resource properties. - :vartype resource_selectors: list[~azure.mgmt.resource.policy.models.ResourceSelector] - :ivar assignment_scope_validation: The option whether validate the exemption is at or under the - assignment scope. Known values are: "Default" and "DoNotValidate". - :vartype assignment_scope_validation: str or - ~azure.mgmt.resource.policy.models.AssignmentScopeValidation - :ivar exemption_management_mode: The mode indicating how the policy exemption is managed. Known - values are: "Admin" and "UserSelfServe". - :vartype exemption_management_mode: str or - ~azure.mgmt.resource.policy.models.ExemptionManagementMode - """ - - resource_selectors: Optional[list["_models.ResourceSelector"]] = rest_field( - name="resourceSelectors", visibility=["read", "create", "update", "delete", "query"] - ) - """The resource selector list to filter policies by resource properties.""" - assignment_scope_validation: Optional[Union[str, "_models.AssignmentScopeValidation"]] = rest_field( - name="assignmentScopeValidation", visibility=["read", "create", "update", "delete", "query"] - ) - """The option whether validate the exemption is at or under the assignment scope. Known values - are: \"Default\" and \"DoNotValidate\".""" - exemption_management_mode: Optional[Union[str, "_models.ExemptionManagementMode"]] = rest_field( - name="exemptionManagementMode", visibility=["read", "create", "update", "delete", "query"] - ) - """The mode indicating how the policy exemption is managed. Known values are: \"Admin\" and - \"UserSelfServe\".""" - - @overload - def __init__( - self, - *, - resource_selectors: Optional[list["_models.ResourceSelector"]] = None, - assignment_scope_validation: Optional[Union[str, "_models.AssignmentScopeValidation"]] = None, - exemption_management_mode: Optional[Union[str, "_models.ExemptionManagementMode"]] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - - class PolicyLogInfo(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """The policy log info. @@ -3116,130 +2587,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class PolicyVariableColumn(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """The variable column. - - :ivar column_name: The name of this policy variable column. Required. - :vartype column_name: str - """ - - column_name: str = rest_field(name="columnName", visibility=["read", "create", "update", "delete", "query"]) - """The name of this policy variable column. Required.""" - - @overload - def __init__( - self, - *, - column_name: str, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - - -class PolicyVariableProperties(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """The variable properties. - - :ivar columns: Variable column definitions. Required. - :vartype columns: list[~azure.mgmt.resource.policy.models.PolicyVariableColumn] - """ - - columns: list["_models.PolicyVariableColumn"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """Variable column definitions. Required.""" - - @overload - def __init__( - self, - *, - columns: list["_models.PolicyVariableColumn"], - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - - -class PolicyVariableValueColumnValue(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """The name value tuple for this variable value column. - - :ivar column_name: Column name for the variable value. Required. - :vartype column_name: str - :ivar column_value: Column value for the variable value; this can be an integer, double, - boolean, null or a string. Required. - :vartype column_value: any - """ - - column_name: str = rest_field(name="columnName", visibility=["read", "create", "update", "delete", "query"]) - """Column name for the variable value. Required.""" - column_value: Any = rest_field(name="columnValue", visibility=["read", "create", "update", "delete", "query"]) - """Column value for the variable value; this can be an integer, double, boolean, null or a string. - Required.""" - - @overload - def __init__( - self, - *, - column_name: str, - column_value: Any, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - - -class PolicyVariableValueProperties(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """The variable value properties. - - :ivar values_property: Variable value column value array. Required. - :vartype values_property: - list[~azure.mgmt.resource.policy.models.PolicyVariableValueColumnValue] - """ - - values_property: list["_models.PolicyVariableValueColumnValue"] = rest_field( - name="values", visibility=["read", "create", "update", "delete", "query"], original_tsp_name="values" - ) - """Variable value column value array. Required.""" - - @overload - def __init__( - self, - *, - values_property: list["_models.PolicyVariableValueColumnValue"], - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - - class ResourceSelector(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """The resource selector to filter policies by resource properties. @@ -3314,25 +2661,29 @@ class Selector(_Model): # pylint: disable=docstring-keyword-should-match-keywor """The selector expression. :ivar kind: The selector kind. Known values are: "resourceLocation", "resourceType", - "resourceWithoutLocation", "policyDefinitionReferenceId", "userPrincipalId", and - "groupPrincipalId". + "resourceWithoutLocation", "policyDefinitionReferenceId", "resourceRolloutPercentage", + "userPrincipalId", and "groupPrincipalId". :vartype kind: str or ~azure.mgmt.resource.policy.models.SelectorKind :ivar in_property: The list of values to filter in. :vartype in_property: list[str] :ivar not_in: The list of values to filter out. :vartype not_in: list[str] + :ivar progress: The percent of total resources that will be governed by the policy. + :vartype progress: int """ kind: Optional[Union[str, "_models.SelectorKind"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) """The selector kind. Known values are: \"resourceLocation\", \"resourceType\", - \"resourceWithoutLocation\", \"policyDefinitionReferenceId\", \"userPrincipalId\", and - \"groupPrincipalId\".""" + \"resourceWithoutLocation\", \"policyDefinitionReferenceId\", \"resourceRolloutPercentage\", + \"userPrincipalId\", and \"groupPrincipalId\".""" in_property: Optional[list[str]] = rest_field(name="in", visibility=["read", "create", "update", "delete", "query"]) """The list of values to filter in.""" not_in: Optional[list[str]] = rest_field(name="notIn", visibility=["read", "create", "update", "delete", "query"]) """The list of values to filter out.""" + progress: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The percent of total resources that will be governed by the policy.""" @overload def __init__( @@ -3341,6 +2692,7 @@ def __init__( kind: Optional[Union[str, "_models.SelectorKind"]] = None, in_property: Optional[list[str]] = None, not_in: Optional[list[str]] = None, + progress: Optional[int] = None, ) -> None: ... @overload @@ -3470,125 +2822,3 @@ class UserAssignedIdentitiesValue(_Model): """The principal id of user assigned identity.""" client_id: Optional[str] = rest_field(name="clientId", visibility=["read"]) """The client id of user assigned identity.""" - - -class Variable(ProxyResource): # pylint: disable=docstring-keyword-should-match-keyword-only - """The variable. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.resource.policy.models.SystemData - :ivar properties: Properties for the variable. - :vartype properties: ~azure.mgmt.resource.policy.models.PolicyVariableProperties - """ - - properties: Optional["_models.PolicyVariableProperties"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """Properties for the variable.""" - - __flattened_items = ["columns"] - - @overload - def __init__( - self, - *, - properties: Optional["_models.PolicyVariableProperties"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} - super().__init__(*args, **kwargs) - for k, v in _flattened_input.items(): - setattr(self, k, v) - - def __getattr__(self, name: str) -> Any: - if name in self.__flattened_items: - if self.properties is None: - return None - return getattr(self.properties, name) - raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - - def __setattr__(self, key: str, value: Any) -> None: - if key in self.__flattened_items: - if self.properties is None: - self.properties = self._attr_to_rest_field["properties"]._class_type() - setattr(self.properties, key, value) - else: - super().__setattr__(key, value) - - -class VariableValue(ProxyResource): # pylint: disable=docstring-keyword-should-match-keyword-only - """The variable value. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.resource.policy.models.SystemData - :ivar properties: Properties for the variable value. - :vartype properties: ~azure.mgmt.resource.policy.models.PolicyVariableValueProperties - """ - - properties: Optional["_models.PolicyVariableValueProperties"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """Properties for the variable value.""" - - __flattened_items = ["values_property"] - - @overload - def __init__( - self, - *, - properties: Optional["_models.PolicyVariableValueProperties"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} - super().__init__(*args, **kwargs) - for k, v in _flattened_input.items(): - setattr(self, k, v) - - def __getattr__(self, name: str) -> Any: - if name in self.__flattened_items: - if self.properties is None: - return None - return getattr(self.properties, name) - raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - - def __setattr__(self, key: str, value: Any) -> None: - if key in self.__flattened_items: - if self.properties is None: - self.properties = self._attr_to_rest_field["properties"]._class_type() - setattr(self.properties, key, value) - else: - super().__setattr__(key, value) diff --git a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/operations/__init__.py b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/operations/__init__.py index 1f69bf806caf..487a10db1153 100644 --- a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/operations/__init__.py @@ -16,12 +16,8 @@ from ._operations import DataPolicyManifestsOperations # type: ignore from ._operations import PolicyDefinitionsOperations # type: ignore from ._operations import PolicyDefinitionVersionsOperations # type: ignore -from ._operations import PolicyEnrollmentsOperations # type: ignore -from ._operations import PolicyExemptionsOperations # type: ignore from ._operations import PolicySetDefinitionsOperations # type: ignore from ._operations import PolicySetDefinitionVersionsOperations # type: ignore -from ._operations import VariablesOperations # type: ignore -from ._operations import VariableValuesOperations # type: ignore from ._operations import PolicyTokensOperations # type: ignore from ._patch import __all__ as _patch_all @@ -33,12 +29,8 @@ "DataPolicyManifestsOperations", "PolicyDefinitionsOperations", "PolicyDefinitionVersionsOperations", - "PolicyEnrollmentsOperations", - "PolicyExemptionsOperations", "PolicySetDefinitionsOperations", "PolicySetDefinitionVersionsOperations", - "VariablesOperations", - "VariableValuesOperations", "PolicyTokensOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore diff --git a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/operations/_operations.py b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/operations/_operations.py index c51cab8ec58b..3eedd08da370 100644 --- a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/operations/_operations.py @@ -50,7 +50,7 @@ def build_policy_assignments_get_by_id_request( # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -77,7 +77,7 @@ def build_policy_assignments_create_by_id_request( # pylint: disable=name-too-l _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -106,7 +106,7 @@ def build_policy_assignments_update_by_id_request( # pylint: disable=name-too-l _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -134,7 +134,7 @@ def build_policy_assignments_delete_by_id_request( # pylint: disable=name-too-l _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -160,7 +160,7 @@ def build_policy_assignments_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -188,7 +188,7 @@ def build_policy_assignments_create_request(scope: str, policy_assignment_name: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -216,7 +216,7 @@ def build_policy_assignments_update_request(scope: str, policy_assignment_name: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -243,7 +243,7 @@ def build_policy_assignments_delete_request(scope: str, policy_assignment_name: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -276,7 +276,7 @@ def build_policy_assignments_list_for_resource_group_request( # pylint: disable _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -314,7 +314,7 @@ def build_policy_assignments_list_for_management_group_request( # pylint: disab _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -351,7 +351,7 @@ def build_policy_assignments_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -393,7 +393,7 @@ def build_policy_assignments_list_for_resource_request( # pylint: disable=name- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -430,7 +430,7 @@ def build_data_policy_manifests_get_by_policy_mode_request( # pylint: disable=n _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -454,7 +454,7 @@ def build_data_policy_manifests_list_request(*, filter: Optional[str] = None, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -477,7 +477,7 @@ def build_policy_definitions_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -505,7 +505,7 @@ def build_policy_definitions_create_or_update_request( # pylint: disable=name-t _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -533,7 +533,7 @@ def build_policy_definitions_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) # Construct URL _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}" path_format_arguments = { @@ -555,7 +555,7 @@ def build_policy_definitions_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -585,7 +585,7 @@ def build_policy_definitions_get_built_in_request( # pylint: disable=name-too-l _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -611,7 +611,7 @@ def build_policy_definitions_list_built_in_request( # pylint: disable=name-too- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -636,7 +636,7 @@ def build_policy_definitions_get_at_management_group_request( # pylint: disable _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -664,7 +664,7 @@ def build_policy_definitions_create_or_update_at_management_group_request( # py _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -692,7 +692,7 @@ def build_policy_definitions_delete_at_management_group_request( # pylint: disa ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) # Construct URL _url = "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}" path_format_arguments = { @@ -714,7 +714,7 @@ def build_policy_definitions_list_by_management_group_request( # pylint: disabl _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -744,7 +744,7 @@ def build_policy_definition_versions_get_request( # pylint: disable=name-too-lo _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -773,7 +773,7 @@ def build_policy_definition_versions_create_or_update_request( # pylint: disabl _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -802,7 +802,7 @@ def build_policy_definition_versions_delete_request( # pylint: disable=name-too ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) # Construct URL _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}" path_format_arguments = { @@ -825,7 +825,7 @@ def build_policy_definition_versions_list_request( # pylint: disable=name-too-l _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -854,7 +854,7 @@ def build_policy_definition_versions_get_built_in_request( # pylint: disable=na _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -883,7 +883,7 @@ def build_policy_definition_versions_list_built_in_request( # pylint: disable=n _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -911,7 +911,7 @@ def build_policy_definition_versions_get_at_management_group_request( # pylint: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -940,7 +940,7 @@ def build_policy_definition_versions_create_or_update_at_management_group_reques _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -969,7 +969,7 @@ def build_policy_definition_versions_delete_at_management_group_request( # pyli ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) # Construct URL _url = "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}" path_format_arguments = { @@ -992,7 +992,7 @@ def build_policy_definition_versions_list_by_management_group_request( # pylint _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1021,7 +1021,7 @@ def build_policy_definition_versions_list_all_builtins_request( # pylint: disab _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1042,7 +1042,7 @@ def build_policy_definition_versions_list_all_at_management_group_request( # py _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1068,7 +1068,7 @@ def build_policy_definition_versions_list_all_request( # pylint: disable=name-t _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1088,24 +1088,28 @@ def build_policy_definition_versions_list_all_request( # pylint: disable=name-t return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_enrollments_get_request(scope: str, policy_enrollment_name: str, **kwargs: Any) -> HttpRequest: +def build_policy_set_definitions_get_request( + policy_set_definition_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/{scope}/providers/Microsoft.Authorization/policyEnrollments/{policyEnrollmentName}" + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "policyEnrollmentName": _SERIALIZER.url("policy_enrollment_name", policy_enrollment_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1113,21 +1117,21 @@ def build_policy_enrollments_get_request(scope: str, policy_enrollment_name: str return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_enrollments_create_or_update_request( # pylint: disable=name-too-long - scope: str, policy_enrollment_name: str, **kwargs: Any +def build_policy_set_definitions_create_or_update_request( # pylint: disable=name-too-long + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/{scope}/providers/Microsoft.Authorization/policyEnrollments/{policyEnrollmentName}" + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "policyEnrollmentName": _SERIALIZER.url("policy_enrollment_name", policy_enrollment_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1143,43 +1147,17 @@ def build_policy_enrollments_create_or_update_request( # pylint: disable=name-t return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_enrollments_update_request(scope: str, policy_enrollment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/{scope}/providers/Microsoft.Authorization/policyEnrollments/{policyEnrollmentName}" - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "policyEnrollmentName": _SERIALIZER.url("policy_enrollment_name", policy_enrollment_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_policy_enrollments_delete_request(scope: str, policy_enrollment_name: str, **kwargs: Any) -> HttpRequest: +def build_policy_set_definitions_delete_request( # pylint: disable=name-too-long + policy_set_definition_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) # Construct URL - _url = "/{scope}/providers/Microsoft.Authorization/policyEnrollments/{policyEnrollmentName}" + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "policyEnrollmentName": _SERIALIZER.url("policy_enrollment_name", policy_enrollment_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1190,20 +1168,24 @@ def build_policy_enrollments_delete_request(scope: str, policy_enrollment_name: return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_policy_enrollments_list_for_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +def build_policy_set_definitions_list_request( # pylint: disable=name-too-long + subscription_id: str, + *, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any, ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyEnrollments" + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1212,6 +1194,10 @@ def build_policy_enrollments_list_for_resource_group_request( # pylint: disable _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1219,27 +1205,27 @@ def build_policy_enrollments_list_for_resource_group_request( # pylint: disable return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_enrollments_list_for_management_group_request( # pylint: disable=name-too-long - management_group_id: str, *, filter: Optional[str] = None, **kwargs: Any +def build_policy_set_definitions_get_built_in_request( # pylint: disable=name-too-long + policy_set_definition_name: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyEnrollments" + _url = "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1247,27 +1233,26 @@ def build_policy_enrollments_list_for_management_group_request( # pylint: disab return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_enrollments_list_request( - subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +def build_policy_set_definitions_list_built_in_request( # pylint: disable=name-too-long + *, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyEnrollments" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/providers/Microsoft.Authorization/policySetDefinitions" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1275,40 +1260,28 @@ def build_policy_enrollments_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_enrollments_list_for_resource_request( # pylint: disable=name-too-long - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any, +def build_policy_set_definitions_get_at_management_group_request( # pylint: disable=name-too-long + management_group_id: str, policy_set_definition_name: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyEnrollments" + _url = "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1316,18 +1289,21 @@ def build_policy_enrollments_list_for_resource_request( # pylint: disable=name- return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_exemptions_get_request(scope: str, policy_exemption_name: str, **kwargs: Any) -> HttpRequest: +def build_policy_set_definitions_create_or_update_at_management_group_request( # pylint: disable=name-too-long + management_group_id: str, policy_set_definition_name: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" + _url = "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1336,26 +1312,24 @@ def build_policy_exemptions_get_request(scope: str, policy_exemption_name: str, _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_exemptions_create_or_update_request( # pylint: disable=name-too-long - scope: str, policy_exemption_name: str, **kwargs: Any +def build_policy_set_definitions_delete_at_management_group_request( # pylint: disable=name-too-long + management_group_id: str, policy_set_definition_name: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) # Construct URL - _url = "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" + _url = "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1363,83 +1337,74 @@ def build_policy_exemptions_create_or_update_request( # pylint: disable=name-to # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_policy_exemptions_update_request(scope: str, policy_exemption_name: str, **kwargs: Any) -> HttpRequest: +def build_policy_set_definitions_list_by_management_group_request( # pylint: disable=name-too-long + management_group_id: str, + *, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any, +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" + _url = "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions" path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_policy_exemptions_delete_request(scope: str, policy_exemption_name: str, **kwargs: Any) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - # Construct URL - _url = "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_exemptions_list_for_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +def build_policy_set_definition_versions_get_request( # pylint: disable=name-too-long + policy_set_definition_name: str, + policy_definition_version: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any, ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions" + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "policyDefinitionVersion": _SERIALIZER.url("policy_definition_version", policy_definition_version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1447,96 +1412,88 @@ def build_policy_exemptions_list_for_resource_group_request( # pylint: disable= return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_exemptions_list_for_management_group_request( # pylint: disable=name-too-long - management_group_id: str, *, filter: Optional[str] = None, **kwargs: Any +def build_policy_set_definition_versions_create_or_update_request( # pylint: disable=name-too-long + policy_set_definition_name: str, policy_definition_version: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyExemptions" + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "policyDefinitionVersion": _SERIALIZER.url("policy_definition_version", policy_definition_version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_exemptions_list_request( - subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +def build_policy_set_definition_versions_delete_request( # pylint: disable=name-too-long + policy_set_definition_name: str, policy_definition_version: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions" + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "policyDefinitionVersion": _SERIALIZER.url("policy_definition_version", policy_definition_version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_policy_exemptions_list_for_resource_request( # pylint: disable=name-too-long - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, +def build_policy_set_definition_versions_list_request( # pylint: disable=name-too-long + policy_set_definition_name: str, subscription_id: str, *, - filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, **kwargs: Any, ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions" + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1544,20 +1501,20 @@ def build_policy_exemptions_list_for_resource_request( # pylint: disable=name-t return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_get_request( - policy_set_definition_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +def build_policy_set_definition_versions_get_built_in_request( # pylint: disable=name-too-long + policy_set_definition_name: str, policy_definition_version: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" + _url = "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "policyDefinitionVersion": _SERIALIZER.url("policy_definition_version", policy_definition_version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1573,20 +1530,18 @@ def build_policy_set_definitions_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_create_or_update_request( # pylint: disable=name-too-long - policy_set_definition_name: str, subscription_id: str, **kwargs: Any +def build_policy_set_definition_versions_list_built_in_request( # pylint: disable=name-too-long + policy_set_definition_name: str, *, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" + _url = "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions" path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), } @@ -1594,117 +1549,6 @@ def build_policy_set_definitions_create_or_update_request( # pylint: disable=na # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_policy_set_definitions_delete_request( # pylint: disable=name-too-long - policy_set_definition_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_policy_set_definitions_list_request( # pylint: disable=name-too-long - subscription_id: str, - *, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any, -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_policy_set_definitions_get_built_in_request( # pylint: disable=name-too-long - policy_set_definition_name: str, *, expand: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" - path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_policy_set_definitions_list_built_in_request( # pylint: disable=name-too-long - *, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/providers/Microsoft.Authorization/policySetDefinitions" - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: @@ -1716,20 +1560,26 @@ def build_policy_set_definitions_list_built_in_request( # pylint: disable=name- return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_get_at_management_group_request( # pylint: disable=name-too-long - management_group_id: str, policy_set_definition_name: str, *, expand: Optional[str] = None, **kwargs: Any +def build_policy_set_definition_versions_get_at_management_group_request( # pylint: disable=name-too-long + management_group_name: str, + policy_set_definition_name: str, + policy_definition_version: str, + *, + expand: Optional[str] = None, + **kwargs: Any, ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" + _url = "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "policyDefinitionVersion": _SERIALIZER.url("policy_definition_version", policy_definition_version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1745,21 +1595,22 @@ def build_policy_set_definitions_get_at_management_group_request( # pylint: dis return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_create_or_update_at_management_group_request( # pylint: disable=name-too-long - management_group_id: str, policy_set_definition_name: str, **kwargs: Any +def build_policy_set_definition_versions_create_or_update_at_management_group_request( # pylint: disable=name-too-long + management_group_name: str, policy_set_definition_name: str, policy_definition_version: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" + _url = "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "policyDefinitionVersion": _SERIALIZER.url("policy_definition_version", policy_definition_version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1775,17 +1626,18 @@ def build_policy_set_definitions_create_or_update_at_management_group_request( return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_delete_at_management_group_request( # pylint: disable=name-too-long - management_group_id: str, policy_set_definition_name: str, **kwargs: Any +def build_policy_set_definition_versions_delete_at_management_group_request( # pylint: disable=name-too-long + management_group_name: str, policy_set_definition_name: str, policy_definition_version: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) # Construct URL - _url = "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" + _url = "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "policyDefinitionVersion": _SERIALIZER.url("policy_definition_version", policy_definition_version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1796,10 +1648,10 @@ def build_policy_set_definitions_delete_at_management_group_request( # pylint: return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_policy_set_definitions_list_by_management_group_request( # pylint: disable=name-too-long - management_group_id: str, +def build_policy_set_definition_versions_list_by_management_group_request( # pylint: disable=name-too-long + management_group_name: str, + policy_set_definition_name: str, *, - filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any, @@ -1807,21 +1659,20 @@ def build_policy_set_definitions_list_by_management_group_request( # pylint: di _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions" + _url = "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions" path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: @@ -1833,57 +1684,40 @@ def build_policy_set_definitions_list_by_management_group_request( # pylint: di return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definition_versions_get_request( # pylint: disable=name-too-long - policy_set_definition_name: str, - policy_definition_version: str, - subscription_id: str, - *, - expand: Optional[str] = None, +def build_policy_set_definition_versions_list_all_builtins_request( # pylint: disable=name-too-long **kwargs: Any, ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), - "policyDefinitionVersion": _SERIALIZER.url("policy_definition_version", policy_definition_version, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/providers/Microsoft.Authorization/listPolicySetDefinitionVersions" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definition_versions_create_or_update_request( # pylint: disable=name-too-long - policy_set_definition_name: str, policy_definition_version: str, subscription_id: str, **kwargs: Any +def build_policy_set_definition_versions_list_all_at_management_group_request( # pylint: disable=name-too-long + management_group_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" + _url = "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/listPolicySetDefinitionVersions" path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), - "policyDefinitionVersion": _SERIALIZER.url("policy_definition_version", policy_definition_version, "str"), + "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1892,4252 +1726,128 @@ def build_policy_set_definition_versions_create_or_update_request( # pylint: di _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_policy_set_definition_versions_delete_request( # pylint: disable=name-too-long - policy_set_definition_name: str, policy_definition_version: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), - "policyDefinitionVersion": _SERIALIZER.url("policy_definition_version", policy_definition_version, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definition_versions_list_request( # pylint: disable=name-too-long - policy_set_definition_name: str, - subscription_id: str, - *, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any, +def build_policy_set_definition_versions_list_all_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions" + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/listPolicySetDefinitionVersions" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definition_versions_get_built_in_request( # pylint: disable=name-too-long - policy_set_definition_name: str, policy_definition_version: str, *, expand: Optional[str] = None, **kwargs: Any -) -> HttpRequest: +def build_policy_tokens_acquire_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/acquirePolicyToken" path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), - "policyDefinitionVersion": _SERIALIZER.url("policy_definition_version", policy_definition_version, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definition_versions_list_built_in_request( # pylint: disable=name-too-long - policy_set_definition_name: str, *, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any +def build_policy_tokens_acquire_at_management_group_request( # pylint: disable=name-too-long + management_group_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions" + _url = "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/acquirePolicyToken" path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definition_versions_get_at_management_group_request( # pylint: disable=name-too-long - management_group_name: str, - policy_set_definition_name: str, - policy_definition_version: str, - *, - expand: Optional[str] = None, - **kwargs: Any, -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" - path_format_arguments = { - "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), - "policyDefinitionVersion": _SERIALIZER.url("policy_definition_version", policy_definition_version, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_policy_set_definition_versions_create_or_update_at_management_group_request( # pylint: disable=name-too-long - management_group_name: str, policy_set_definition_name: str, policy_definition_version: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" - path_format_arguments = { - "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), - "policyDefinitionVersion": _SERIALIZER.url("policy_definition_version", policy_definition_version, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_policy_set_definition_versions_delete_at_management_group_request( # pylint: disable=name-too-long - management_group_name: str, policy_set_definition_name: str, policy_definition_version: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - # Construct URL - _url = "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" - path_format_arguments = { - "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), - "policyDefinitionVersion": _SERIALIZER.url("policy_definition_version", policy_definition_version, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_policy_set_definition_versions_list_by_management_group_request( # pylint: disable=name-too-long - management_group_name: str, - policy_set_definition_name: str, - *, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any, -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions" - path_format_arguments = { - "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_policy_set_definition_versions_list_all_builtins_request( # pylint: disable=name-too-long - **kwargs: Any, -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/providers/Microsoft.Authorization/listPolicySetDefinitionVersions" - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_policy_set_definition_versions_list_all_at_management_group_request( # pylint: disable=name-too-long - management_group_name: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/listPolicySetDefinitionVersions" - path_format_arguments = { - "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_policy_set_definition_versions_list_all_request( # pylint: disable=name-too-long - subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/listPolicySetDefinitionVersions" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_variables_get_request(variable_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_variables_create_or_update_request(variable_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_variables_delete_request(variable_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_variables_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_variables_get_at_management_group_request( # pylint: disable=name-too-long - management_group_id: str, variable_name: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}" - path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_variables_create_or_update_at_management_group_request( # pylint: disable=name-too-long - management_group_id: str, variable_name: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}" - path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_variables_delete_at_management_group_request( # pylint: disable=name-too-long - management_group_id: str, variable_name: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - # Construct URL - _url = "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}" - path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_variables_list_for_management_group_request( # pylint: disable=name-too-long - management_group_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables" - path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_variable_values_get_request( - variable_name: str, variable_value_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), - "variableValueName": _SERIALIZER.url("variable_value_name", variable_value_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_variable_values_create_or_update_request( # pylint: disable=name-too-long - variable_name: str, variable_value_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), - "variableValueName": _SERIALIZER.url("variable_value_name", variable_value_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_variable_values_delete_request( - variable_name: str, variable_value_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), - "variableValueName": _SERIALIZER.url("variable_value_name", variable_value_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_variable_values_list_request(variable_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_variable_values_get_at_management_group_request( # pylint: disable=name-too-long - management_group_id: str, variable_name: str, variable_value_name: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), - "variableValueName": _SERIALIZER.url("variable_value_name", variable_value_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_variable_values_create_or_update_at_management_group_request( # pylint: disable=name-too-long - management_group_id: str, variable_name: str, variable_value_name: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), - "variableValueName": _SERIALIZER.url("variable_value_name", variable_value_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_variable_values_delete_at_management_group_request( # pylint: disable=name-too-long - management_group_id: str, variable_name: str, variable_value_name: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - # Construct URL - _url = "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), - "variableValueName": _SERIALIZER.url("variable_value_name", variable_value_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_variable_values_list_for_management_group_request( # pylint: disable=name-too-long - management_group_id: str, variable_name: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values" - path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_policy_tokens_acquire_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/acquirePolicyToken" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_policy_tokens_acquire_at_management_group_request( # pylint: disable=name-too-long - management_group_name: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/acquirePolicyToken" - path_format_arguments = { - "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class PolicyAssignmentsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.resource.policy.PolicyClient`'s - :attr:`policy_assignments` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PolicyClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: - """Retrieves the policy assignment with the given ID. - - The operation retrieves the policy assignment with the given ID. Policy assignment IDs have - this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid - scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - - :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. - :type policy_assignment_id: str - :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) - - _request = build_policy_assignments_get_by_id_request( - policy_assignment_id=policy_assignment_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicyAssignment, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_by_id( - self, - policy_assignment_id: str, - parameters: _models.PolicyAssignment, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyAssignment: - """Creates or updates a policy assignment. - - This operation creates or updates the policy assignment with the given ID. Policy assignments - made on a scope apply to all resources contained in that scope. For example, when you assign a - policy to a resource group that policy applies to all resources in the group. Policy assignment - IDs have this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid - scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - - :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. - :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyAssignment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_by_id( - self, - policy_assignment_id: str, - parameters: _types.PolicyAssignment, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyAssignment: - """Creates or updates a policy assignment. - - This operation creates or updates the policy assignment with the given ID. Policy assignments - made on a scope apply to all resources contained in that scope. For example, when you assign a - policy to a resource group that policy applies to all resources in the group. Policy assignment - IDs have this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid - scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - - :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. - :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicyAssignment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_by_id( - self, policy_assignment_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.PolicyAssignment: - """Creates or updates a policy assignment. - - This operation creates or updates the policy assignment with the given ID. Policy assignments - made on a scope apply to all resources contained in that scope. For example, when you assign a - policy to a resource group that policy applies to all resources in the group. Policy assignment - IDs have this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid - scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - - :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. - :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_by_id( - self, - policy_assignment_id: str, - parameters: Union[_models.PolicyAssignment, _types.PolicyAssignment, IO[bytes]], - **kwargs: Any, - ) -> _models.PolicyAssignment: - """Creates or updates a policy assignment. - - This operation creates or updates the policy assignment with the given ID. Policy assignments - made on a scope apply to all resources contained in that scope. For example, when you assign a - policy to a resource group that policy applies to all resources in the group. Policy assignment - IDs have this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid - scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - - :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. - :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. Is either a PolicyAssignment type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyAssignment or - ~azure.mgmt.resource.policy.types.PolicyAssignment or IO[bytes] - :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_policy_assignments_create_by_id_request( - policy_assignment_id=policy_assignment_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicyAssignment, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update_by_id( - self, - policy_assignment_id: str, - parameters: _models.PolicyAssignmentUpdate, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyAssignment: - """Updates a policy assignment. - - This operation updates the policy assignment with the given ID. Policy assignments made on a - scope apply to all resources contained in that scope. For example, when you assign a policy to - a resource group that policy applies to all resources in the group. Policy assignment IDs have - this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid - scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - - :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. - :type policy_assignment_id: str - :param parameters: Parameters for policy assignment patch request. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyAssignmentUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update_by_id( - self, - policy_assignment_id: str, - parameters: _types.PolicyAssignmentUpdate, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyAssignment: - """Updates a policy assignment. - - This operation updates the policy assignment with the given ID. Policy assignments made on a - scope apply to all resources contained in that scope. For example, when you assign a policy to - a resource group that policy applies to all resources in the group. Policy assignment IDs have - this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid - scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - - :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. - :type policy_assignment_id: str - :param parameters: Parameters for policy assignment patch request. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicyAssignmentUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update_by_id( - self, policy_assignment_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.PolicyAssignment: - """Updates a policy assignment. - - This operation updates the policy assignment with the given ID. Policy assignments made on a - scope apply to all resources contained in that scope. For example, when you assign a policy to - a resource group that policy applies to all resources in the group. Policy assignment IDs have - this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid - scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - - :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. - :type policy_assignment_id: str - :param parameters: Parameters for policy assignment patch request. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update_by_id( - self, - policy_assignment_id: str, - parameters: Union[_models.PolicyAssignmentUpdate, _types.PolicyAssignmentUpdate, IO[bytes]], - **kwargs: Any, - ) -> _models.PolicyAssignment: - """Updates a policy assignment. - - This operation updates the policy assignment with the given ID. Policy assignments made on a - scope apply to all resources contained in that scope. For example, when you assign a policy to - a resource group that policy applies to all resources in the group. Policy assignment IDs have - this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid - scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - - :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. - :type policy_assignment_id: str - :param parameters: Parameters for policy assignment patch request. Is either a - PolicyAssignmentUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyAssignmentUpdate or - ~azure.mgmt.resource.policy.types.PolicyAssignmentUpdate or IO[bytes] - :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_policy_assignments_update_by_id_request( - policy_assignment_id=policy_assignment_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicyAssignment, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: - """Deletes a policy assignment. - - This operation deletes the policy with the given ID. Policy assignment IDs have this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid - formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' - (management group), '/subscriptions/{subscriptionId}' (subscription), - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' - (resource). - - :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. - :type policy_assignment_id: str - :return: PolicyAssignment or None. The PolicyAssignment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[Optional[_models.PolicyAssignment]] = kwargs.pop("cls", None) - - _request = build_policy_assignments_delete_by_id_request( - policy_assignment_id=policy_assignment_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicyAssignment, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get( - self, scope: str, policy_assignment_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> _models.PolicyAssignment: - """This operation retrieves a single policy assignment, given its name and the scope it was - created at. - - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. Required. - :type policy_assignment_name: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) - - _request = build_policy_assignments_get_request( - scope=scope, - policy_assignment_name=policy_assignment_name, - expand=expand, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicyAssignment, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create( - self, - scope: str, - policy_assignment_name: str, - parameters: _models.PolicyAssignment, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyAssignment: - """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 fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. Required. - :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyAssignment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - scope: str, - policy_assignment_name: str, - parameters: _types.PolicyAssignment, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyAssignment: - """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 fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. Required. - :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicyAssignment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - scope: str, - policy_assignment_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyAssignment: - """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 fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. Required. - :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - scope: str, - policy_assignment_name: str, - parameters: Union[_models.PolicyAssignment, _types.PolicyAssignment, IO[bytes]], - **kwargs: Any, - ) -> _models.PolicyAssignment: - """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 fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. Required. - :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. Is either a PolicyAssignment type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyAssignment or - ~azure.mgmt.resource.policy.types.PolicyAssignment or IO[bytes] - :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_policy_assignments_create_request( - scope=scope, - policy_assignment_name=policy_assignment_name, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicyAssignment, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - scope: str, - policy_assignment_name: str, - parameters: _models.PolicyAssignmentUpdate, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyAssignment: - """This operation updates a policy assignment with the given scope and name. Policy assignments - apply to all resources contained within their scope. For example, when you assign a policy at - resource group scope, that policy applies to all resources in the group. - - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. Required. - :type policy_assignment_name: str - :param parameters: Parameters for policy assignment patch request. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyAssignmentUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - scope: str, - policy_assignment_name: str, - parameters: _types.PolicyAssignmentUpdate, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyAssignment: - """This operation updates a policy assignment with the given scope and name. Policy assignments - apply to all resources contained within their scope. For example, when you assign a policy at - resource group scope, that policy applies to all resources in the group. - - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. Required. - :type policy_assignment_name: str - :param parameters: Parameters for policy assignment patch request. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicyAssignmentUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - scope: str, - policy_assignment_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyAssignment: - """This operation updates a policy assignment with the given scope and name. Policy assignments - apply to all resources contained within their scope. For example, when you assign a policy at - resource group scope, that policy applies to all resources in the group. - - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. Required. - :type policy_assignment_name: str - :param parameters: Parameters for policy assignment patch request. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - scope: str, - policy_assignment_name: str, - parameters: Union[_models.PolicyAssignmentUpdate, _types.PolicyAssignmentUpdate, IO[bytes]], - **kwargs: Any, - ) -> _models.PolicyAssignment: - """This operation updates a policy assignment with the given scope and name. Policy assignments - apply to all resources contained within their scope. For example, when you assign a policy at - resource group scope, that policy applies to all resources in the group. - - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. Required. - :type policy_assignment_name: str - :param parameters: Parameters for policy assignment patch request. Is either a - PolicyAssignmentUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyAssignmentUpdate or - ~azure.mgmt.resource.policy.types.PolicyAssignmentUpdate or IO[bytes] - :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_policy_assignments_update_request( - scope=scope, - policy_assignment_name=policy_assignment_name, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicyAssignment, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: - """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 fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. Required. - :type policy_assignment_name: str - :return: PolicyAssignment or None. The PolicyAssignment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[Optional[_models.PolicyAssignment]] = kwargs.pop("cls", None) - - _request = build_policy_assignments_delete_request( - scope=scope, - policy_assignment_name=policy_assignment_name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicyAssignment, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_for_resource_group( - self, - resource_group_name: str, - *, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any, - ) -> ItemPaged["_models.PolicyAssignment"]: - """This operation retrieves the list of all policy assignments associated with the given resource - group in the given subscription that match the optional given $filter. Valid values for $filter - are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not - provided, the unfiltered list includes all policy assignments associated with the resource - group, including those that apply directly or apply from containing scopes, as well as any - applied to resources contained within the resource group. If $filter=atScope() is provided, the - returned list includes all policy assignments that apply to the resource group, which is - everything in the unfiltered list except those applied to resources contained within the - resource group. If $filter=atExactScope() is provided, the returned list only includes all - policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is - provided, the returned list includes all policy assignments of the policy definition whose id - is {value} that apply to the resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, - no filtering is performed. If $filter=atScope() is provided, the returned list only includes - all policy assignments that apply to the scope, which is everything in the unfiltered list - except those applied to sub scopes contained within the given scope. If $filter=atExactScope() - is provided, the returned list only includes all policy assignments that at the given scope. If - $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy - assignments of the policy definition whose id is {value}. Default value is None. - :paramtype filter: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :keyword top: Maximum number of records to return. When the $top filter is not provided, it - will return 500 records. Default value is None. - :paramtype top: int - :return: An iterator like instance of PolicyAssignment - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicyAssignment]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - expand=expand, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicyAssignment], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_for_management_group( - self, - management_group_id: str, - *, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any, - ) -> ItemPaged["_models.PolicyAssignment"]: - """Retrieves all policy assignments that apply to a management group. - - This operation retrieves the list of all policy assignments applicable to the management group - that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or - 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes - all policy assignments that are assigned to the management group or the management group's - ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy - assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is - provided, the returned list includes all policy assignments of the policy definition whose id - is {value} that apply to the management group. - - :param management_group_id: The management group ID. Required. - :type management_group_id: str - :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, - no filtering is performed. If $filter=atScope() is provided, the returned list only includes - all policy assignments that apply to the scope, which is everything in the unfiltered list - except those applied to sub scopes contained within the given scope. If $filter=atExactScope() - is provided, the returned list only includes all policy assignments that at the given scope. If - $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy - assignments of the policy definition whose id is {value}. Default value is None. - :paramtype filter: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :keyword top: Maximum number of records to return. When the $top filter is not provided, it - will return 500 records. Default value is None. - :paramtype top: int - :return: An iterator like instance of PolicyAssignment - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicyAssignment]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_assignments_list_for_management_group_request( - management_group_id=management_group_id, - filter=filter, - expand=expand, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicyAssignment], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list( - self, *, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.PolicyAssignment"]: - """Retrieves all policy assignments that apply to a subscription. - - This operation retrieves the list of all policy assignments associated with the given - subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', - 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the - unfiltered list includes all policy assignments associated with the subscription, including - those that apply directly or from management groups that contain the given subscription, as - well as any applied to objects contained within the subscription. If $filter=atScope() is - provided, the returned list includes all policy assignments that apply to the subscription, - which is everything in the unfiltered list except those applied to objects contained within the - subscription. If $filter=atExactScope() is provided, the returned list only includes all policy - assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, - the returned list includes all policy assignments of the policy definition whose id is {value}. - - :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, - no filtering is performed. If $filter=atScope() is provided, the returned list only includes - all policy assignments that apply to the scope, which is everything in the unfiltered list - except those applied to sub scopes contained within the given scope. If $filter=atExactScope() - is provided, the returned list only includes all policy assignments that at the given scope. If - $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy - assignments of the policy definition whose id is {value}. Default value is None. - :paramtype filter: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :keyword top: Maximum number of records to return. When the $top filter is not provided, it - will return 500 records. Default value is None. - :paramtype top: int - :return: An iterator like instance of PolicyAssignment - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicyAssignment]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - expand=expand, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicyAssignment], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - *, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any, - ) -> ItemPaged["_models.PolicyAssignment"]: - """Retrieves all policy assignments that apply to a resource. - - This operation retrieves the list of all policy assignments associated with the specified - resource in the given resource group and subscription that match the optional given $filter. - Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq - '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments - associated with the resource, including those that apply directly or from all containing - scopes, as well as any applied to resources contained within the resource. If $filter=atScope() - is provided, the returned list includes all policy assignments that apply to the resource, - which is everything in the unfiltered list except those applied to resources contained within - the resource. If $filter=atExactScope() is provided, the returned list only includes all policy - assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, - the returned list includes all policy assignments of the policy definition whose id is {value} - that apply to the resource. Three parameters plus the resource name are used to identify a - specific resource. If the resource is not part of a parent resource (the more common case), the - parent resource path should not be provided (or provided as ''). For example a web app could be - specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', - {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent - resource, then all parameters should be provided. For example a virtual machine DNS name could - be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == - 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == - 'MyComputerName'). A convenient alternative to providing the namespace and type name separately - is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', - {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == - 'MyWebApp'). - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :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). - Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource path. Use empty string if there is none. - Required. - :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). Required. - :type resource_type: str - :param resource_name: The name of the resource. Required. - :type resource_name: str - :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, - no filtering is performed. If $filter=atScope() is provided, the returned list only includes - all policy assignments that apply to the scope, which is everything in the unfiltered list - except those applied to sub scopes contained within the given scope. If $filter=atExactScope() - is provided, the returned list only includes all policy assignments that at the given scope. If - $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy - assignments of the policy definition whose id is {value}. Default value is None. - :paramtype filter: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :keyword top: Maximum number of records to return. When the $top filter is not provided, it - will return 500 records. Default value is None. - :paramtype top: int - :return: An iterator like instance of PolicyAssignment - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicyAssignment]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - filter=filter, - expand=expand, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicyAssignment], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class DataPolicyManifestsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.resource.policy.PolicyClient`'s - :attr:`data_policy_manifests` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PolicyClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - @api_version_validation( - method_added_on="2025-11-01", - params_added_on={"2025-11-01": ["api_version", "policy_mode", "accept"]}, - api_versions_list=["2025-11-01", "2025-12-01-preview", "2026-01-01-preview"], - ) - def get_by_policy_mode(self, policy_mode: str, **kwargs: Any) -> _models.DataPolicyManifest: - """Retrieves a data policy manifest. - - This operation retrieves the data policy manifest with the given policy mode. - - :param policy_mode: The policy mode of the data policy manifest to get. Required. - :type policy_mode: str - :return: DataPolicyManifest. The DataPolicyManifest is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.DataPolicyManifest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.DataPolicyManifest] = kwargs.pop("cls", None) - - _request = build_data_policy_manifests_get_by_policy_mode_request( - policy_mode=policy_mode, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.DataPolicyManifest, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - @api_version_validation( - method_added_on="2025-11-01", - params_added_on={"2025-11-01": ["api_version", "filter", "accept"]}, - api_versions_list=["2025-11-01", "2025-12-01-preview", "2026-01-01-preview"], - ) - def list(self, *, filter: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.DataPolicyManifest"]: - """Retrieves data policy manifests. - - This operation retrieves a list of all the data policy manifests that match the optional given - $filter. Valid values for $filter are: \\"$filter=namespace eq '{0}'\\". If $filter is not - provided, the unfiltered list includes all data policy manifests for data resource types. If - $filter=namespace is provided, the returned list only includes all data policy manifests that - have a namespace matching the provided value. - - :keyword filter: The filter to apply on the operation. Valid values for $filter are: - \\"namespace eq '{value}'\\". If $filter is not provided, no filtering is performed. If - $filter=namespace eq '{value}' is provided, the returned list only includes all data policy - manifests that have a namespace matching the provided value. Default value is None. - :paramtype filter: str - :return: An iterator like instance of DataPolicyManifest - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.DataPolicyManifest] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.DataPolicyManifest]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_data_policy_manifests_list_request( - filter=filter, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.DataPolicyManifest], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class PolicyDefinitionsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.resource.policy.PolicyClient`'s - :attr:`policy_definitions` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PolicyClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: - """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. Required. - :type policy_definition_name: str - :return: PolicyDefinition. The PolicyDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.PolicyDefinition] = kwargs.pop("cls", None) - - _request = build_policy_definitions_get_request( - policy_definition_name=policy_definition_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicyDefinition, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - policy_definition_name: str, - parameters: _models.PolicyDefinition, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyDefinition: - """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 get. Required. - :type policy_definition_name: str - :param parameters: The policy definition properties. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyDefinition. The PolicyDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - policy_definition_name: str, - parameters: _types.PolicyDefinition, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyDefinition: - """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 get. Required. - :type policy_definition_name: str - :param parameters: The policy definition properties. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicyDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyDefinition. The PolicyDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - policy_definition_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyDefinition: - """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 get. Required. - :type policy_definition_name: str - :param parameters: The policy definition properties. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyDefinition. The PolicyDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - policy_definition_name: str, - parameters: Union[_models.PolicyDefinition, _types.PolicyDefinition, IO[bytes]], - **kwargs: Any, - ) -> _models.PolicyDefinition: - """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 get. Required. - :type policy_definition_name: str - :param parameters: The policy definition properties. Is either a PolicyDefinition type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyDefinition or - ~azure.mgmt.resource.policy.types.PolicyDefinition or IO[bytes] - :return: PolicyDefinition. The PolicyDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_policy_definitions_create_or_update_request( - policy_definition_name=policy_definition_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicyDefinition, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, policy_definition_name: str, **kwargs: Any - ) -> None: - """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 get. Required. - :type policy_definition_name: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_policy_definitions_delete_request( - policy_definition_name=policy_definition_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def list( - self, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.PolicyDefinition"]: - """This operation retrieves a list of all the policy definitions in a given subscription that - match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType - -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list - includes all policy definitions associated with the subscription, including those that apply - directly or from management groups that contain the given subscription. If - $filter=atExactScope() is provided, the returned list only includes all policy definitions that - at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list - only includes all policy definitions whose type match the {value}. Possible policyType values - are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, - the returned list only includes all policy definitions whose category match the {value}. - - :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not - provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list - only includes all policy definitions that at the given scope. If $filter='policyType -eq - {value}' is provided, the returned list only includes all policy definitions whose type match - the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If - $filter='category -eq {value}' is provided, the returned list only includes all policy - definitions whose category match the {value}. Default value is None. - :paramtype filter: str - :keyword top: Maximum number of records to return. When the $top filter is not provided, it - will return 500 records. Default value is None. - :paramtype top: int - :return: An iterator like instance of PolicyDefinition - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicyDefinition]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicyDefinition], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get_built_in(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: - """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. Required. - :type policy_definition_name: str - :return: PolicyDefinition. The PolicyDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.PolicyDefinition] = kwargs.pop("cls", None) - - _request = build_policy_definitions_get_built_in_request( - policy_definition_name=policy_definition_name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicyDefinition, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_built_in( - self, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.PolicyDefinition"]: - """This operation retrieves a list of all the built-in policy definitions that match the optional - given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes - all built-in policy definitions whose type match the {value}. Possible policyType values are - NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the - returned list only includes all built-in policy definitions whose category match the {value}. - - :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not - provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list - only includes all policy definitions that at the given scope. If $filter='policyType -eq - {value}' is provided, the returned list only includes all policy definitions whose type match - the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If - $filter='category -eq {value}' is provided, the returned list only includes all policy - definitions whose category match the {value}. Default value is None. - :paramtype filter: str - :keyword top: Maximum number of records to return. When the $top filter is not provided, it - will return 500 records. Default value is None. - :paramtype top: int - :return: An iterator like instance of PolicyDefinition - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicyDefinition]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_definitions_list_built_in_request( - filter=filter, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicyDefinition], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get_at_management_group( - self, management_group_id: str, policy_definition_name: str, **kwargs: Any - ) -> _models.PolicyDefinition: - """This operation retrieves the policy definition in the given management group with the given - name. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param policy_definition_name: The name of the policy definition to get. Required. - :type policy_definition_name: str - :return: PolicyDefinition. The PolicyDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.PolicyDefinition] = kwargs.pop("cls", None) - - _request = build_policy_definitions_get_at_management_group_request( - management_group_id=management_group_id, - policy_definition_name=policy_definition_name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicyDefinition, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update_at_management_group( - self, - management_group_id: str, - policy_definition_name: str, - parameters: _models.PolicyDefinition, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyDefinition: - """This operation creates or updates a policy definition in the given management group with the - given name. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param policy_definition_name: The name of the policy definition to get. Required. - :type policy_definition_name: str - :param parameters: The policy definition properties. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyDefinition. The PolicyDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update_at_management_group( - self, - management_group_id: str, - policy_definition_name: str, - parameters: _types.PolicyDefinition, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyDefinition: - """This operation creates or updates a policy definition in the given management group with the - given name. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param policy_definition_name: The name of the policy definition to get. Required. - :type policy_definition_name: str - :param parameters: The policy definition properties. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicyDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyDefinition. The PolicyDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update_at_management_group( - self, - management_group_id: str, - policy_definition_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyDefinition: - """This operation creates or updates a policy definition in the given management group with the - given name. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param policy_definition_name: The name of the policy definition to get. Required. - :type policy_definition_name: str - :param parameters: The policy definition properties. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyDefinition. The PolicyDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update_at_management_group( - self, - management_group_id: str, - policy_definition_name: str, - parameters: Union[_models.PolicyDefinition, _types.PolicyDefinition, IO[bytes]], - **kwargs: Any, - ) -> _models.PolicyDefinition: - """This operation creates or updates a policy definition in the given management group with the - given name. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param policy_definition_name: The name of the policy definition to get. Required. - :type policy_definition_name: str - :param parameters: The policy definition properties. Is either a PolicyDefinition type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyDefinition or - ~azure.mgmt.resource.policy.types.PolicyDefinition or IO[bytes] - :return: PolicyDefinition. The PolicyDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_policy_definitions_create_or_update_at_management_group_request( - management_group_id=management_group_id, - policy_definition_name=policy_definition_name, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicyDefinition, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, management_group_id: str, policy_definition_name: str, **kwargs: Any - ) -> None: - """This operation deletes the policy definition in the given management group with the given name. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param policy_definition_name: The name of the policy definition to get. Required. - :type policy_definition_name: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_policy_definitions_delete_at_management_group_request( - management_group_id=management_group_id, - policy_definition_name=policy_definition_name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def list_by_management_group( - self, management_group_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.PolicyDefinition"]: - """This operation retrieves a list of all the policy definitions in a given management group that - match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType - -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list - includes all policy definitions associated with the management group, including those that - apply directly or from management groups that contain the given management group. If - $filter=atExactScope() is provided, the returned list only includes all policy definitions that - at the given management group. If $filter='policyType -eq {value}' is provided, the returned - list only includes all policy definitions whose type match the {value}. Possible policyType - values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is - provided, the returned list only includes all policy definitions whose category match the - {value}. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not - provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list - only includes all policy definitions that at the given scope. If $filter='policyType -eq - {value}' is provided, the returned list only includes all policy definitions whose type match - the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If - $filter='category -eq {value}' is provided, the returned list only includes all policy - definitions whose category match the {value}. Default value is None. - :paramtype filter: str - :keyword top: Maximum number of records to return. When the $top filter is not provided, it - will return 500 records. Default value is None. - :paramtype top: int - :return: An iterator like instance of PolicyDefinition - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicyDefinition]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_definitions_list_by_management_group_request( - management_group_id=management_group_id, - filter=filter, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicyDefinition], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class PolicyDefinitionVersionsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.resource.policy.PolicyClient`'s - :attr:`policy_definition_versions` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PolicyClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, policy_definition_name: str, policy_definition_version: str, **kwargs: Any - ) -> _models.PolicyDefinitionVersion: - """This operation retrieves the policy definition version in the given subscription with the given - name. - - :param policy_definition_name: The name of the policy definition. Required. - :type policy_definition_name: str - :param policy_definition_version: The policy definition version. The format is x.y.z where x - is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :return: PolicyDefinitionVersion. The PolicyDefinitionVersion is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.PolicyDefinitionVersion] = kwargs.pop("cls", None) - - _request = build_policy_definition_versions_get_request( - policy_definition_name=policy_definition_name, - policy_definition_version=policy_definition_version, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicyDefinitionVersion, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - policy_definition_name: str, - policy_definition_version: str, - parameters: _models.PolicyDefinitionVersion, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyDefinitionVersion: - """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. Required. - :type policy_definition_name: str - :param policy_definition_version: The policy definition version. The format is x.y.z where x - is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :param parameters: The policy definition properties. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyDefinitionVersion. The PolicyDefinitionVersion is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - policy_definition_name: str, - policy_definition_version: str, - parameters: _types.PolicyDefinitionVersion, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyDefinitionVersion: - """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. Required. - :type policy_definition_name: str - :param policy_definition_version: The policy definition version. The format is x.y.z where x - is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :param parameters: The policy definition properties. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicyDefinitionVersion - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyDefinitionVersion. The PolicyDefinitionVersion is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - policy_definition_name: str, - policy_definition_version: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyDefinitionVersion: - """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. Required. - :type policy_definition_name: str - :param policy_definition_version: The policy definition version. The format is x.y.z where x - is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :param parameters: The policy definition properties. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyDefinitionVersion. The PolicyDefinitionVersion is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - policy_definition_name: str, - policy_definition_version: str, - parameters: Union[_models.PolicyDefinitionVersion, _types.PolicyDefinitionVersion, IO[bytes]], - **kwargs: Any, - ) -> _models.PolicyDefinitionVersion: - """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. Required. - :type policy_definition_name: str - :param policy_definition_version: The policy definition version. The format is x.y.z where x - is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :param parameters: The policy definition properties. Is either a PolicyDefinitionVersion type - or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion or - ~azure.mgmt.resource.policy.types.PolicyDefinitionVersion or IO[bytes] - :return: PolicyDefinitionVersion. The PolicyDefinitionVersion is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyDefinitionVersion] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_policy_definition_versions_create_or_update_request( - policy_definition_name=policy_definition_name, - policy_definition_version=policy_definition_version, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicyDefinitionVersion, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, policy_definition_name: str, policy_definition_version: str, **kwargs: Any - ) -> None: - """This operation deletes the policy definition version in the given subscription with the given - name. - - :param policy_definition_name: The name of the policy definition. Required. - :type policy_definition_name: str - :param policy_definition_version: The policy definition version. The format is x.y.z where x - is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_policy_definition_versions_delete_request( - policy_definition_name=policy_definition_name, - policy_definition_version=policy_definition_version, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def list( - self, policy_definition_name: str, *, top: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.PolicyDefinitionVersion"]: - """This operation retrieves a list of all the policy definition versions for the given policy - definition. - - :param policy_definition_name: The name of the policy definition. Required. - :type policy_definition_name: str - :keyword top: Maximum number of records to return. When the $top filter is not provided, it - will return 500 records. Default value is None. - :paramtype top: int - :return: An iterator like instance of PolicyDefinitionVersion - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinitionVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicyDefinitionVersion]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_definition_versions_list_request( - policy_definition_name=policy_definition_name, - subscription_id=self._config.subscription_id, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicyDefinitionVersion], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get_built_in( - self, policy_definition_name: str, policy_definition_version: str, **kwargs: Any - ) -> _models.PolicyDefinitionVersion: - """This operation retrieves the built-in policy definition version with the given name. - - :param policy_definition_name: The name of the policy definition. Required. - :type policy_definition_name: str - :param policy_definition_version: The policy definition version. The format is x.y.z where x - is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :return: PolicyDefinitionVersion. The PolicyDefinitionVersion is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.PolicyDefinitionVersion] = kwargs.pop("cls", None) - - _request = build_policy_definition_versions_get_built_in_request( - policy_definition_name=policy_definition_name, - policy_definition_version=policy_definition_version, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicyDefinitionVersion, response.json()) +class PolicyAssignmentsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.PolicyClient`'s + :attr:`policy_assignments` attribute. + """ - return deserialized # type: ignore + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_built_in( - self, policy_definition_name: str, *, top: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.PolicyDefinitionVersion"]: - """This operation retrieves a list of all the built-in policy definition versions for the given - policy definition. - - :param policy_definition_name: The name of the policy definition. Required. - :type policy_definition_name: str - :keyword top: Maximum number of records to return. When the $top filter is not provided, it - will return 500 records. Default value is None. - :paramtype top: int - :return: An iterator like instance of PolicyDefinitionVersion - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinitionVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicyDefinitionVersion]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_definition_versions_list_built_in_request( - policy_definition_name=policy_definition_name, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicyDefinitionVersion], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) + def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: + """Retrieves the policy assignment with the given ID. - @distributed_trace - def get_at_management_group( - self, management_group_name: str, policy_definition_name: str, policy_definition_version: str, **kwargs: Any - ) -> _models.PolicyDefinitionVersion: - """This operation retrieves the policy definition version in the given management group with the - given name. + 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 management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :param policy_definition_name: The name of the policy definition. Required. - :type policy_definition_name: str - :param policy_definition_version: The policy definition version. The format is x.y.z where x - is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :return: PolicyDefinitionVersion. The PolicyDefinitionVersion is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion + :param policy_assignment_id: The ID of the policy assignment to get. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6151,12 +1861,10 @@ def get_at_management_group( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.PolicyDefinitionVersion] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) - _request = build_policy_definition_versions_get_at_management_group_request( - management_group_name=management_group_name, - policy_definition_name=policy_definition_name, - policy_definition_version=policy_definition_version, + _request = build_policy_assignments_get_by_id_request( + policy_assignment_id=policy_assignment_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6190,7 +1898,7 @@ def get_at_management_group( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.PolicyDefinitionVersion, response.json()) + deserialized = _deserialize(_models.PolicyAssignment, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -6198,217 +1906,134 @@ def get_at_management_group( return deserialized # type: ignore @overload - def create_or_update_at_management_group( + def create_by_id( self, - management_group_name: str, - policy_definition_name: str, - policy_definition_version: str, - parameters: _models.PolicyDefinitionVersion, + policy_assignment_id: str, + parameters: _models.PolicyAssignment, *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicyDefinitionVersion: - """This operation creates or updates a policy definition version in the given management group - with the given name. + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :param policy_definition_name: The name of the policy definition. Required. - :type policy_definition_name: str - :param policy_definition_version: The policy definition version. The format is x.y.z where x - is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :param parameters: The policy definition properties. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion + 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 get. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicyAssignment :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PolicyDefinitionVersion. The PolicyDefinitionVersion is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion + :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update_at_management_group( + def create_by_id( self, - management_group_name: str, - policy_definition_name: str, - policy_definition_version: str, - parameters: _types.PolicyDefinitionVersion, + policy_assignment_id: str, + parameters: _types.PolicyAssignment, *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicyDefinitionVersion: - """This operation creates or updates a policy definition version in the given management group - with the given name. + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :param policy_definition_name: The name of the policy definition. Required. - :type policy_definition_name: str - :param policy_definition_version: The policy definition version. The format is x.y.z where x - is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :param parameters: The policy definition properties. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicyDefinitionVersion + 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 get. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: ~azure.mgmt.resource.policy.types.PolicyAssignment :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PolicyDefinitionVersion. The PolicyDefinitionVersion is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion + :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update_at_management_group( - self, - management_group_name: str, - policy_definition_name: str, - policy_definition_version: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyDefinitionVersion: - """This operation creates or updates a policy definition version in the given management group - with the given name. + def create_by_id( + self, policy_assignment_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :param policy_definition_name: The name of the policy definition. Required. - :type policy_definition_name: str - :param policy_definition_version: The policy definition version. The format is x.y.z where x - is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :param parameters: The policy definition properties. Required. + 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 get. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: PolicyDefinitionVersion. The PolicyDefinitionVersion is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion + :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create_or_update_at_management_group( + def create_by_id( self, - management_group_name: str, - policy_definition_name: str, - policy_definition_version: str, - parameters: Union[_models.PolicyDefinitionVersion, _types.PolicyDefinitionVersion, IO[bytes]], + policy_assignment_id: str, + parameters: Union[_models.PolicyAssignment, _types.PolicyAssignment, IO[bytes]], **kwargs: Any, - ) -> _models.PolicyDefinitionVersion: - """This operation creates or updates a policy definition version in the given management group - with the given name. - - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :param policy_definition_name: The name of the policy definition. Required. - :type policy_definition_name: str - :param policy_definition_version: The policy definition version. The format is x.y.z where x - is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :param parameters: The policy definition properties. Is either a PolicyDefinitionVersion type - or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion or - ~azure.mgmt.resource.policy.types.PolicyDefinitionVersion or IO[bytes] - :return: PolicyDefinitionVersion. The PolicyDefinitionVersion is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyDefinitionVersion] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_policy_definition_versions_create_or_update_at_management_group_request( - management_group_name=management_group_name, - policy_definition_name=policy_definition_name, - policy_definition_version=policy_definition_version, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicyDefinitionVersion, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. - @distributed_trace - def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, management_group_name: str, policy_definition_name: str, policy_definition_version: str, **kwargs: Any - ) -> None: - """This operation deletes the policy definition in the given management group with the given name. + 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 management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :param policy_definition_name: The name of the policy definition. Required. - :type policy_definition_name: str - :param policy_definition_version: The policy definition version. The format is x.y.z where x - is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :return: None - :rtype: None + :param policy_assignment_id: The ID of the policy assignment to get. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Is either a PolicyAssignment type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicyAssignment or + ~azure.mgmt.resource.policy.types.PolicyAssignment or IO[bytes] + :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6419,16 +2044,24 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) - _request = build_policy_definition_versions_delete_at_management_group_request( - management_group_name=management_group_name, - policy_definition_name=policy_definition_name, - policy_definition_version=policy_definition_version, + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_policy_assignments_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -6437,14 +2070,20 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _failsafe_deserialize( _models.ErrorResponse, @@ -6452,197 +2091,145 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def list_by_management_group( - self, management_group_name: str, policy_definition_name: str, *, top: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.PolicyDefinitionVersion"]: - """This operation retrieves a list of all the policy definition versions for the given policy - definition in the given management group. - - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :param policy_definition_name: The name of the policy definition. Required. - :type policy_definition_name: str - :keyword top: Maximum number of records to return. When the $top filter is not provided, it - will return 500 records. Default value is None. - :paramtype top: int - :return: An iterator like instance of PolicyDefinitionVersion - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinitionVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicyDefinitionVersion]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_definition_versions_list_by_management_group_request( - management_group_name=management_group_name, - policy_definition_name=policy_definition_name, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicyDefinitionVersion], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyAssignment, response.json()) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - return ItemPaged(get_next, extract_data) + return deserialized # type: ignore - @distributed_trace - def list_all_builtins(self, **kwargs: Any) -> _models.PolicyDefinitionVersionListResult: - """Lists all built-in policy definition versions. + @overload + def update_by_id( + self, + policy_assignment_id: str, + parameters: _models.PolicyAssignmentUpdate, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.PolicyAssignment: + """Updates a policy assignment. - This operation lists all the built-in policy definition versions for all built-in policy - definitions. + This operation updates the policy assignment with the given ID. Policy assignments made on a + scope apply to all resources contained in that scope. For example, when you assign a policy to + a resource group that policy applies to all resources in the group. Policy assignment IDs have + this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - :return: PolicyDefinitionVersionListResult. The PolicyDefinitionVersionListResult is compatible - with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersionListResult + :param policy_assignment_id: The ID of the policy assignment to get. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment patch request. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicyAssignmentUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.PolicyDefinitionVersionListResult] = kwargs.pop("cls", None) - - _request = build_policy_definition_versions_list_all_builtins_request( - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + @overload + def update_by_id( + self, + policy_assignment_id: str, + parameters: _types.PolicyAssignmentUpdate, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.PolicyAssignment: + """Updates a policy assignment. - response = pipeline_response.http_response + This operation updates the policy assignment with the given ID. Policy assignments made on a + scope apply to all resources contained in that scope. For example, when you assign a policy to + a resource group that policy applies to all resources in the group. Policy assignment IDs have + this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + :param policy_assignment_id: The ID of the policy assignment to get. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment patch request. Required. + :type parameters: ~azure.mgmt.resource.policy.types.PolicyAssignmentUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicyDefinitionVersionListResult, response.json()) + @overload + def update_by_id( + self, policy_assignment_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Updates a policy assignment. - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + This operation updates the policy assignment with the given ID. Policy assignments made on a + scope apply to all resources contained in that scope. For example, when you assign a policy to + a resource group that policy applies to all resources in the group. Policy assignment IDs have + this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - return deserialized # type: ignore + :param policy_assignment_id: The ID of the policy assignment to get. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment patch request. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def list_all_at_management_group( - self, management_group_name: str, **kwargs: Any - ) -> _models.PolicyDefinitionVersionListResult: - """Lists all policy definition versions at management group scope. + def update_by_id( + self, + policy_assignment_id: str, + parameters: Union[_models.PolicyAssignmentUpdate, _types.PolicyAssignmentUpdate, IO[bytes]], + **kwargs: Any, + ) -> _models.PolicyAssignment: + """Updates a policy assignment. - This operation lists all the policy definition versions for all policy definitions at the - management group scope. + This operation updates the policy assignment with the given ID. Policy assignments made on a + scope apply to all resources contained in that scope. For example, when you assign a policy to + a resource group that policy applies to all resources in the group. Policy assignment IDs have + this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :return: PolicyDefinitionVersionListResult. The PolicyDefinitionVersionListResult is compatible - with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersionListResult + :param policy_assignment_id: The ID of the policy assignment to get. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment patch request. Is either a + PolicyAssignmentUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicyAssignmentUpdate or + ~azure.mgmt.resource.policy.types.PolicyAssignmentUpdate or IO[bytes] + :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6653,14 +2240,24 @@ def list_all_at_management_group( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.PolicyDefinitionVersionListResult] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) - _request = build_policy_definition_versions_list_all_at_management_group_request( - management_group_name=management_group_name, + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_policy_assignments_update_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -6693,7 +2290,7 @@ def list_all_at_management_group( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.PolicyDefinitionVersionListResult, response.json()) + deserialized = _deserialize(_models.PolicyAssignment, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -6701,15 +2298,22 @@ def list_all_at_management_group( return deserialized # type: ignore @distributed_trace - def list_all(self, **kwargs: Any) -> _models.PolicyDefinitionVersionListResult: - """Lists all policy definition versions within a subscription. + def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: + """Deletes a policy assignment. - This operation lists all the policy definition versions for all policy definitions within a - subscription. + 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). - :return: PolicyDefinitionVersionListResult. The PolicyDefinitionVersionListResult is compatible - with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersionListResult + :param policy_assignment_id: The ID of the policy assignment to get. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :return: PolicyAssignment or None. The PolicyAssignment is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6723,10 +2327,10 @@ def list_all(self, **kwargs: Any) -> _models.PolicyDefinitionVersionListResult: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.PolicyDefinitionVersionListResult] = kwargs.pop("cls", None) + cls: ClsType[Optional[_models.PolicyAssignment]] = kwargs.pop("cls", None) - _request = build_policy_definition_versions_list_all_request( - subscription_id=self._config.subscription_id, + _request = build_policy_assignments_delete_by_id_request( + policy_assignment_id=policy_assignment_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6744,7 +2348,7 @@ def list_all(self, **kwargs: Any) -> _models.PolicyDefinitionVersionListResult: response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 204]: if _stream: try: response.read() # Load the body in memory and close the socket @@ -6757,52 +2361,35 @@ def list_all(self, **kwargs: Any) -> _models.PolicyDefinitionVersionListResult: ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicyDefinitionVersionListResult, response.json()) + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyAssignment, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class PolicyEnrollmentsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.resource.policy.PolicyClient`'s - :attr:`policy_enrollments` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PolicyClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - @api_version_validation( - method_added_on="2026-01-01-preview", - params_added_on={"2026-01-01-preview": ["api_version", "scope", "policy_enrollment_name", "accept"]}, - api_versions_list=["2026-01-01-preview"], - ) - def get(self, scope: str, policy_enrollment_name: str, **kwargs: Any) -> _models.PolicyEnrollment: - """Retrieves a policy enrollment. - - This operation retrieves a single policy enrollment, given its name and the scope it was + def get( + self, scope: str, policy_assignment_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> _models.PolicyAssignment: + """This operation retrieves a single policy assignment, given its name and the scope it was created at. :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. :type scope: str - :param policy_enrollment_name: The name of the policy enrollment. Required. - :type policy_enrollment_name: str - :return: PolicyEnrollment. The PolicyEnrollment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyEnrollment + :param policy_assignment_name: The name of the policy assignment to get. Required. + :type policy_assignment_name: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6816,11 +2403,12 @@ def get(self, scope: str, policy_enrollment_name: str, **kwargs: Any) -> _models _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.PolicyEnrollment] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) - _request = build_policy_enrollments_get_request( + _request = build_policy_assignments_get_request( scope=scope, - policy_enrollment_name=policy_enrollment_name, + policy_assignment_name=policy_assignment_name, + expand=expand, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6854,7 +2442,7 @@ def get(self, scope: str, policy_enrollment_name: str, **kwargs: Any) -> _models if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.PolicyEnrollment, response.json()) + deserialized = _deserialize(_models.PolicyAssignment, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -6862,130 +2450,111 @@ def get(self, scope: str, policy_enrollment_name: str, **kwargs: Any) -> _models return deserialized # type: ignore @overload - def create_or_update( + def create( self, scope: str, - policy_enrollment_name: str, - parameters: _models.PolicyEnrollment, + policy_assignment_name: str, + parameters: _models.PolicyAssignment, *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicyEnrollment: - """Creates or updates a policy enrollment. - - This operation creates or updates a policy enrollment with the given scope and name. Policy - enrollments apply to all resources contained within their scope. For example, when you create a - policy enrollment at resource group scope for a policy assignment at the same or above level, - the enrollment applies to all applicable resources in the resource group. + ) -> _models.PolicyAssignment: + """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 fully qualified Azure Resource manager identifier of the resource. Required. :type scope: str - :param policy_enrollment_name: The name of the policy enrollment. Required. - :type policy_enrollment_name: str - :param parameters: The policy enrollment resource to create or replace. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyEnrollment + :param policy_assignment_name: The name of the policy assignment to get. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicyAssignment :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PolicyEnrollment. The PolicyEnrollment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyEnrollment + :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( + def create( self, scope: str, - policy_enrollment_name: str, - parameters: _types.PolicyEnrollment, + policy_assignment_name: str, + parameters: _types.PolicyAssignment, *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicyEnrollment: - """Creates or updates a policy enrollment. - - This operation creates or updates a policy enrollment with the given scope and name. Policy - enrollments apply to all resources contained within their scope. For example, when you create a - policy enrollment at resource group scope for a policy assignment at the same or above level, - the enrollment applies to all applicable resources in the resource group. + ) -> _models.PolicyAssignment: + """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 fully qualified Azure Resource manager identifier of the resource. Required. :type scope: str - :param policy_enrollment_name: The name of the policy enrollment. Required. - :type policy_enrollment_name: str - :param parameters: The policy enrollment resource to create or replace. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicyEnrollment + :param policy_assignment_name: The name of the policy assignment to get. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: ~azure.mgmt.resource.policy.types.PolicyAssignment :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PolicyEnrollment. The PolicyEnrollment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyEnrollment + :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( + def create( self, scope: str, - policy_enrollment_name: str, + policy_assignment_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicyEnrollment: - """Creates or updates a policy enrollment. - - This operation creates or updates a policy enrollment with the given scope and name. Policy - enrollments apply to all resources contained within their scope. For example, when you create a - policy enrollment at resource group scope for a policy assignment at the same or above level, - the enrollment applies to all applicable resources in the resource group. + ) -> _models.PolicyAssignment: + """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 fully qualified Azure Resource manager identifier of the resource. Required. :type scope: str - :param policy_enrollment_name: The name of the policy enrollment. Required. - :type policy_enrollment_name: str - :param parameters: The policy enrollment resource to create or replace. Required. + :param policy_assignment_name: The name of the policy assignment to get. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: PolicyEnrollment. The PolicyEnrollment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyEnrollment + :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - @api_version_validation( - method_added_on="2026-01-01-preview", - params_added_on={ - "2026-01-01-preview": ["api_version", "scope", "policy_enrollment_name", "content_type", "accept"] - }, - api_versions_list=["2026-01-01-preview"], - ) - def create_or_update( + def create( self, scope: str, - policy_enrollment_name: str, - parameters: Union[_models.PolicyEnrollment, _types.PolicyEnrollment, IO[bytes]], + policy_assignment_name: str, + parameters: Union[_models.PolicyAssignment, _types.PolicyAssignment, IO[bytes]], **kwargs: Any, - ) -> _models.PolicyEnrollment: - """Creates or updates a policy enrollment. - - This operation creates or updates a policy enrollment with the given scope and name. Policy - enrollments apply to all resources contained within their scope. For example, when you create a - policy enrollment at resource group scope for a policy assignment at the same or above level, - the enrollment applies to all applicable resources in the resource group. + ) -> _models.PolicyAssignment: + """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 fully qualified Azure Resource manager identifier of the resource. Required. :type scope: str - :param policy_enrollment_name: The name of the policy enrollment. Required. - :type policy_enrollment_name: str - :param parameters: The policy enrollment resource to create or replace. Is either a - PolicyEnrollment type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyEnrollment or - ~azure.mgmt.resource.policy.types.PolicyEnrollment or IO[bytes] - :return: PolicyEnrollment. The PolicyEnrollment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyEnrollment + :param policy_assignment_name: The name of the policy assignment to get. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a PolicyAssignment type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicyAssignment or + ~azure.mgmt.resource.policy.types.PolicyAssignment or IO[bytes] + :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7000,7 +2569,7 @@ def create_or_update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyEnrollment] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _content = None @@ -7009,9 +2578,9 @@ def create_or_update( else: _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_policy_enrollments_create_or_update_request( + _request = build_policy_assignments_create_request( scope=scope, - policy_enrollment_name=policy_enrollment_name, + policy_assignment_name=policy_assignment_name, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -7031,7 +2600,7 @@ def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [201]: if _stream: try: response.read() # Load the body in memory and close the socket @@ -7047,7 +2616,7 @@ def create_or_update( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.PolicyEnrollment, response.json()) + deserialized = _deserialize(_models.PolicyAssignment, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -7058,27 +2627,27 @@ def create_or_update( def update( self, scope: str, - policy_enrollment_name: str, - parameters: _models.PolicyEnrollmentUpdate, + policy_assignment_name: str, + parameters: _models.PolicyAssignmentUpdate, *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicyEnrollment: - """Updates a policy enrollment. - - This operation updates a policy enrollment with the given scope and name. + ) -> _models.PolicyAssignment: + """This operation updates a policy assignment with the given scope and name. Policy assignments + apply to all resources contained within their scope. For example, when you assign a policy at + resource group scope, that policy applies to all resources in the group. :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. :type scope: str - :param policy_enrollment_name: The name of the policy enrollment. Required. - :type policy_enrollment_name: str - :param parameters: The properties to update in the policy enrollment. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyEnrollmentUpdate + :param policy_assignment_name: The name of the policy assignment to get. Required. + :type policy_assignment_name: str + :param parameters: Parameters for policy assignment patch request. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicyAssignmentUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PolicyEnrollment. The PolicyEnrollment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyEnrollment + :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @@ -7086,27 +2655,27 @@ def update( def update( self, scope: str, - policy_enrollment_name: str, - parameters: _types.PolicyEnrollmentUpdate, + policy_assignment_name: str, + parameters: _types.PolicyAssignmentUpdate, *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicyEnrollment: - """Updates a policy enrollment. - - This operation updates a policy enrollment with the given scope and name. + ) -> _models.PolicyAssignment: + """This operation updates a policy assignment with the given scope and name. Policy assignments + apply to all resources contained within their scope. For example, when you assign a policy at + resource group scope, that policy applies to all resources in the group. :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. :type scope: str - :param policy_enrollment_name: The name of the policy enrollment. Required. - :type policy_enrollment_name: str - :param parameters: The properties to update in the policy enrollment. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicyEnrollmentUpdate + :param policy_assignment_name: The name of the policy assignment to get. Required. + :type policy_assignment_name: str + :param parameters: Parameters for policy assignment patch request. Required. + :type parameters: ~azure.mgmt.resource.policy.types.PolicyAssignmentUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PolicyEnrollment. The PolicyEnrollment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyEnrollment + :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @@ -7114,59 +2683,52 @@ def update( def update( self, scope: str, - policy_enrollment_name: str, + policy_assignment_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicyEnrollment: - """Updates a policy enrollment. - - This operation updates a policy enrollment with the given scope and name. + ) -> _models.PolicyAssignment: + """This operation updates a policy assignment with the given scope and name. Policy assignments + apply to all resources contained within their scope. For example, when you assign a policy at + resource group scope, that policy applies to all resources in the group. :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. :type scope: str - :param policy_enrollment_name: The name of the policy enrollment. Required. - :type policy_enrollment_name: str - :param parameters: The properties to update in the policy enrollment. Required. + :param policy_assignment_name: The name of the policy assignment to get. Required. + :type policy_assignment_name: str + :param parameters: Parameters for policy assignment patch request. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: PolicyEnrollment. The PolicyEnrollment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyEnrollment + :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - @api_version_validation( - method_added_on="2026-01-01-preview", - params_added_on={ - "2026-01-01-preview": ["api_version", "scope", "policy_enrollment_name", "content_type", "accept"] - }, - api_versions_list=["2026-01-01-preview"], - ) def update( self, scope: str, - policy_enrollment_name: str, - parameters: Union[_models.PolicyEnrollmentUpdate, _types.PolicyEnrollmentUpdate, IO[bytes]], + policy_assignment_name: str, + parameters: Union[_models.PolicyAssignmentUpdate, _types.PolicyAssignmentUpdate, IO[bytes]], **kwargs: Any, - ) -> _models.PolicyEnrollment: - """Updates a policy enrollment. - - This operation updates a policy enrollment with the given scope and name. + ) -> _models.PolicyAssignment: + """This operation updates a policy assignment with the given scope and name. Policy assignments + apply to all resources contained within their scope. For example, when you assign a policy at + resource group scope, that policy applies to all resources in the group. :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. :type scope: str - :param policy_enrollment_name: The name of the policy enrollment. Required. - :type policy_enrollment_name: str - :param parameters: The properties to update in the policy enrollment. Is either a - PolicyEnrollmentUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyEnrollmentUpdate or - ~azure.mgmt.resource.policy.types.PolicyEnrollmentUpdate or IO[bytes] - :return: PolicyEnrollment. The PolicyEnrollment is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyEnrollment + :param policy_assignment_name: The name of the policy assignment to get. Required. + :type policy_assignment_name: str + :param parameters: Parameters for policy assignment patch request. Is either a + PolicyAssignmentUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicyAssignmentUpdate or + ~azure.mgmt.resource.policy.types.PolicyAssignmentUpdate or IO[bytes] + :return: PolicyAssignment. The PolicyAssignment is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7181,7 +2743,7 @@ def update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyEnrollment] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _content = None @@ -7190,9 +2752,9 @@ def update( else: _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_policy_enrollments_update_request( + _request = build_policy_assignments_update_request( scope=scope, - policy_enrollment_name=policy_enrollment_name, + policy_assignment_name=policy_assignment_name, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -7228,7 +2790,7 @@ def update( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.PolicyEnrollment, response.json()) + deserialized = _deserialize(_models.PolicyAssignment, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -7236,26 +2798,17 @@ def update( return deserialized # type: ignore @distributed_trace - @api_version_validation( - method_added_on="2026-01-01-preview", - params_added_on={"2026-01-01-preview": ["api_version", "scope", "policy_enrollment_name"]}, - api_versions_list=["2026-01-01-preview"], - ) - def delete( # pylint: disable=inconsistent-return-statements - self, scope: str, policy_enrollment_name: str, **kwargs: Any - ) -> None: - """Deletes a policy enrollment. - - This operation deletes a policy enrollment, given its name and the scope it was created in. The - scope of a policy enrollment is the part of its ID preceding - '/providers/Microsoft.Authorization/policyEnrollments/{policyEnrollmentName}'. + def delete(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: + """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 fully qualified Azure Resource manager identifier of the resource. Required. :type scope: str - :param policy_enrollment_name: The name of the policy enrollment. Required. - :type policy_enrollment_name: str - :return: None - :rtype: None + :param policy_assignment_name: The name of the policy assignment to get. Required. + :type policy_assignment_name: str + :return: PolicyAssignment or None. The PolicyAssignment is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7269,11 +2822,11 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Optional[_models.PolicyAssignment]] = kwargs.pop("cls", None) - _request = build_policy_enrollments_delete_request( + _request = build_policy_assignments_delete_request( scope=scope, - policy_enrollment_name=policy_enrollment_name, + policy_assignment_name=policy_assignment_name, api_version=self._config.api_version, headers=_headers, params=_params, @@ -7283,7 +2836,8 @@ def delete( # pylint: disable=inconsistent-return-statements } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -7291,6 +2845,11 @@ def delete( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 204]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _failsafe_deserialize( _models.ErrorResponse, @@ -7298,49 +2857,68 @@ def delete( # pylint: disable=inconsistent-return-statements ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyAssignment, response.json()) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace - @api_version_validation( - method_added_on="2026-01-01-preview", - params_added_on={ - "2026-01-01-preview": ["api_version", "subscription_id", "resource_group_name", "filter", "accept"] - }, - api_versions_list=["2026-01-01-preview"], - ) def list_for_resource_group( - self, resource_group_name: str, *, filter: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.PolicyEnrollment"]: - """Retrieves all policy enrollments that apply to a resource group. - - This operation retrieves the list of all policy enrollments associated with the given resource + self, + resource_group_name: str, + *, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any, + ) -> ItemPaged["_models.PolicyAssignment"]: + """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 'atExactScope()'. If $filter is not provided, the unfiltered list includes - all policy enrollments 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. + are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not + provided, the unfiltered list includes all policy assignments associated with the resource + group, including those that apply directly or apply from containing scopes, as well as any + applied to resources contained within the resource group. If $filter=atScope() is provided, the + returned list includes all policy assignments that apply to the resource group, which is + everything in the unfiltered list except those applied to resources contained within the + resource group. If $filter=atExactScope() is provided, the returned list only includes all + policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is + provided, the returned list includes all policy assignments of the policy definition whose id + is {value} that apply to the resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atScope()' or 'atExactScope()'. If $filter is not provided, no filtering is performed. If - $filter is not provided, the unfiltered list includes all policy enrollments associated with - the scope, including those that apply directly or from containing scopes. If $filter=atScope() - is provided, the returned list includes all policy enrollments that apply to the scope, which - is everything in the unfiltered list except those applied to sub-scopes contained within the - given scope. If $filter=atExactScope() is provided, the returned list only includes all policy - enrollments that apply at the given scope. Default value is None. + 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, + no filtering is performed. If $filter=atScope() is provided, the returned list only includes + all policy assignments that apply to the scope, which is everything in the unfiltered list + except those applied to sub scopes contained within the given scope. If $filter=atExactScope() + is provided, the returned list only includes all policy assignments that at the given scope. If + $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy + assignments of the policy definition whose id is {value}. Default value is None. :paramtype filter: str - :return: An iterator like instance of PolicyEnrollment - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyEnrollment] + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :keyword top: Maximum number of records to return. When the $top filter is not provided, it + will return 500 records. Default value is None. + :paramtype top: int + :return: An iterator like instance of PolicyAssignment + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.PolicyEnrollment]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.PolicyAssignment]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7353,10 +2931,12 @@ def list_for_resource_group( def prepare_request(next_link=None): if not next_link: - _request = build_policy_enrollments_list_for_resource_group_request( + _request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, + expand=expand, + top=top, api_version=self._config.api_version, headers=_headers, params=_params, @@ -7396,7 +2976,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.PolicyEnrollment], + List[_models.PolicyAssignment], deserialized.get("value", []), ) if cls: @@ -7425,40 +3005,52 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - @api_version_validation( - method_added_on="2026-01-01-preview", - params_added_on={"2026-01-01-preview": ["api_version", "management_group_id", "filter", "accept"]}, - api_versions_list=["2026-01-01-preview"], - ) def list_for_management_group( - self, management_group_id: str, *, filter: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.PolicyEnrollment"]: - """Retrieves all policy enrollments that apply to a management group. + self, + management_group_id: str, + *, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any, + ) -> ItemPaged["_models.PolicyAssignment"]: + """Retrieves all policy assignments that apply to a management group. - This operation retrieves the list of all policy enrollments applicable to the management group - that match the given $filter. Valid values for $filter are: 'atScope()' or 'atExactScope()'. If - $filter=atScope() is provided, the returned list includes all policy enrollments that are - assigned to the management group or the management group's ancestors. + This operation retrieves the list of all policy assignments applicable to the management group + that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or + 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes + all policy assignments that are assigned to the management group or the management group's + ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy + assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is + provided, the returned list includes all policy assignments of the policy definition whose id + is {value} that apply to the management group. :param management_group_id: The management group ID. Required. :type management_group_id: str :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atScope()' or 'atExactScope()'. If $filter is not provided, no filtering is performed. If - $filter is not provided, the unfiltered list includes all policy enrollments associated with - the scope, including those that apply directly or from containing scopes. If $filter=atScope() - is provided, the returned list includes all policy enrollments that apply to the scope, which - is everything in the unfiltered list except those applied to sub-scopes contained within the - given scope. If $filter=atExactScope() is provided, the returned list only includes all policy - enrollments that apply at the given scope. Default value is None. + 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, + no filtering is performed. If $filter=atScope() is provided, the returned list only includes + all policy assignments that apply to the scope, which is everything in the unfiltered list + except those applied to sub scopes contained within the given scope. If $filter=atExactScope() + is provided, the returned list only includes all policy assignments that at the given scope. If + $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy + assignments of the policy definition whose id is {value}. Default value is None. :paramtype filter: str - :return: An iterator like instance of PolicyEnrollment - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyEnrollment] + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :keyword top: Maximum number of records to return. When the $top filter is not provided, it + will return 500 records. Default value is None. + :paramtype top: int + :return: An iterator like instance of PolicyAssignment + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.PolicyEnrollment]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.PolicyAssignment]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7471,9 +3063,11 @@ def list_for_management_group( def prepare_request(next_link=None): if not next_link: - _request = build_policy_enrollments_list_for_management_group_request( + _request = build_policy_assignments_list_for_management_group_request( management_group_id=management_group_id, filter=filter, + expand=expand, + top=top, api_version=self._config.api_version, headers=_headers, params=_params, @@ -7513,7 +3107,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.PolicyEnrollment], + List[_models.PolicyAssignment], deserialized.get("value", []), ) if cls: @@ -7542,38 +3136,47 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - @api_version_validation( - method_added_on="2026-01-01-preview", - params_added_on={"2026-01-01-preview": ["api_version", "subscription_id", "filter", "accept"]}, - api_versions_list=["2026-01-01-preview"], - ) - def list(self, *, filter: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.PolicyEnrollment"]: - """Retrieves all policy enrollments that apply to a subscription. + def list( + self, *, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.PolicyAssignment"]: + """Retrieves all policy assignments that apply to a subscription. - This operation retrieves the list of all policy enrollments associated with the given - subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' - or 'atExactScope()'. If $filter is not provided, the unfiltered list includes all policy - enrollments 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. + This operation retrieves the list of all policy assignments associated with the given + subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', + 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the + unfiltered list includes all policy assignments associated with the subscription, including + those that apply directly or from management groups that contain the given subscription, as + well as any applied to objects contained within the subscription. If $filter=atScope() is + provided, the returned list includes all policy assignments that apply to the subscription, + which is everything in the unfiltered list except those applied to objects contained within the + subscription. If $filter=atExactScope() is provided, the returned list only includes all policy + assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, + the returned list includes all policy assignments of the policy definition whose id is {value}. :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atScope()' or 'atExactScope()'. If $filter is not provided, no filtering is performed. If - $filter is not provided, the unfiltered list includes all policy enrollments associated with - the scope, including those that apply directly or from containing scopes. If $filter=atScope() - is provided, the returned list includes all policy enrollments that apply to the scope, which - is everything in the unfiltered list except those applied to sub-scopes contained within the - given scope. If $filter=atExactScope() is provided, the returned list only includes all policy - enrollments that apply at the given scope. Default value is None. + 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, + no filtering is performed. If $filter=atScope() is provided, the returned list only includes + all policy assignments that apply to the scope, which is everything in the unfiltered list + except those applied to sub scopes contained within the given scope. If $filter=atExactScope() + is provided, the returned list only includes all policy assignments that at the given scope. If + $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy + assignments of the policy definition whose id is {value}. Default value is None. :paramtype filter: str - :return: An iterator like instance of PolicyEnrollment - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyEnrollment] + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :keyword top: Maximum number of records to return. When the $top filter is not provided, it + will return 500 records. Default value is None. + :paramtype top: int + :return: An iterator like instance of PolicyAssignment + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.PolicyEnrollment]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.PolicyAssignment]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7586,9 +3189,11 @@ def list(self, *, filter: Optional[str] = None, **kwargs: Any) -> ItemPaged["_mo def prepare_request(next_link=None): if not next_link: - _request = build_policy_enrollments_list_request( + _request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, filter=filter, + expand=expand, + top=top, api_version=self._config.api_version, headers=_headers, params=_params, @@ -7628,7 +3233,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.PolicyEnrollment], + List[_models.PolicyAssignment], deserialized.get("value", []), ) if cls: @@ -7657,23 +3262,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - @api_version_validation( - method_added_on="2026-01-01-preview", - params_added_on={ - "2026-01-01-preview": [ - "subscription_id", - "resource_group_name", - "resource_provider_namespace", - "parent_resource_path", - "resource_type", - "resource_name", - "api_version", - "filter", - "accept", - ] - }, - api_versions_list=["2026-01-01-preview"], - ) def list_for_resource( self, resource_group_name: str, @@ -7683,16 +3271,24 @@ def list_for_resource( resource_name: str, *, filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, **kwargs: Any, - ) -> ItemPaged["_models.PolicyEnrollment"]: - """Retrieves all policy enrollments that apply to a resource. + ) -> ItemPaged["_models.PolicyAssignment"]: + """Retrieves all policy assignments that apply to a resource. - This operation retrieves the list of all policy enrollments associated with the specified + 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 'atExactScope()'. If $filter is not provided, the - unfiltered list includes all policy enrollments associated with the resource, including those - that apply directly or from all containing scopes, as well as any applied to resources - contained within the resource. Three parameters plus the resource name are used to identify a + Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq + '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments + associated with the resource, including those that apply directly or from all containing + scopes, as well as any applied to resources contained within the resource. If $filter=atScope() + is provided, the returned list includes all policy assignments that apply to the resource, + which is everything in the unfiltered list except those applied to resources contained within + the resource. If $filter=atExactScope() is provided, the returned list only includes all policy + assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, + the returned list includes all policy assignments of the policy definition whose id is {value} + that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', @@ -7721,22 +3317,29 @@ def list_for_resource( :param resource_name: The name of the resource. Required. :type resource_name: str :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atScope()' or 'atExactScope()'. If $filter is not provided, no filtering is performed. If - $filter is not provided, the unfiltered list includes all policy enrollments associated with - the scope, including those that apply directly or from containing scopes. If $filter=atScope() - is provided, the returned list includes all policy enrollments that apply to the scope, which - is everything in the unfiltered list except those applied to sub-scopes contained within the - given scope. If $filter=atExactScope() is provided, the returned list only includes all policy - enrollments that apply at the given scope. Default value is None. + 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, + no filtering is performed. If $filter=atScope() is provided, the returned list only includes + all policy assignments that apply to the scope, which is everything in the unfiltered list + except those applied to sub scopes contained within the given scope. If $filter=atExactScope() + is provided, the returned list only includes all policy assignments that at the given scope. If + $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy + assignments of the policy definition whose id is {value}. Default value is None. :paramtype filter: str - :return: An iterator like instance of PolicyEnrollment - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyEnrollment] + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :keyword top: Maximum number of records to return. When the $top filter is not provided, it + will return 500 records. Default value is None. + :paramtype top: int + :return: An iterator like instance of PolicyAssignment + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.PolicyEnrollment]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.PolicyAssignment]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7749,7 +3352,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - _request = build_policy_enrollments_list_for_resource_request( + _request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -7757,6 +3360,8 @@ def prepare_request(next_link=None): resource_name=resource_name, subscription_id=self._config.subscription_id, filter=filter, + expand=expand, + top=top, api_version=self._config.api_version, headers=_headers, params=_params, @@ -7796,7 +3401,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.PolicyEnrollment], + List[_models.PolicyAssignment], deserialized.get("value", []), ) if cls: @@ -7825,14 +3430,14 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) -class PolicyExemptionsOperations: # pylint: disable=docstring-missing-param +class DataPolicyManifestsOperations: # pylint: disable=docstring-missing-param """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.resource.policy.PolicyClient`'s - :attr:`policy_exemptions` attribute. + :attr:`data_policy_manifests` attribute. """ def __init__(self, *args, **kwargs) -> None: @@ -7844,22 +3449,19 @@ def __init__(self, *args, **kwargs) -> None: @distributed_trace @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "scope", "policy_exemption_name", "accept"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], + method_added_on="2025-11-01", + params_added_on={"2025-11-01": ["api_version", "policy_mode", "accept"]}, + api_versions_list=["2025-11-01", "2025-12-01-preview", "2026-01-01-preview", "2026-06-01"], ) - def get(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> _models.PolicyExemption: - """Retrieves a policy exemption. + def get_by_policy_mode(self, policy_mode: str, **kwargs: Any) -> _models.DataPolicyManifest: + """Retrieves a data policy manifest. - This operation retrieves a single policy exemption, given its name and the scope it was created - at. + This operation retrieves the data policy manifest with the given policy mode. - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to get. Required. - :type policy_exemption_name: str - :return: PolicyExemption. The PolicyExemption is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption + :param policy_mode: The policy mode of the data policy manifest to get. Required. + :type policy_mode: str + :return: DataPolicyManifest. The DataPolicyManifest is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.DataPolicyManifest :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7873,11 +3475,10 @@ def get(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> _models. _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.PolicyExemption] = kwargs.pop("cls", None) + cls: ClsType[_models.DataPolicyManifest] = kwargs.pop("cls", None) - _request = build_policy_exemptions_get_request( - scope=scope, - policy_exemption_name=policy_exemption_name, + _request = build_data_policy_manifests_get_by_policy_mode_request( + policy_mode=policy_mode, api_version=self._config.api_version, headers=_headers, params=_params, @@ -7911,138 +3512,148 @@ def get(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> _models. if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.PolicyExemption, response.json()) + deserialized = _deserialize(_models.DataPolicyManifest, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def create_or_update( - self, - scope: str, - policy_exemption_name: str, - parameters: _models.PolicyExemption, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyExemption: - """Creates or updates a policy exemption. + @distributed_trace + @api_version_validation( + method_added_on="2025-11-01", + params_added_on={"2025-11-01": ["api_version", "filter", "accept"]}, + api_versions_list=["2025-11-01", "2025-12-01-preview", "2026-01-01-preview", "2026-06-01"], + ) + def list(self, *, filter: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.DataPolicyManifest"]: + """Retrieves data policy manifests. - This operation creates or updates a policy exemption with the given scope and name. Policy - exemptions apply to all resources contained within their scope. For example, when you create a - policy exemption at resource group scope for a policy assignment at the same or above level, - the exemption exempts to all applicable resources in the resource group. + This operation retrieves a list of all the data policy manifests that match the optional given + $filter. Valid values for $filter are: \\"$filter=namespace eq '{0}'\\". If $filter is not + provided, the unfiltered list includes all data policy manifests for data resource types. If + $filter=namespace is provided, the returned list only includes all data policy manifests that + have a namespace matching the provided value. - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to get. Required. - :type policy_exemption_name: str - :param parameters: Parameters for the policy exemption. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyExemption - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyExemption. The PolicyExemption is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption + :keyword filter: The filter to apply on the operation. Valid values for $filter are: + \\"namespace eq '{value}'\\". If $filter is not provided, no filtering is performed. If + $filter=namespace eq '{value}' is provided, the returned list only includes all data policy + manifests that have a namespace matching the provided value. Default value is None. + :paramtype filter: str + :return: An iterator like instance of DataPolicyManifest + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.DataPolicyManifest] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - @overload - def create_or_update( - self, - scope: str, - policy_exemption_name: str, - parameters: _types.PolicyExemption, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyExemption: - """Creates or updates a policy exemption. + cls: ClsType[List[_models.DataPolicyManifest]] = kwargs.pop("cls", None) - This operation creates or updates a policy exemption with the given scope and name. Policy - exemptions apply to all resources contained within their scope. For example, when you create a - policy exemption at resource group scope for a policy assignment at the same or above level, - the exemption exempts to all applicable resources in the resource group. + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to get. Required. - :type policy_exemption_name: str - :param parameters: Parameters for the policy exemption. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicyExemption - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyExemption. The PolicyExemption is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption - :raises ~azure.core.exceptions.HttpResponseError: - """ + def prepare_request(next_link=None): + if not next_link: - @overload - def create_or_update( - self, - scope: str, - policy_exemption_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyExemption: - """Creates or updates a policy exemption. + _request = build_data_policy_manifests_list_request( + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - This operation creates or updates a policy exemption with the given scope and name. Policy - exemptions apply to all resources contained within their scope. For example, when you create a - policy exemption at resource group scope for a policy assignment at the same or above level, - the exemption exempts to all applicable resources in the resource group. + return _request - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to get. Required. - :type policy_exemption_name: str - :param parameters: Parameters for the policy exemption. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyExemption. The PolicyExemption is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption - :raises ~azure.core.exceptions.HttpResponseError: - """ + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DataPolicyManifest], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) - @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": ["api_version", "scope", "policy_exemption_name", "content_type", "accept"] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def create_or_update( - self, - scope: str, - policy_exemption_name: str, - parameters: Union[_models.PolicyExemption, _types.PolicyExemption, IO[bytes]], - **kwargs: Any, - ) -> _models.PolicyExemption: - """Creates or updates a policy exemption. + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - This operation creates or updates a policy exemption with the given scope and name. Policy - exemptions apply to all resources contained within their scope. For example, when you create a - policy exemption at resource group scope for a policy assignment at the same or above level, - the exemption exempts to all applicable resources in the resource group. + return pipeline_response - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to get. Required. - :type policy_exemption_name: str - :param parameters: Parameters for the policy exemption. Is either a PolicyExemption type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyExemption or - ~azure.mgmt.resource.policy.types.PolicyExemption or IO[bytes] - :return: PolicyExemption. The PolicyExemption is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption + return ItemPaged(get_next, extract_data) + + +class PolicyDefinitionsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.PolicyClient`'s + :attr:`policy_definitions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: + """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. Required. + :type policy_definition_name: str + :return: PolicyDefinition. The PolicyDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -8053,25 +3664,15 @@ def create_or_update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyExemption] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.PolicyDefinition] = kwargs.pop("cls", None) - _request = build_policy_exemptions_create_or_update_request( - scope=scope, - policy_exemption_name=policy_exemption_name, - content_type=content_type, + _request = build_policy_definitions_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -8088,7 +3689,7 @@ def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: if _stream: try: response.read() # Load the body in memory and close the socket @@ -8104,7 +3705,7 @@ def create_or_update( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.PolicyExemption, response.json()) + deserialized = _deserialize(_models.PolicyDefinition, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -8112,118 +3713,95 @@ def create_or_update( return deserialized # type: ignore @overload - def update( + def create_or_update( self, - scope: str, - policy_exemption_name: str, - parameters: _models.PolicyExemptionUpdate, + policy_definition_name: str, + parameters: _models.PolicyDefinition, *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicyExemption: - """Updates a policy exemption. - - This operation updates a policy exemption with the given scope and name. + ) -> _models.PolicyDefinition: + """This operation creates or updates a policy definition in the given subscription with the given + name. - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to get. Required. - :type policy_exemption_name: str - :param parameters: Parameters for policy exemption patch request. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyExemptionUpdate + :param policy_definition_name: The name of the policy definition to get. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicyDefinition :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PolicyExemption. The PolicyExemption is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption + :return: PolicyDefinition. The PolicyDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( + def create_or_update( self, - scope: str, - policy_exemption_name: str, - parameters: _types.PolicyExemptionUpdate, + policy_definition_name: str, + parameters: _types.PolicyDefinition, *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicyExemption: - """Updates a policy exemption. - - This operation updates a policy exemption with the given scope and name. + ) -> _models.PolicyDefinition: + """This operation creates or updates a policy definition in the given subscription with the given + name. - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to get. Required. - :type policy_exemption_name: str - :param parameters: Parameters for policy exemption patch request. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicyExemptionUpdate + :param policy_definition_name: The name of the policy definition to get. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.types.PolicyDefinition :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PolicyExemption. The PolicyExemption is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption + :return: PolicyDefinition. The PolicyDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( + def create_or_update( self, - scope: str, - policy_exemption_name: str, + policy_definition_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicyExemption: - """Updates a policy exemption. - - This operation updates a policy exemption with the given scope and name. + ) -> _models.PolicyDefinition: + """This operation creates or updates a policy definition in the given subscription with the given + name. - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to get. Required. - :type policy_exemption_name: str - :param parameters: Parameters for policy exemption patch request. Required. + :param policy_definition_name: The name of the policy definition to get. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: PolicyExemption. The PolicyExemption is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption + :return: PolicyDefinition. The PolicyDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": ["api_version", "scope", "policy_exemption_name", "content_type", "accept"] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def update( + def create_or_update( self, - scope: str, - policy_exemption_name: str, - parameters: Union[_models.PolicyExemptionUpdate, _types.PolicyExemptionUpdate, IO[bytes]], + policy_definition_name: str, + parameters: Union[_models.PolicyDefinition, _types.PolicyDefinition, IO[bytes]], **kwargs: Any, - ) -> _models.PolicyExemption: - """Updates a policy exemption. - - This operation updates a policy exemption with the given scope and name. + ) -> _models.PolicyDefinition: + """This operation creates or updates a policy definition in the given subscription with the given + name. - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to get. Required. - :type policy_exemption_name: str - :param parameters: Parameters for policy exemption patch request. Is either a - PolicyExemptionUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyExemptionUpdate or - ~azure.mgmt.resource.policy.types.PolicyExemptionUpdate or IO[bytes] - :return: PolicyExemption. The PolicyExemption is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption + :param policy_definition_name: The name of the policy definition to get. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a PolicyDefinition type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicyDefinition or + ~azure.mgmt.resource.policy.types.PolicyDefinition or IO[bytes] + :return: PolicyDefinition. The PolicyDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -8238,7 +3816,7 @@ def update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyExemption] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _content = None @@ -8247,9 +3825,9 @@ def update( else: _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_policy_exemptions_update_request( - scope=scope, - policy_exemption_name=policy_exemption_name, + _request = build_policy_definitions_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -8269,7 +3847,7 @@ def update( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [201]: if _stream: try: response.read() # Load the body in memory and close the socket @@ -8285,7 +3863,7 @@ def update( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.PolicyExemption, response.json()) + deserialized = _deserialize(_models.PolicyDefinition, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -8293,24 +3871,13 @@ def update( return deserialized # type: ignore @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "scope", "policy_exemption_name"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) def delete( # pylint: disable=inconsistent-return-statements - self, scope: str, policy_exemption_name: str, **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: - """Deletes a policy exemption. - - This operation deletes a policy exemption, given its name and the scope it was created in. The - scope of a policy exemption is the part of its ID preceding - '/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'. + """This operation deletes the policy definition in the given subscription with the given name. - :param scope: The fully qualified Azure Resource manager identifier of the resource. Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to get. Required. - :type policy_exemption_name: str + :param policy_definition_name: The name of the policy definition to get. Required. + :type policy_definition_name: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -8328,9 +3895,9 @@ def delete( # pylint: disable=inconsistent-return-statements cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_policy_exemptions_delete_request( - scope=scope, - policy_exemption_name=policy_exemption_name, + _request = build_policy_definitions_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -8359,291 +3926,40 @@ def delete( # pylint: disable=inconsistent-return-statements return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": ["api_version", "subscription_id", "resource_group_name", "filter", "accept"] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def list_for_resource_group( - self, resource_group_name: str, *, filter: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.PolicyExemption"]: - """Retrieves all policy exemptions that apply to a resource group. - - This operation retrieves the list of all policy exemptions associated with the given resource - group in the given subscription that match the optional given $filter. Valid values for $filter - are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If - $filter is not provided, the unfiltered list includes all policy exemptions associated with the - resource group, including those that apply directly or apply from containing scopes, as well as - any applied to resources contained within the resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If - $filter is not provided, no filtering is performed. If $filter is not provided, the unfiltered - list includes all policy exemptions associated with the scope, including those that apply - directly or apply from containing scopes. If $filter=atScope() is provided, the returned list - only includes all policy exemptions that apply to the scope, which is everything in the - unfiltered list except those applied to sub scopes contained within the given scope. If - $filter=atExactScope() is provided, the returned list only includes all policy exemptions that - at the given scope. If $filter=excludeExpired() is provided, the returned list only includes - all policy exemptions that either haven't expired or didn't set expiration date. If - $filter=policyAssignmentId eq '{value}' is provided. the returned list only includes all policy - exemptions that are associated with the give policyAssignmentId. Default value is None. - :paramtype filter: str - :return: An iterator like instance of PolicyExemption - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyExemption] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicyExemption]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_exemptions_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicyExemption], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "management_group_id", "filter", "accept"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def list_for_management_group( - self, management_group_id: str, *, filter: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.PolicyExemption"]: - """Retrieves all policy exemptions that apply to a management group. - - This operation retrieves the list of all policy exemptions applicable to the management group - that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', - 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter=atScope() is provided, the - returned list includes all policy exemptions that are assigned to the management group or the - management group's ancestors. - - :param management_group_id: The management group ID. Required. - :type management_group_id: str - :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If - $filter is not provided, no filtering is performed. If $filter is not provided, the unfiltered - list includes all policy exemptions associated with the scope, including those that apply - directly or apply from containing scopes. If $filter=atScope() is provided, the returned list - only includes all policy exemptions that apply to the scope, which is everything in the - unfiltered list except those applied to sub scopes contained within the given scope. If - $filter=atExactScope() is provided, the returned list only includes all policy exemptions that - at the given scope. If $filter=excludeExpired() is provided, the returned list only includes - all policy exemptions that either haven't expired or didn't set expiration date. If - $filter=policyAssignmentId eq '{value}' is provided. the returned list only includes all policy - exemptions that are associated with the give policyAssignmentId. Default value is None. - :paramtype filter: str - :return: An iterator like instance of PolicyExemption - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyExemption] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicyExemption]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_exemptions_list_for_management_group_request( - management_group_id=management_group_id, - filter=filter, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicyExemption], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "subscription_id", "filter", "accept"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def list(self, *, filter: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.PolicyExemption"]: - """Retrieves all policy exemptions that apply to a subscription. - - This operation retrieves the list of all policy exemptions associated with the given - subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', - 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not - provided, the unfiltered list includes all policy exemptions associated with the subscription, - including those that apply directly or from management groups that contain the given - subscription, as well as any applied to objects contained within the subscription. + def list( + self, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.PolicyDefinition"]: + """This operation retrieves a list of all the policy definitions in a given subscription that + match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType + -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list + includes all policy definitions associated with the subscription, including those that apply + directly or from management groups that contain the given subscription. If + $filter=atExactScope() is provided, the returned list only includes all policy definitions that + at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list + only includes all policy definitions whose type match the {value}. Possible policyType values + are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, + the returned list only includes all policy definitions whose category match the {value}. :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If - $filter is not provided, no filtering is performed. If $filter is not provided, the unfiltered - list includes all policy exemptions associated with the scope, including those that apply - directly or apply from containing scopes. If $filter=atScope() is provided, the returned list - only includes all policy exemptions that apply to the scope, which is everything in the - unfiltered list except those applied to sub scopes contained within the given scope. If - $filter=atExactScope() is provided, the returned list only includes all policy exemptions that - at the given scope. If $filter=excludeExpired() is provided, the returned list only includes - all policy exemptions that either haven't expired or didn't set expiration date. If - $filter=policyAssignmentId eq '{value}' is provided. the returned list only includes all policy - exemptions that are associated with the give policyAssignmentId. Default value is None. + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy definitions whose type match + the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy + definitions whose category match the {value}. Default value is None. :paramtype filter: str - :return: An iterator like instance of PolicyExemption - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyExemption] + :keyword top: Maximum number of records to return. When the $top filter is not provided, it + will return 500 records. Default value is None. + :paramtype top: int + :return: An iterator like instance of PolicyDefinition + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.PolicyExemption]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.PolicyDefinition]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -8656,9 +3972,10 @@ def list(self, *, filter: Optional[str] = None, **kwargs: Any) -> ItemPaged["_mo def prepare_request(next_link=None): if not next_link: - _request = build_policy_exemptions_list_request( + _request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, filter=filter, + top=top, api_version=self._config.api_version, headers=_headers, params=_params, @@ -8698,7 +4015,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.PolicyExemption], + List[_models.PolicyDefinition], deserialized.get("value", []), ) if cls: @@ -8727,91 +4044,100 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": [ - "subscription_id", - "resource_group_name", - "resource_provider_namespace", - "parent_resource_path", - "resource_type", - "resource_name", - "api_version", - "filter", - "accept", - ] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - *, - filter: Optional[str] = None, - **kwargs: Any, - ) -> ItemPaged["_models.PolicyExemption"]: - """Retrieves all policy exemptions that apply to a resource. + def get_built_in(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: + """This operation retrieves the built-in policy definition with the given name. - This operation retrieves the list of all policy exemptions associated with the specified - resource in the given resource group and subscription that match the optional given $filter. - Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or - 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all - policy exemptions associated with the resource, including those that apply directly or from all - containing scopes, as well as any applied to resources contained within the resource. Three - parameters plus the resource name are used to identify a specific resource. If the resource is - not part of a parent resource (the more common case), the parent resource path should not be - provided (or provided as ''). For example a web app could be specified as - ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == - 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all - parameters should be provided. For example a virtual machine DNS name could be specified as - ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == - 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == - 'MyComputerName'). A convenient alternative to providing the namespace and type name separately - is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', - {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == - 'MyWebApp'). + :param policy_definition_name: The name of the built-in policy definition to get. Required. + :type policy_definition_name: str + :return: PolicyDefinition. The PolicyDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyDefinition] = kwargs.pop("cls", None) + + _request = build_policy_definitions_get_built_in_request( + policy_definition_name=policy_definition_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyDefinition, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_built_in( + self, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.PolicyDefinition"]: + """This operation retrieves a list of all the built-in policy definitions that match the optional + given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes + all built-in policy definitions whose type match the {value}. Possible policyType values are + NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the + returned list only includes all built-in policy definitions whose category match the {value}. - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :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). - Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource path. Use empty string if there is none. - Required. - :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). Required. - :type resource_type: str - :param resource_name: The name of the resource. Required. - :type resource_name: str :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If - $filter is not provided, no filtering is performed. If $filter is not provided, the unfiltered - list includes all policy exemptions associated with the scope, including those that apply - directly or apply from containing scopes. If $filter=atScope() is provided, the returned list - only includes all policy exemptions that apply to the scope, which is everything in the - unfiltered list except those applied to sub scopes contained within the given scope. If - $filter=atExactScope() is provided, the returned list only includes all policy exemptions that - at the given scope. If $filter=excludeExpired() is provided, the returned list only includes - all policy exemptions that either haven't expired or didn't set expiration date. If - $filter=policyAssignmentId eq '{value}' is provided. the returned list only includes all policy - exemptions that are associated with the give policyAssignmentId. Default value is None. + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy definitions whose type match + the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy + definitions whose category match the {value}. Default value is None. :paramtype filter: str - :return: An iterator like instance of PolicyExemption - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyExemption] + :keyword top: Maximum number of records to return. When the $top filter is not provided, it + will return 500 records. Default value is None. + :paramtype top: int + :return: An iterator like instance of PolicyDefinition + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.PolicyExemption]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.PolicyDefinition]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -8824,14 +4150,9 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - _request = build_policy_exemptions_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, + _request = build_policy_definitions_list_built_in_request( filter=filter, + top=top, api_version=self._config.api_version, headers=_headers, params=_params, @@ -8871,7 +4192,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.PolicyExemption], + List[_models.PolicyDefinition], deserialized.get("value", []), ) if cls: @@ -8899,39 +4220,19 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - -class PolicySetDefinitionsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.resource.policy.PolicyClient`'s - :attr:`policy_set_definitions` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PolicyClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def get( - self, policy_set_definition_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> _models.PolicySetDefinition: - """This operation retrieves the policy set definition in the given subscription with the given + def get_at_management_group( + self, management_group_id: str, policy_definition_name: str, **kwargs: Any + ) -> _models.PolicyDefinition: + """This operation retrieves the policy definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. Required. - :type policy_set_definition_name: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param policy_definition_name: The name of the policy definition to get. Required. + :type policy_definition_name: str + :return: PolicyDefinition. The PolicyDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -8945,12 +4246,11 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyDefinition] = kwargs.pop("cls", None) - _request = build_policy_set_definitions_get_request( - policy_set_definition_name=policy_set_definition_name, - subscription_id=self._config.subscription_id, - expand=expand, + _request = build_policy_definitions_get_at_management_group_request( + management_group_id=management_group_id, + policy_definition_name=policy_definition_name, api_version=self._config.api_version, headers=_headers, params=_params, @@ -8984,7 +4284,7 @@ def get( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.PolicySetDefinition, response.json()) + deserialized = _deserialize(_models.PolicyDefinition, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -8992,95 +4292,107 @@ def get( return deserialized # type: ignore @overload - def create_or_update( + def create_or_update_at_management_group( self, - policy_set_definition_name: str, - parameters: _models.PolicySetDefinition, + management_group_id: str, + policy_definition_name: str, + parameters: _models.PolicyDefinition, *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicySetDefinition: - """This operation creates or updates a policy set definition in the given subscription with the + ) -> _models.PolicyDefinition: + """This operation creates or updates a policy definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. Required. - :type policy_set_definition_name: str - :param parameters: The policy set definition properties. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param policy_definition_name: The name of the policy definition to get. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicyDefinition :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :return: PolicyDefinition. The PolicyDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( + def create_or_update_at_management_group( self, - policy_set_definition_name: str, - parameters: _types.PolicySetDefinition, + management_group_id: str, + policy_definition_name: str, + parameters: _types.PolicyDefinition, *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicySetDefinition: - """This operation creates or updates a policy set definition in the given subscription with the + ) -> _models.PolicyDefinition: + """This operation creates or updates a policy definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. Required. - :type policy_set_definition_name: str - :param parameters: The policy set definition properties. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicySetDefinition + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param policy_definition_name: The name of the policy definition to get. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.types.PolicyDefinition :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :return: PolicyDefinition. The PolicyDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( + def create_or_update_at_management_group( self, - policy_set_definition_name: str, + management_group_id: str, + policy_definition_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicySetDefinition: - """This operation creates or updates a policy set definition in the given subscription with the + ) -> _models.PolicyDefinition: + """This operation creates or updates a policy definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. Required. - :type policy_set_definition_name: str - :param parameters: The policy set definition properties. Required. + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param policy_definition_name: The name of the policy definition to get. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :return: PolicyDefinition. The PolicyDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create_or_update( + def create_or_update_at_management_group( self, - policy_set_definition_name: str, - parameters: Union[_models.PolicySetDefinition, _types.PolicySetDefinition, IO[bytes]], + management_group_id: str, + policy_definition_name: str, + parameters: Union[_models.PolicyDefinition, _types.PolicyDefinition, IO[bytes]], **kwargs: Any, - ) -> _models.PolicySetDefinition: - """This operation creates or updates a policy set definition in the given subscription with the + ) -> _models.PolicyDefinition: + """This operation creates or updates a policy definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. Required. - :type policy_set_definition_name: str - :param parameters: The policy set definition properties. Is either a PolicySetDefinition type - or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinition or - ~azure.mgmt.resource.policy.types.PolicySetDefinition or IO[bytes] - :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param policy_definition_name: The name of the policy definition to get. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a PolicyDefinition type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicyDefinition or + ~azure.mgmt.resource.policy.types.PolicyDefinition or IO[bytes] + :return: PolicyDefinition. The PolicyDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -9095,7 +4407,7 @@ def create_or_update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _content = None @@ -9104,9 +4416,9 @@ def create_or_update( else: _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_policy_set_definitions_create_or_update_request( - policy_set_definition_name=policy_set_definition_name, - subscription_id=self._config.subscription_id, + _request = build_policy_definitions_create_or_update_at_management_group_request( + management_group_id=management_group_id, + policy_definition_name=policy_definition_name, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -9126,7 +4438,7 @@ def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [201]: if _stream: try: response.read() # Load the body in memory and close the socket @@ -9142,7 +4454,7 @@ def create_or_update( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.PolicySetDefinition, response.json()) + deserialized = _deserialize(_models.PolicyDefinition, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -9150,197 +4462,17 @@ def create_or_update( return deserialized # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, policy_set_definition_name: str, **kwargs: Any + def delete_at_management_group( # pylint: disable=inconsistent-return-statements + self, management_group_id: str, policy_definition_name: str, **kwargs: Any ) -> None: - """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 get. Required. - :type policy_set_definition_name: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_policy_set_definitions_delete_request( - policy_set_definition_name=policy_set_definition_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def list( - self, *, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.PolicySetDefinition"]: - """This operation retrieves a list of all the policy set definitions in a given subscription that - match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType - -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list - includes all policy set definitions associated with the subscription, including those that - apply directly or from management groups that contain the given subscription. If - $filter=atExactScope() is provided, the returned list only includes all policy set definitions - that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned - list only includes all policy set definitions whose type match the {value}. Possible policyType - values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the - returned list only includes all policy set definitions whose category match the {value}. - - :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not - provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list - only includes all policy set definitions that at the given scope. If $filter='policyType -eq - {value}' is provided, the returned list only includes all policy set definitions whose type - match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If - $filter='category -eq {value}' is provided, the returned list only includes all policy set - definitions whose category match the {value}. Default value is None. - :paramtype filter: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :keyword top: Maximum number of records to return. When the $top filter is not provided, it - will return 500 records. Default value is None. - :paramtype top: int - :return: An iterator like instance of PolicySetDefinition - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.PolicySetDefinition]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_set_definitions_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - expand=expand, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicySetDefinition], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get_built_in( - self, policy_set_definition_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> _models.PolicySetDefinition: - """This operation retrieves the built-in policy set definition with the given name. + """This operation deletes the policy definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. Required. - :type policy_set_definition_name: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param policy_definition_name: The name of the policy definition to get. Required. + :type policy_definition_name: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -9354,11 +4486,11 @@ def get_built_in( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_policy_set_definitions_get_built_in_request( - policy_set_definition_name=policy_set_definition_name, - expand=expand, + _request = build_policy_definitions_delete_at_management_group_request( + management_group_id=management_group_id, + policy_definition_name=policy_definition_name, api_version=self._config.api_version, headers=_headers, params=_params, @@ -9368,20 +4500,14 @@ def get_built_in( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = _failsafe_deserialize( _models.ErrorResponse, @@ -9389,48 +4515,47 @@ def get_built_in( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicySetDefinition, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def list_built_in( - self, *, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.PolicySetDefinition"]: - """This operation retrieves a list of all the built-in policy set definitions that match the - optional given $filter. If $filter='category -eq {value}' is provided, the returned list only - includes all built-in policy set definitions whose category match the {value}. + def list_by_management_group( + self, management_group_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.PolicyDefinition"]: + """This operation retrieves a list of all the policy definitions in a given management group that + match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType + -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list + includes all policy definitions associated with the management group, including those that + apply directly or from management groups that contain the given management group. If + $filter=atExactScope() is provided, the returned list only includes all policy definitions that + at the given management group. If $filter='policyType -eq {value}' is provided, the returned + list only includes all policy definitions whose type match the {value}. Possible policyType + values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is + provided, the returned list only includes all policy definitions whose category match the + {value}. + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str :keyword filter: The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list - only includes all policy set definitions that at the given scope. If $filter='policyType -eq - {value}' is provided, the returned list only includes all policy set definitions whose type - match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If - $filter='category -eq {value}' is provided, the returned list only includes all policy set + only includes all policy definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy definitions whose type match + the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. Default value is None. :paramtype filter: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str :keyword top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :paramtype top: int - :return: An iterator like instance of PolicySetDefinition - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] + :return: An iterator like instance of PolicyDefinition + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.PolicySetDefinition]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.PolicyDefinition]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -9443,9 +4568,9 @@ def list_built_in( def prepare_request(next_link=None): if not next_link: - _request = build_policy_set_definitions_list_built_in_request( + _request = build_policy_definitions_list_by_management_group_request( + management_group_id=management_group_id, filter=filter, - expand=expand, top=top, api_version=self._config.api_version, headers=_headers, @@ -9486,7 +4611,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.PolicySetDefinition], + List[_models.PolicyDefinition], deserialized.get("value", []), ) if cls: @@ -9514,23 +4639,39 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) + +class PolicyDefinitionVersionsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.PolicyClient`'s + :attr:`policy_definition_versions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace - def get_at_management_group( - self, management_group_id: str, policy_set_definition_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> _models.PolicySetDefinition: - """This operation retrieves the policy set definition in the given management group with the given + def get( + self, policy_definition_name: str, policy_definition_version: str, **kwargs: Any + ) -> _models.PolicyDefinitionVersion: + """This operation retrieves the policy definition version in the given subscription with the given name. - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param policy_set_definition_name: The name of the policy set definition to get. Required. - :type policy_set_definition_name: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :param policy_definition_name: The name of the policy definition. Required. + :type policy_definition_name: str + :param policy_definition_version: The policy definition version. The format is x.y.z where x + is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :return: PolicyDefinitionVersion. The PolicyDefinitionVersion is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -9544,12 +4685,12 @@ def get_at_management_group( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyDefinitionVersion] = kwargs.pop("cls", None) - _request = build_policy_set_definitions_get_at_management_group_request( - management_group_id=management_group_id, - policy_set_definition_name=policy_set_definition_name, - expand=expand, + _request = build_policy_definition_versions_get_request( + policy_definition_name=policy_definition_name, + policy_definition_version=policy_definition_version, + subscription_id=self._config.subscription_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -9583,7 +4724,7 @@ def get_at_management_group( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.PolicySetDefinition, response.json()) + deserialized = _deserialize(_models.PolicyDefinitionVersion, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -9591,107 +4732,115 @@ def get_at_management_group( return deserialized # type: ignore @overload - def create_or_update_at_management_group( + def create_or_update( self, - management_group_id: str, - policy_set_definition_name: str, - parameters: _models.PolicySetDefinition, + policy_definition_name: str, + policy_definition_version: str, + parameters: _models.PolicyDefinitionVersion, *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicySetDefinition: - """This operation creates or updates a policy set definition in the given management group with - the given name. + ) -> _models.PolicyDefinitionVersion: + """This operation creates or updates a policy definition in the given subscription with the given + name. - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param policy_set_definition_name: The name of the policy set definition to get. Required. - :type policy_set_definition_name: str - :param parameters: The policy set definition properties. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :param policy_definition_name: The name of the policy definition. Required. + :type policy_definition_name: str + :param policy_definition_version: The policy definition version. The format is x.y.z where x + is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :param parameters: The policy definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :return: PolicyDefinitionVersion. The PolicyDefinitionVersion is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update_at_management_group( + def create_or_update( self, - management_group_id: str, - policy_set_definition_name: str, - parameters: _types.PolicySetDefinition, + policy_definition_name: str, + policy_definition_version: str, + parameters: _types.PolicyDefinitionVersion, *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicySetDefinition: - """This operation creates or updates a policy set definition in the given management group with - the given name. + ) -> _models.PolicyDefinitionVersion: + """This operation creates or updates a policy definition in the given subscription with the given + name. - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param policy_set_definition_name: The name of the policy set definition to get. Required. - :type policy_set_definition_name: str - :param parameters: The policy set definition properties. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicySetDefinition + :param policy_definition_name: The name of the policy definition. Required. + :type policy_definition_name: str + :param policy_definition_version: The policy definition version. The format is x.y.z where x + is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :param parameters: The policy definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.types.PolicyDefinitionVersion :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :return: PolicyDefinitionVersion. The PolicyDefinitionVersion is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update_at_management_group( + def create_or_update( self, - management_group_id: str, - policy_set_definition_name: str, + policy_definition_name: str, + policy_definition_version: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicySetDefinition: - """This operation creates or updates a policy set definition in the given management group with - the given name. + ) -> _models.PolicyDefinitionVersion: + """This operation creates or updates a policy definition in the given subscription with the given + name. - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param policy_set_definition_name: The name of the policy set definition to get. Required. - :type policy_set_definition_name: str - :param parameters: The policy set definition properties. Required. + :param policy_definition_name: The name of the policy definition. Required. + :type policy_definition_name: str + :param policy_definition_version: The policy definition version. The format is x.y.z where x + is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :param parameters: The policy definition properties. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :return: PolicyDefinitionVersion. The PolicyDefinitionVersion is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create_or_update_at_management_group( + def create_or_update( self, - management_group_id: str, - policy_set_definition_name: str, - parameters: Union[_models.PolicySetDefinition, _types.PolicySetDefinition, IO[bytes]], + policy_definition_name: str, + policy_definition_version: str, + parameters: Union[_models.PolicyDefinitionVersion, _types.PolicyDefinitionVersion, IO[bytes]], **kwargs: Any, - ) -> _models.PolicySetDefinition: - """This operation creates or updates a policy set definition in the given management group with - the given name. + ) -> _models.PolicyDefinitionVersion: + """This operation creates or updates a policy definition in the given subscription with the given + name. - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param policy_set_definition_name: The name of the policy set definition to get. Required. - :type policy_set_definition_name: str - :param parameters: The policy set definition properties. Is either a PolicySetDefinition type + :param policy_definition_name: The name of the policy definition. Required. + :type policy_definition_name: str + :param policy_definition_version: The policy definition version. The format is x.y.z where x + is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :param parameters: The policy definition properties. Is either a PolicyDefinitionVersion type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinition or - ~azure.mgmt.resource.policy.types.PolicySetDefinition or IO[bytes] - :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :type parameters: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion or + ~azure.mgmt.resource.policy.types.PolicyDefinitionVersion or IO[bytes] + :return: PolicyDefinitionVersion. The PolicyDefinitionVersion is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -9706,7 +4855,7 @@ def create_or_update_at_management_group( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyDefinitionVersion] = kwargs.pop("cls", None) content_type = content_type or "application/json" _content = None @@ -9715,9 +4864,10 @@ def create_or_update_at_management_group( else: _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_policy_set_definitions_create_or_update_at_management_group_request( - management_group_id=management_group_id, - policy_set_definition_name=policy_set_definition_name, + _request = build_policy_definition_versions_create_or_update_request( + policy_definition_name=policy_definition_name, + policy_definition_version=policy_definition_version, + subscription_id=self._config.subscription_id, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -9753,7 +4903,7 @@ def create_or_update_at_management_group( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.PolicySetDefinition, response.json()) + deserialized = _deserialize(_models.PolicyDefinitionVersion, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -9761,16 +4911,18 @@ def create_or_update_at_management_group( return deserialized # type: ignore @distributed_trace - def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, management_group_id: str, policy_set_definition_name: str, **kwargs: Any + def delete( # pylint: disable=inconsistent-return-statements + self, policy_definition_name: str, policy_definition_version: str, **kwargs: Any ) -> None: - """This operation deletes the policy set definition in the given management group with the given + """This operation deletes the policy definition version in the given subscription with the given name. - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param policy_set_definition_name: The name of the policy set definition to get. Required. - :type policy_set_definition_name: str + :param policy_definition_name: The name of the policy definition. Required. + :type policy_definition_name: str + :param policy_definition_version: The policy definition version. The format is x.y.z where x + is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -9788,9 +4940,10 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_policy_set_definitions_delete_at_management_group_request( - management_group_id=management_group_id, - policy_set_definition_name=policy_set_definition_name, + _request = build_policy_definition_versions_delete_request( + policy_definition_name=policy_definition_name, + policy_definition_version=policy_definition_version, + subscription_id=self._config.subscription_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -9819,53 +4972,202 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def list_by_management_group( - self, - management_group_id: str, - *, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any, - ) -> ItemPaged["_models.PolicySetDefinition"]: - """This operation retrieves a list of all the policy set definitions in a given management group - that match the optional given $filter. Valid values for $filter are: 'atExactScope()', - 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered - list includes all policy set definitions associated with the management group, including those - that apply directly or from management groups that contain the given management group. If - $filter=atExactScope() is provided, the returned list only includes all policy set definitions - that at the given management group. If $filter='policyType -eq {value}' is provided, the - returned list only includes all policy set definitions whose type match the {value}. Possible - policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is - provided, the returned list only includes all policy set definitions whose category match the - {value}. + def list( + self, policy_definition_name: str, *, top: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.PolicyDefinitionVersion"]: + """This operation retrieves a list of all the policy definition versions for the given policy + definition. - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :keyword filter: The filter to apply on the operation. Valid values for $filter are: - 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not - provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list - only includes all policy set definitions that at the given scope. If $filter='policyType -eq - {value}' is provided, the returned list only includes all policy set definitions whose type - match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If - $filter='category -eq {value}' is provided, the returned list only includes all policy set - definitions whose category match the {value}. Default value is None. - :paramtype filter: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str + :param policy_definition_name: The name of the policy definition. Required. + :type policy_definition_name: str :keyword top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :paramtype top: int - :return: An iterator like instance of PolicySetDefinition - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] + :return: An iterator like instance of PolicyDefinitionVersion + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinitionVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicyDefinitionVersion]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_policy_definition_versions_list_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyDefinitionVersion], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_built_in( + self, policy_definition_name: str, policy_definition_version: str, **kwargs: Any + ) -> _models.PolicyDefinitionVersion: + """This operation retrieves the built-in policy definition version with the given name. + + :param policy_definition_name: The name of the policy definition. Required. + :type policy_definition_name: str + :param policy_definition_version: The policy definition version. The format is x.y.z where x + is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :return: PolicyDefinitionVersion. The PolicyDefinitionVersion is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyDefinitionVersion] = kwargs.pop("cls", None) + + _request = build_policy_definition_versions_get_built_in_request( + policy_definition_name=policy_definition_name, + policy_definition_version=policy_definition_version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyDefinitionVersion, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_built_in( + self, policy_definition_name: str, *, top: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.PolicyDefinitionVersion"]: + """This operation retrieves a list of all the built-in policy definition versions for the given + policy definition. + + :param policy_definition_name: The name of the policy definition. Required. + :type policy_definition_name: str + :keyword top: Maximum number of records to return. When the $top filter is not provided, it + will return 500 records. Default value is None. + :paramtype top: int + :return: An iterator like instance of PolicyDefinitionVersion + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinitionVersion] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.PolicySetDefinition]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.PolicyDefinitionVersion]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -9878,10 +5180,8 @@ def list_by_management_group( def prepare_request(next_link=None): if not next_link: - _request = build_policy_set_definitions_list_by_management_group_request( - management_group_id=management_group_id, - filter=filter, - expand=expand, + _request = build_policy_definition_versions_list_built_in_request( + policy_definition_name=policy_definition_name, top=top, api_version=self._config.api_version, headers=_headers, @@ -9922,7 +5222,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.PolicySetDefinition], + List[_models.PolicyDefinitionVersion], deserialized.get("value", []), ) if cls: @@ -9950,49 +5250,24 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - -class PolicySetDefinitionVersionsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.resource.policy.PolicyClient`'s - :attr:`policy_set_definition_versions` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PolicyClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def get( - self, - policy_set_definition_name: str, - policy_definition_version: str, - *, - expand: Optional[str] = None, - **kwargs: Any, - ) -> _models.PolicySetDefinitionVersion: - """This operation retrieves the policy set definition version in the given subscription with the - given name and version. + def get_at_management_group( + self, management_group_name: str, policy_definition_name: str, policy_definition_version: str, **kwargs: Any + ) -> _models.PolicyDefinitionVersion: + """This operation retrieves the policy definition version in the given management group with the + given name. - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param policy_definition_name: The name of the policy definition. Required. + :type policy_definition_name: str + :param policy_definition_version: The policy definition version. The format is x.y.z where x + is the major version number, y is the minor version number, and z is the patch number. Required. :type policy_definition_version: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with - MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion + :return: PolicyDefinitionVersion. The PolicyDefinitionVersion is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -10006,13 +5281,12 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyDefinitionVersion] = kwargs.pop("cls", None) - _request = build_policy_set_definition_versions_get_request( - policy_set_definition_name=policy_set_definition_name, + _request = build_policy_definition_versions_get_at_management_group_request( + management_group_name=management_group_name, + policy_definition_name=policy_definition_name, policy_definition_version=policy_definition_version, - subscription_id=self._config.subscription_id, - expand=expand, api_version=self._config.api_version, headers=_headers, params=_params, @@ -10046,7 +5320,7 @@ def get( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.PolicySetDefinitionVersion, response.json()) + deserialized = _deserialize(_models.PolicyDefinitionVersion, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -10054,119 +5328,131 @@ def get( return deserialized # type: ignore @overload - def create_or_update( + def create_or_update_at_management_group( self, - policy_set_definition_name: str, + management_group_name: str, + policy_definition_name: str, policy_definition_version: str, - parameters: _models.PolicySetDefinitionVersion, + parameters: _models.PolicyDefinitionVersion, *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicySetDefinitionVersion: - """This operation creates or updates a policy set definition version in the given subscription - with the given name and version. + ) -> _models.PolicyDefinitionVersion: + """This operation creates or updates a policy definition version in the given management group + with the given name. - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param policy_definition_name: The name of the policy definition. Required. + :type policy_definition_name: str + :param policy_definition_version: The policy definition version. The format is x.y.z where x + is the major version number, y is the minor version number, and z is the patch number. Required. :type policy_definition_version: str - :param parameters: The policy set definition properties. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion + :param parameters: The policy definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with - MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion + :return: PolicyDefinitionVersion. The PolicyDefinitionVersion is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( + def create_or_update_at_management_group( self, - policy_set_definition_name: str, + management_group_name: str, + policy_definition_name: str, policy_definition_version: str, - parameters: _types.PolicySetDefinitionVersion, + parameters: _types.PolicyDefinitionVersion, *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicySetDefinitionVersion: - """This operation creates or updates a policy set definition version in the given subscription - with the given name and version. + ) -> _models.PolicyDefinitionVersion: + """This operation creates or updates a policy definition version in the given management group + with the given name. - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param policy_definition_name: The name of the policy definition. Required. + :type policy_definition_name: str + :param policy_definition_version: The policy definition version. The format is x.y.z where x + is the major version number, y is the minor version number, and z is the patch number. Required. :type policy_definition_version: str - :param parameters: The policy set definition properties. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicySetDefinitionVersion + :param parameters: The policy definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.types.PolicyDefinitionVersion :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with - MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion + :return: PolicyDefinitionVersion. The PolicyDefinitionVersion is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( + def create_or_update_at_management_group( self, - policy_set_definition_name: str, + management_group_name: str, + policy_definition_name: str, policy_definition_version: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicySetDefinitionVersion: - """This operation creates or updates a policy set definition version in the given subscription - with the given name and version. + ) -> _models.PolicyDefinitionVersion: + """This operation creates or updates a policy definition version in the given management group + with the given name. - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param policy_definition_name: The name of the policy definition. Required. + :type policy_definition_name: str + :param policy_definition_version: The policy definition version. The format is x.y.z where x + is the major version number, y is the minor version number, and z is the patch number. Required. :type policy_definition_version: str - :param parameters: The policy set definition properties. Required. + :param parameters: The policy definition properties. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with - MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion + :return: PolicyDefinitionVersion. The PolicyDefinitionVersion is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create_or_update( + def create_or_update_at_management_group( self, - policy_set_definition_name: str, + management_group_name: str, + policy_definition_name: str, policy_definition_version: str, - parameters: Union[_models.PolicySetDefinitionVersion, _types.PolicySetDefinitionVersion, IO[bytes]], + parameters: Union[_models.PolicyDefinitionVersion, _types.PolicyDefinitionVersion, IO[bytes]], **kwargs: Any, - ) -> _models.PolicySetDefinitionVersion: - """This operation creates or updates a policy set definition version in the given subscription - with the given name and version. + ) -> _models.PolicyDefinitionVersion: + """This operation creates or updates a policy definition version in the given management group + with the given name. - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param policy_definition_name: The name of the policy definition. Required. + :type policy_definition_name: str + :param policy_definition_version: The policy definition version. The format is x.y.z where x + is the major version number, y is the minor version number, and z is the patch number. Required. :type policy_definition_version: str - :param parameters: The policy set definition properties. Is either a PolicySetDefinitionVersion - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion or - ~azure.mgmt.resource.policy.types.PolicySetDefinitionVersion or IO[bytes] - :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with - MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion + :param parameters: The policy definition properties. Is either a PolicyDefinitionVersion type + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion or + ~azure.mgmt.resource.policy.types.PolicyDefinitionVersion or IO[bytes] + :return: PolicyDefinitionVersion. The PolicyDefinitionVersion is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -10181,7 +5467,7 @@ def create_or_update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyDefinitionVersion] = kwargs.pop("cls", None) content_type = content_type or "application/json" _content = None @@ -10190,10 +5476,10 @@ def create_or_update( else: _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_policy_set_definition_versions_create_or_update_request( - policy_set_definition_name=policy_set_definition_name, + _request = build_policy_definition_versions_create_or_update_at_management_group_request( + management_group_name=management_group_name, + policy_definition_name=policy_definition_name, policy_definition_version=policy_definition_version, - subscription_id=self._config.subscription_id, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -10229,7 +5515,7 @@ def create_or_update( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.PolicySetDefinitionVersion, response.json()) + deserialized = _deserialize(_models.PolicyDefinitionVersion, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -10237,16 +5523,18 @@ def create_or_update( return deserialized # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, policy_set_definition_name: str, policy_definition_version: str, **kwargs: Any + def delete_at_management_group( # pylint: disable=inconsistent-return-statements + self, management_group_name: str, policy_definition_name: str, policy_definition_version: str, **kwargs: Any ) -> None: - """This operation deletes the policy set definition version in the given subscription with the - given name and version. + """This operation deletes the policy definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param policy_definition_name: The name of the policy definition. Required. + :type policy_definition_name: str + :param policy_definition_version: The policy definition version. The format is x.y.z where x + is the major version number, y is the minor version number, and z is the patch number. Required. :type policy_definition_version: str :return: None @@ -10266,10 +5554,10 @@ def delete( # pylint: disable=inconsistent-return-statements cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_policy_set_definition_versions_delete_request( - policy_set_definition_name=policy_set_definition_name, + _request = build_policy_definition_versions_delete_at_management_group_request( + management_group_name=management_group_name, + policy_definition_name=policy_definition_name, policy_definition_version=policy_definition_version, - subscription_id=self._config.subscription_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -10298,30 +5586,29 @@ def delete( # pylint: disable=inconsistent-return-statements return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def list( - self, policy_set_definition_name: str, *, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.PolicySetDefinitionVersion"]: - """This operation retrieves a list of all the policy set definition versions for the given policy - set definition. - - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str + def list_by_management_group( + self, management_group_name: str, policy_definition_name: str, *, top: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.PolicyDefinitionVersion"]: + """This operation retrieves a list of all the policy definition versions for the given policy + definition in the given management group. + + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param policy_definition_name: The name of the policy definition. Required. + :type policy_definition_name: str :keyword top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :paramtype top: int - :return: An iterator like instance of PolicySetDefinitionVersion + :return: An iterator like instance of PolicyDefinitionVersion :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinitionVersion] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.PolicySetDefinitionVersion]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.PolicyDefinitionVersion]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -10334,10 +5621,9 @@ def list( def prepare_request(next_link=None): if not next_link: - _request = build_policy_set_definition_versions_list_request( - policy_set_definition_name=policy_set_definition_name, - subscription_id=self._config.subscription_id, - expand=expand, + _request = build_policy_definition_versions_list_by_management_group_request( + management_group_name=management_group_name, + policy_definition_name=policy_definition_name, top=top, api_version=self._config.api_version, headers=_headers, @@ -10378,7 +5664,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.PolicySetDefinitionVersion], + List[_models.PolicyDefinitionVersion], deserialized.get("value", []), ) if cls: @@ -10407,30 +5693,15 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def get_built_in( - self, - policy_set_definition_name: str, - policy_definition_version: str, - *, - expand: Optional[str] = None, - **kwargs: Any, - ) -> _models.PolicySetDefinitionVersion: - """This operation retrieves the built-in policy set definition version with the given name and - version. + def list_all_builtins(self, **kwargs: Any) -> _models.PolicyDefinitionVersionListResult: + """Lists all built-in policy definition versions. - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with - MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion + This operation lists all the built-in policy definition versions for all built-in policy + definitions. + + :return: PolicyDefinitionVersionListResult. The PolicyDefinitionVersionListResult is compatible + with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersionListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -10444,12 +5715,9 @@ def get_built_in( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyDefinitionVersionListResult] = kwargs.pop("cls", None) - _request = build_policy_set_definition_versions_get_built_in_request( - policy_set_definition_name=policy_set_definition_name, - policy_definition_version=policy_definition_version, - expand=expand, + _request = build_policy_definition_versions_list_all_builtins_request( api_version=self._config.api_version, headers=_headers, params=_params, @@ -10483,7 +5751,7 @@ def get_built_in( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.PolicySetDefinitionVersion, response.json()) + deserialized = _deserialize(_models.PolicyDefinitionVersionListResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -10491,31 +5759,89 @@ def get_built_in( return deserialized # type: ignore @distributed_trace - def list_built_in( - self, policy_set_definition_name: str, *, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.PolicySetDefinitionVersion"]: - """This operation retrieves a list of all the built-in policy set definition versions for the - given built-in policy set definition. + def list_all_at_management_group( + self, management_group_name: str, **kwargs: Any + ) -> _models.PolicyDefinitionVersionListResult: + """Lists all policy definition versions at management group scope. - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :keyword expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :paramtype expand: str - :keyword top: Maximum number of records to return. When the $top filter is not provided, it - will return 500 records. Default value is None. - :paramtype top: int - :return: An iterator like instance of PolicySetDefinitionVersion - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] + This operation lists all the policy definition versions for all policy definitions at the + management group scope. + + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :return: PolicyDefinitionVersionListResult. The PolicyDefinitionVersionListResult is compatible + with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersionListResult :raises ~azure.core.exceptions.HttpResponseError: """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.PolicySetDefinitionVersion]] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyDefinitionVersionListResult] = kwargs.pop("cls", None) + + _request = build_policy_definition_versions_list_all_at_management_group_request( + management_group_name=management_group_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyDefinitionVersionListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_all(self, **kwargs: Any) -> _models.PolicyDefinitionVersionListResult: + """Lists all policy definition versions within a subscription. + + This operation lists all the policy definition versions for all policy definitions within a + subscription. + :return: PolicyDefinitionVersionListResult. The PolicyDefinitionVersionListResult is compatible + with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersionListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -10524,109 +5850,86 @@ def list_built_in( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_policy_set_definition_versions_list_built_in_request( - policy_set_definition_name=policy_set_definition_name, - expand=expand, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + cls: ClsType[_models.PolicyDefinitionVersionListResult] = kwargs.pop("cls", None) - return _request + _request = build_policy_definition_versions_list_all_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.PolicySetDefinitionVersion], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, ) - response = pipeline_response.http_response + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyDefinitionVersionListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - return pipeline_response + return deserialized # type: ignore - return ItemPaged(get_next, extract_data) + +class PolicySetDefinitionsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.PolicyClient`'s + :attr:`policy_set_definitions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get_at_management_group( - self, - management_group_name: str, - policy_set_definition_name: str, - policy_definition_version: str, - *, - expand: Optional[str] = None, - **kwargs: Any, - ) -> _models.PolicySetDefinitionVersion: - """This operation retrieves the policy set definition version in the given management group with - the given name and version. + def get( + self, policy_set_definition_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> _models.PolicySetDefinition: + """This operation retrieves the policy set definition in the given subscription with the given + name. - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :param policy_set_definition_name: The name of the policy set definition. Required. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str :keyword expand: Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is None. :paramtype expand: str - :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with - MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion + :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -10640,12 +5943,11 @@ def get_at_management_group( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) - _request = build_policy_set_definition_versions_get_at_management_group_request( - management_group_name=management_group_name, + _request = build_policy_set_definitions_get_request( policy_set_definition_name=policy_set_definition_name, - policy_definition_version=policy_definition_version, + subscription_id=self._config.subscription_id, expand=expand, api_version=self._config.api_version, headers=_headers, @@ -10680,7 +5982,7 @@ def get_at_management_group( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.PolicySetDefinitionVersion, response.json()) + deserialized = _deserialize(_models.PolicySetDefinition, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -10688,135 +5990,173 @@ def get_at_management_group( return deserialized # type: ignore @overload - def create_or_update_at_management_group( + def create_or_update( self, - management_group_name: str, policy_set_definition_name: str, - policy_definition_version: str, - parameters: _models.PolicySetDefinitionVersion, + parameters: _models.PolicySetDefinition, *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicySetDefinitionVersion: - """This operation creates or updates a policy set definition version in the given management group - with the given name and version. + ) -> _models.PolicySetDefinition: + """This operation creates or updates a policy set definition in the given subscription with the + given name. - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :param policy_set_definition_name: The name of the policy set definition. Required. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :param parameters: The policy set definition version properties. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion + :param parameters: The policy set definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinition :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with - MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion + :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update_at_management_group( + def create_or_update( self, - management_group_name: str, policy_set_definition_name: str, - policy_definition_version: str, - parameters: _types.PolicySetDefinitionVersion, + parameters: _types.PolicySetDefinition, *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicySetDefinitionVersion: - """This operation creates or updates a policy set definition version in the given management group - with the given name and version. + ) -> _models.PolicySetDefinition: + """This operation creates or updates a policy set definition in the given subscription with the + given name. - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :param policy_set_definition_name: The name of the policy set definition. Required. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :param parameters: The policy set definition version properties. Required. - :type parameters: ~azure.mgmt.resource.policy.types.PolicySetDefinitionVersion + :param parameters: The policy set definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.types.PolicySetDefinition :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with - MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion + :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update_at_management_group( + def create_or_update( self, - management_group_name: str, policy_set_definition_name: str, - policy_definition_version: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicySetDefinitionVersion: - """This operation creates or updates a policy set definition version in the given management group - with the given name and version. + ) -> _models.PolicySetDefinition: + """This operation creates or updates a policy set definition in the given subscription with the + given name. - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :param policy_set_definition_name: The name of the policy set definition. Required. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :param parameters: The policy set definition version properties. Required. + :param parameters: The policy set definition properties. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with - MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion + :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create_or_update_at_management_group( + def create_or_update( self, - management_group_name: str, policy_set_definition_name: str, - policy_definition_version: str, - parameters: Union[_models.PolicySetDefinitionVersion, _types.PolicySetDefinitionVersion, IO[bytes]], + parameters: Union[_models.PolicySetDefinition, _types.PolicySetDefinition, IO[bytes]], **kwargs: Any, - ) -> _models.PolicySetDefinitionVersion: - """This operation creates or updates a policy set definition version in the given management group - with the given name and version. + ) -> _models.PolicySetDefinition: + """This operation creates or updates a policy set definition in the given subscription with the + given name. - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :param policy_set_definition_name: The name of the policy set definition. Required. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :param parameters: The policy set definition version properties. Is either a - PolicySetDefinitionVersion type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion or - ~azure.mgmt.resource.policy.types.PolicySetDefinitionVersion or IO[bytes] - :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with - MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion + :param parameters: The policy set definition properties. Is either a PolicySetDefinition type + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinition or + ~azure.mgmt.resource.policy.types.PolicySetDefinition or IO[bytes] + :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_policy_set_definitions_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicySetDefinition, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, policy_set_definition_name: str, **kwargs: Any + ) -> None: + """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 get. Required. + :type policy_set_definition_name: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -10827,26 +6167,15 @@ def create_or_update_at_management_group( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_policy_set_definition_versions_create_or_update_at_management_group_request( - management_group_name=management_group_name, + _request = build_policy_set_definitions_delete_request( policy_set_definition_name=policy_set_definition_name, - policy_definition_version=policy_definition_version, - content_type=content_type, + subscription_id=self._config.subscription_id, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -10855,20 +6184,14 @@ def create_or_update_at_management_group( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = _failsafe_deserialize( _models.ErrorResponse, @@ -10876,34 +6199,146 @@ def create_or_update_at_management_group( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicySetDefinitionVersion, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, None, {}) # type: ignore - return deserialized # type: ignore + @distributed_trace + def list( + self, *, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.PolicySetDefinition"]: + """This operation retrieves a list of all the policy set definitions in a given subscription that + match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType + -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list + includes all policy set definitions associated with the subscription, including those that + apply directly or from management groups that contain the given subscription. If + $filter=atExactScope() is provided, the returned list only includes all policy set definitions + that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned + list only includes all policy set definitions whose type match the {value}. Possible policyType + values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the + returned list only includes all policy set definitions whose category match the {value}. + + :keyword filter: The filter to apply on the operation. Valid values for $filter are: + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy set definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy set definitions whose type + match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy set + definitions whose category match the {value}. Default value is None. + :paramtype filter: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :keyword top: Maximum number of records to return. When the $top filter is not provided, it + will return 500 records. Default value is None. + :paramtype top: int + :return: An iterator like instance of PolicySetDefinition + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicySetDefinition]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_policy_set_definitions_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicySetDefinition], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) @distributed_trace - def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, management_group_name: str, policy_set_definition_name: str, policy_definition_version: str, **kwargs: Any - ) -> None: - """This operation deletes the policy set definition version in the given management group with the - given name and version. + def get_built_in( + self, policy_set_definition_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> _models.PolicySetDefinition: + """This operation retrieves the built-in policy set definition with the given name. - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :param policy_set_definition_name: The name of the policy set definition. Required. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :param policy_definition_version: The policy set definition version. The format is x.y.z where - x is the major version number, y is the minor version number, and z is the patch number. - Required. - :type policy_definition_version: str - :return: None - :rtype: None + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -10917,12 +6352,11 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) - _request = build_policy_set_definition_versions_delete_at_management_group_request( - management_group_name=management_group_name, + _request = build_policy_set_definitions_get_built_in_request( policy_set_definition_name=policy_set_definition_name, - policy_definition_version=policy_definition_version, + expand=expand, api_version=self._config.api_version, headers=_headers, params=_params, @@ -10932,14 +6366,20 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _failsafe_deserialize( _models.ErrorResponse, @@ -10947,27 +6387,33 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicySetDefinition, response.json()) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace - def list_by_management_group( - self, - management_group_name: str, - policy_set_definition_name: str, - *, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any, - ) -> ItemPaged["_models.PolicySetDefinitionVersion"]: - """This operation retrieves a list of all the policy set definition versions for the given policy - set definition in a given management group. + def list_built_in( + self, *, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.PolicySetDefinition"]: + """This operation retrieves a list of all the built-in policy set definitions that match the + optional given $filter. If $filter='category -eq {value}' is provided, the returned list only + includes all built-in policy set definitions whose category match the {value}. - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :param policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str + :keyword filter: The filter to apply on the operation. Valid values for $filter are: + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy set definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy set definitions whose type + match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy set + definitions whose category match the {value}. Default value is None. + :paramtype filter: str :keyword expand: Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is None. @@ -10975,15 +6421,14 @@ def list_by_management_group( :keyword top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :paramtype top: int - :return: An iterator like instance of PolicySetDefinitionVersion - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] + :return: An iterator like instance of PolicySetDefinition + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.PolicySetDefinitionVersion]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.PolicySetDefinition]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -10996,9 +6441,8 @@ def list_by_management_group( def prepare_request(next_link=None): if not next_link: - _request = build_policy_set_definition_versions_list_by_management_group_request( - management_group_name=management_group_name, - policy_set_definition_name=policy_set_definition_name, + _request = build_policy_set_definitions_list_built_in_request( + filter=filter, expand=expand, top=top, api_version=self._config.api_version, @@ -11040,7 +6484,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.PolicySetDefinitionVersion], + List[_models.PolicySetDefinition], deserialized.get("value", []), ) if cls: @@ -11069,15 +6513,22 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def list_all_builtins(self, **kwargs: Any) -> _models.PolicySetDefinitionVersionListResult: - """Lists all built-in policy set definition versions. - - This operation lists all the built-in policy set definition versions for all built-in policy - set definitions. + def get_at_management_group( + self, management_group_id: str, policy_set_definition_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> _models.PolicySetDefinition: + """This operation retrieves the policy set definition in the given management group with the given + name. - :return: PolicySetDefinitionVersionListResult. The PolicySetDefinitionVersionListResult is - compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersionListResult + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -11091,9 +6542,12 @@ def list_all_builtins(self, **kwargs: Any) -> _models.PolicySetDefinitionVersion _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) - _request = build_policy_set_definition_versions_list_all_builtins_request( + _request = build_policy_set_definitions_get_at_management_group_request( + management_group_id=management_group_id, + policy_set_definition_name=policy_set_definition_name, + expand=expand, api_version=self._config.api_version, headers=_headers, params=_params, @@ -11127,28 +6581,115 @@ def list_all_builtins(self, **kwargs: Any) -> _models.PolicySetDefinitionVersion if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.PolicySetDefinitionVersionListResult, response.json()) + deserialized = _deserialize(_models.PolicySetDefinition, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def list_all_at_management_group( - self, management_group_name: str, **kwargs: Any - ) -> _models.PolicySetDefinitionVersionListResult: - """Lists all policy set definition versions at management group scope. + @overload + def create_or_update_at_management_group( + self, + management_group_id: str, + policy_set_definition_name: str, + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.PolicySetDefinition: + """This operation creates or updates a policy set definition in the given management group with + the given name. - This operation lists all the policy set definition versions for all policy set definitions at - the management group scope. + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :return: PolicySetDefinitionVersionListResult. The PolicySetDefinitionVersionListResult is - compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersionListResult + @overload + def create_or_update_at_management_group( + self, + management_group_id: str, + policy_set_definition_name: str, + parameters: _types.PolicySetDefinition, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.PolicySetDefinition: + """This operation creates or updates a policy set definition in the given management group with + the given name. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.types.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_management_group( + self, + management_group_id: str, + policy_set_definition_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.PolicySetDefinition: + """This operation creates or updates a policy set definition in the given management group with + the given name. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_management_group( + self, + management_group_id: str, + policy_set_definition_name: str, + parameters: Union[_models.PolicySetDefinition, _types.PolicySetDefinition, IO[bytes]], + **kwargs: Any, + ) -> _models.PolicySetDefinition: + """This operation creates or updates a policy set definition in the given management group with + the given name. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Is either a PolicySetDefinition type + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinition or + ~azure.mgmt.resource.policy.types.PolicySetDefinition or IO[bytes] + :return: PolicySetDefinition. The PolicySetDefinition is compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -11159,14 +6700,25 @@ def list_all_at_management_group( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) - _request = build_policy_set_definition_versions_list_all_at_management_group_request( - management_group_name=management_group_name, + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_policy_set_definitions_create_or_update_at_management_group_request( + management_group_id=management_group_id, + policy_set_definition_name=policy_set_definition_name, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -11183,7 +6735,7 @@ def list_all_at_management_group( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: if _stream: try: response.read() # Load the body in memory and close the socket @@ -11199,7 +6751,7 @@ def list_all_at_management_group( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.PolicySetDefinitionVersionListResult, response.json()) + deserialized = _deserialize(_models.PolicySetDefinition, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -11207,17 +6759,112 @@ def list_all_at_management_group( return deserialized # type: ignore @distributed_trace - def list_all(self, **kwargs: Any) -> _models.PolicySetDefinitionVersionListResult: - """Lists all policy set definition versions within a subscription. + def delete_at_management_group( # pylint: disable=inconsistent-return-statements + self, management_group_id: str, policy_set_definition_name: str, **kwargs: Any + ) -> None: + """This operation deletes the policy set definition in the given management group with the given + name. - This operation lists all the policy set definition versions for all policy set definitions - within a subscription. + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - :return: PolicySetDefinitionVersionListResult. The PolicySetDefinitionVersionListResult is - compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersionListResult + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_policy_set_definitions_delete_at_management_group_request( + management_group_id=management_group_id, + policy_set_definition_name=policy_set_definition_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_management_group( + self, + management_group_id: str, + *, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any, + ) -> ItemPaged["_models.PolicySetDefinition"]: + """This operation retrieves a list of all the policy set definitions in a given management group + that match the optional given $filter. Valid values for $filter are: 'atExactScope()', + 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered + list includes all policy set definitions associated with the management group, including those + that apply directly or from management groups that contain the given management group. If + $filter=atExactScope() is provided, the returned list only includes all policy set definitions + that at the given management group. If $filter='policyType -eq {value}' is provided, the + returned list only includes all policy set definitions whose type match the {value}. Possible + policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is + provided, the returned list only includes all policy set definitions whose category match the + {value}. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :keyword filter: The filter to apply on the operation. Valid values for $filter are: + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy set definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy set definitions whose type + match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy set + definitions whose category match the {value}. Default value is None. + :paramtype filter: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :keyword top: Maximum number of records to return. When the $top filter is not provided, it + will return 500 records. Default value is None. + :paramtype top: int + :return: An iterator like instance of PolicySetDefinition + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicySetDefinition]] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -11226,62 +6873,90 @@ def list_all(self, **kwargs: Any) -> _models.PolicySetDefinitionVersionListResul } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} + def prepare_request(next_link=None): + if not next_link: - cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) + _request = build_policy_set_definitions_list_by_management_group_request( + management_group_id=management_group_id, + filter=filter, + expand=expand, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_policy_set_definition_versions_list_all_request( - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + return _request - response = pipeline_response.http_response + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicySetDefinition], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response = pipeline_response.http_response - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PolicySetDefinitionVersionListResult, response.json()) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return ItemPaged(get_next, extract_data) -class VariablesOperations: # pylint: disable=docstring-missing-param +class PolicySetDefinitionVersionsOperations: # pylint: disable=docstring-missing-param """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.resource.policy.PolicyClient`'s - :attr:`variables` attribute. + :attr:`policy_set_definition_versions` attribute. """ def __init__(self, *args, **kwargs) -> None: @@ -11292,21 +6967,30 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "subscription_id", "variable_name", "accept"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def get(self, variable_name: str, **kwargs: Any) -> _models.Variable: - """Retrieves a variable. - - This operation retrieves a single variable, given its name and the subscription it was created - at. + def get( + self, + policy_set_definition_name: str, + policy_definition_version: str, + *, + expand: Optional[str] = None, + **kwargs: Any, + ) -> _models.PolicySetDefinitionVersion: + """This operation retrieves the policy set definition version in the given subscription with the + given name and version. - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :return: Variable. The Variable is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.Variable + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -11320,11 +7004,13 @@ def get(self, variable_name: str, **kwargs: Any) -> _models.Variable: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Variable] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) - _request = build_variables_get_request( - variable_name=variable_name, + _request = build_policy_set_definition_versions_get_request( + policy_set_definition_name=policy_set_definition_name, + policy_definition_version=policy_definition_version, subscription_id=self._config.subscription_id, + expand=expand, api_version=self._config.api_version, headers=_headers, params=_params, @@ -11358,7 +7044,7 @@ def get(self, variable_name: str, **kwargs: Any) -> _models.Variable: if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Variable, response.json()) + deserialized = _deserialize(_models.PolicySetDefinitionVersion, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -11367,91 +7053,118 @@ def get(self, variable_name: str, **kwargs: Any) -> _models.Variable: @overload def create_or_update( - self, variable_name: str, parameters: _models.Variable, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Variable: - """Creates or updates a variable. - - This operation creates or updates a variable with the given subscription and name. Policy - variables can only be used by a policy definition at the scope they are created or below. + self, + policy_set_definition_name: str, + policy_definition_version: str, + parameters: _models.PolicySetDefinitionVersion, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given subscription + with the given name and version. - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param parameters: Parameters for the variable. Required. - :type parameters: ~azure.mgmt.resource.policy.models.Variable + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :param parameters: The policy set definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: Variable. The Variable is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.Variable + :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_or_update( - self, variable_name: str, parameters: _types.Variable, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Variable: - """Creates or updates a variable. - - This operation creates or updates a variable with the given subscription and name. Policy - variables can only be used by a policy definition at the scope they are created or below. + self, + policy_set_definition_name: str, + policy_definition_version: str, + parameters: _types.PolicySetDefinitionVersion, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given subscription + with the given name and version. - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param parameters: Parameters for the variable. Required. - :type parameters: ~azure.mgmt.resource.policy.types.Variable + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :param parameters: The policy set definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.types.PolicySetDefinitionVersion :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: Variable. The Variable is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.Variable + :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_or_update( - self, variable_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Variable: - """Creates or updates a variable. - - This operation creates or updates a variable with the given subscription and name. Policy - variables can only be used by a policy definition at the scope they are created or below. + self, + policy_set_definition_name: str, + policy_definition_version: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> _models.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given subscription + with the given name and version. - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param parameters: Parameters for the variable. Required. + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :param parameters: The policy set definition properties. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: Variable. The Variable is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.Variable + :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": ["api_version", "subscription_id", "variable_name", "content_type", "accept"] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) def create_or_update( - self, variable_name: str, parameters: Union[_models.Variable, _types.Variable, IO[bytes]], **kwargs: Any - ) -> _models.Variable: - """Creates or updates a variable. - - This operation creates or updates a variable with the given subscription and name. Policy - variables can only be used by a policy definition at the scope they are created or below. + self, + policy_set_definition_name: str, + policy_definition_version: str, + parameters: Union[_models.PolicySetDefinitionVersion, _types.PolicySetDefinitionVersion, IO[bytes]], + **kwargs: Any, + ) -> _models.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given subscription + with the given name and version. - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param parameters: Parameters for the variable. Is either a Variable type or a IO[bytes] type. + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. Required. - :type parameters: ~azure.mgmt.resource.policy.models.Variable or - ~azure.mgmt.resource.policy.types.Variable or IO[bytes] - :return: Variable. The Variable is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.Variable + :type policy_definition_version: str + :param parameters: The policy set definition properties. Is either a PolicySetDefinitionVersion + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion or + ~azure.mgmt.resource.policy.types.PolicySetDefinitionVersion or IO[bytes] + :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -11466,7 +7179,7 @@ def create_or_update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Variable] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) content_type = content_type or "application/json" _content = None @@ -11475,8 +7188,9 @@ def create_or_update( else: _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_variables_create_or_update_request( - variable_name=variable_name, + _request = build_policy_set_definition_versions_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + policy_definition_version=policy_definition_version, subscription_id=self._config.subscription_id, content_type=content_type, api_version=self._config.api_version, @@ -11513,7 +7227,7 @@ def create_or_update( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Variable, response.json()) + deserialized = _deserialize(_models.PolicySetDefinitionVersion, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -11521,20 +7235,18 @@ def create_or_update( return deserialized # type: ignore @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "subscription_id", "variable_name"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def delete(self, variable_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Deletes a variable. - - This operation deletes a variable, given its name and the subscription it was created in. The - scope of a variable is the part of its ID preceding - '/providers/Microsoft.Authorization/variables/{variableName}'. + def delete( # pylint: disable=inconsistent-return-statements + self, policy_set_definition_name: str, policy_definition_version: str, **kwargs: Any + ) -> None: + """This operation deletes the policy set definition version in the given subscription with the + given name and version. - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -11552,8 +7264,9 @@ def delete(self, variable_name: str, **kwargs: Any) -> None: # pylint: disable= cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_variables_delete_request( - variable_name=variable_name, + _request = build_policy_set_definition_versions_delete_request( + policy_set_definition_name=policy_set_definition_name, + policy_definition_version=policy_definition_version, subscription_id=self._config.subscription_id, api_version=self._config.api_version, headers=_headers, @@ -11583,24 +7296,30 @@ def delete(self, variable_name: str, **kwargs: Any) -> None: # pylint: disable= return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "subscription_id", "accept"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def list(self, **kwargs: Any) -> ItemPaged["_models.Variable"]: - """Retrieves all variables that are at this subscription level. - - This operation retrieves the list of all variables associated with the given subscription. + def list( + self, policy_set_definition_name: str, *, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.PolicySetDefinitionVersion"]: + """This operation retrieves a list of all the policy set definition versions for the given policy + set definition. - :return: An iterator like instance of Variable - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.Variable] + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :keyword top: Maximum number of records to return. When the $top filter is not provided, it + will return 500 records. Default value is None. + :paramtype top: int + :return: An iterator like instance of PolicySetDefinitionVersion + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Variable]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.PolicySetDefinitionVersion]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -11613,8 +7332,11 @@ def list(self, **kwargs: Any) -> ItemPaged["_models.Variable"]: def prepare_request(next_link=None): if not next_link: - _request = build_variables_list_request( + _request = build_policy_set_definition_versions_list_request( + policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, + expand=expand, + top=top, api_version=self._config.api_version, headers=_headers, params=_params, @@ -11654,7 +7376,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.Variable], + List[_models.PolicySetDefinitionVersion], deserialized.get("value", []), ) if cls: @@ -11683,287 +7405,30 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "management_group_id", "variable_name", "accept"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def get_at_management_group(self, management_group_id: str, variable_name: str, **kwargs: Any) -> _models.Variable: - """Retrieves a variable. - - This operation retrieves a single variable, given its name and the management group it was - created at. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :return: Variable. The Variable is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.Variable - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.Variable] = kwargs.pop("cls", None) - - _request = build_variables_get_at_management_group_request( - management_group_id=management_group_id, - variable_name=variable_name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.Variable, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - parameters: _models.Variable, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.Variable: - """Creates or updates a variable. - - This operation creates or updates a variable with the given management group and name. Policy - variables can only be used by a policy definition at the scope they are created or below. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param parameters: Parameters for the variable. Required. - :type parameters: ~azure.mgmt.resource.policy.models.Variable - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Variable. The Variable is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.Variable - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - parameters: _types.Variable, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.Variable: - """Creates or updates a variable. - - This operation creates or updates a variable with the given management group and name. Policy - variables can only be used by a policy definition at the scope they are created or below. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param parameters: Parameters for the variable. Required. - :type parameters: ~azure.mgmt.resource.policy.types.Variable - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Variable. The Variable is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.Variable - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update_at_management_group( + def get_built_in( self, - management_group_id: str, - variable_name: str, - parameters: IO[bytes], + policy_set_definition_name: str, + policy_definition_version: str, *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.Variable: - """Creates or updates a variable. - - This operation creates or updates a variable with the given management group and name. Policy - variables can only be used by a policy definition at the scope they are created or below. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param parameters: Parameters for the variable. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: Variable. The Variable is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.Variable - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": ["api_version", "management_group_id", "variable_name", "content_type", "accept"] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - parameters: Union[_models.Variable, _types.Variable, IO[bytes]], + expand: Optional[str] = None, **kwargs: Any, - ) -> _models.Variable: - """Creates or updates a variable. - - This operation creates or updates a variable with the given management group and name. Policy - variables can only be used by a policy definition at the scope they are created or below. + ) -> _models.PolicySetDefinitionVersion: + """This operation retrieves the built-in policy set definition version with the given name and + version. - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param parameters: Parameters for the variable. Is either a Variable type or a IO[bytes] type. + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. Required. - :type parameters: ~azure.mgmt.resource.policy.models.Variable or - ~azure.mgmt.resource.policy.types.Variable or IO[bytes] - :return: Variable. The Variable is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.Variable - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Variable] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_variables_create_or_update_at_management_group_request( - management_group_id=management_group_id, - variable_name=variable_name, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.Variable, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "management_group_id", "variable_name"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, management_group_id: str, variable_name: str, **kwargs: Any - ) -> None: - """Deletes a variable. - - This operation deletes a variable, given its name and the management group it was created in. - The scope of a variable is the part of its ID preceding - '/providers/Microsoft.Authorization/variables/{variableName}'. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :return: None - :rtype: None + :type policy_definition_version: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -11977,11 +7442,12 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) - _request = build_variables_delete_at_management_group_request( - management_group_id=management_group_id, - variable_name=variable_name, + _request = build_policy_set_definition_versions_get_built_in_request( + policy_set_definition_name=policy_set_definition_name, + policy_definition_version=policy_definition_version, + expand=expand, api_version=self._config.api_version, headers=_headers, params=_params, @@ -11991,14 +7457,20 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _failsafe_deserialize( _models.ErrorResponse, @@ -12006,30 +7478,41 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicySetDefinitionVersion, response.json()) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore - @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "management_group_id", "accept"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def list_for_management_group(self, management_group_id: str, **kwargs: Any) -> ItemPaged["_models.Variable"]: - """Retrieves all variables that are at this management group level. + return deserialized # type: ignore - This operation retrieves the list of all variables applicable to the management group. + @distributed_trace + def list_built_in( + self, policy_set_definition_name: str, *, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.PolicySetDefinitionVersion"]: + """This operation retrieves a list of all the built-in policy set definition versions for the + given built-in policy set definition. - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :return: An iterator like instance of Variable - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.Variable] + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :keyword top: Maximum number of records to return. When the $top filter is not provided, it + will return 500 records. Default value is None. + :paramtype top: int + :return: An iterator like instance of PolicySetDefinitionVersion + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Variable]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.PolicySetDefinitionVersion]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -12042,8 +7525,10 @@ def list_for_management_group(self, management_group_id: str, **kwargs: Any) -> def prepare_request(next_link=None): if not next_link: - _request = build_variables_list_for_management_group_request( - management_group_id=management_group_id, + _request = build_policy_set_definition_versions_list_built_in_request( + policy_set_definition_name=policy_set_definition_name, + expand=expand, + top=top, api_version=self._config.api_version, headers=_headers, params=_params, @@ -12083,7 +7568,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.Variable], + List[_models.PolicySetDefinitionVersion], deserialized.get("value", []), ) if cls: @@ -12111,44 +7596,35 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - -class VariableValuesOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.resource.policy.PolicyClient`'s - :attr:`variable_values` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: PolicyClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": ["api_version", "subscription_id", "variable_name", "variable_value_name", "accept"] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def get(self, variable_name: str, variable_value_name: str, **kwargs: Any) -> _models.VariableValue: - """Retrieves a variable value. - - This operation retrieves a single variable value; given its name, subscription it was created - at and the variable it's created for. - - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str - :return: VariableValue. The VariableValue is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + def get_at_management_group( + self, + management_group_name: str, + policy_set_definition_name: str, + policy_definition_version: str, + *, + expand: Optional[str] = None, + **kwargs: Any, + ) -> _models.PolicySetDefinitionVersion: + """This operation retrieves the policy set definition version in the given management group with + the given name and version. + + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -12162,12 +7638,13 @@ def get(self, variable_name: str, variable_value_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.VariableValue] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) - _request = build_variable_values_get_request( - variable_name=variable_name, - variable_value_name=variable_value_name, - subscription_id=self._config.subscription_id, + _request = build_policy_set_definition_versions_get_at_management_group_request( + management_group_name=management_group_name, + policy_set_definition_name=policy_set_definition_name, + policy_definition_version=policy_definition_version, + expand=expand, api_version=self._config.api_version, headers=_headers, params=_params, @@ -12201,7 +7678,7 @@ def get(self, variable_name: str, variable_value_name: str, **kwargs: Any) -> _m if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.VariableValue, response.json()) + deserialized = _deserialize(_models.PolicySetDefinitionVersion, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -12209,129 +7686,135 @@ def get(self, variable_name: str, variable_value_name: str, **kwargs: Any) -> _m return deserialized # type: ignore @overload - def create_or_update( + def create_or_update_at_management_group( self, - variable_name: str, - variable_value_name: str, - parameters: _models.VariableValue, + management_group_name: str, + policy_set_definition_name: str, + policy_definition_version: str, + parameters: _models.PolicySetDefinitionVersion, *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.VariableValue: - """Creates or updates a variable value. - - This operation creates or updates a variable value with the given subscription and name for a - given variable. Variable values are scoped to the variable for which they are created for. - - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str - :param parameters: Parameters for the variable value. Required. - :type parameters: ~azure.mgmt.resource.policy.models.VariableValue + ) -> _models.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given management group + with the given name and version. + + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :param parameters: The policy set definition version properties. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: VariableValue. The VariableValue is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( + def create_or_update_at_management_group( self, - variable_name: str, - variable_value_name: str, - parameters: _types.VariableValue, + management_group_name: str, + policy_set_definition_name: str, + policy_definition_version: str, + parameters: _types.PolicySetDefinitionVersion, *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.VariableValue: - """Creates or updates a variable value. - - This operation creates or updates a variable value with the given subscription and name for a - given variable. Variable values are scoped to the variable for which they are created for. - - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str - :param parameters: Parameters for the variable value. Required. - :type parameters: ~azure.mgmt.resource.policy.types.VariableValue + ) -> _models.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given management group + with the given name and version. + + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :param parameters: The policy set definition version properties. Required. + :type parameters: ~azure.mgmt.resource.policy.types.PolicySetDefinitionVersion :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: VariableValue. The VariableValue is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( + def create_or_update_at_management_group( self, - variable_name: str, - variable_value_name: str, + management_group_name: str, + policy_set_definition_name: str, + policy_definition_version: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.VariableValue: - """Creates or updates a variable value. - - This operation creates or updates a variable value with the given subscription and name for a - given variable. Variable values are scoped to the variable for which they are created for. + ) -> _models.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given management group + with the given name and version. - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str - :param parameters: Parameters for the variable value. Required. + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :param parameters: The policy set definition version properties. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: VariableValue. The VariableValue is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": [ - "api_version", - "subscription_id", - "variable_name", - "variable_value_name", - "content_type", - "accept", - ] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def create_or_update( + def create_or_update_at_management_group( self, - variable_name: str, - variable_value_name: str, - parameters: Union[_models.VariableValue, _types.VariableValue, IO[bytes]], + management_group_name: str, + policy_set_definition_name: str, + policy_definition_version: str, + parameters: Union[_models.PolicySetDefinitionVersion, _types.PolicySetDefinitionVersion, IO[bytes]], **kwargs: Any, - ) -> _models.VariableValue: - """Creates or updates a variable value. - - This operation creates or updates a variable value with the given subscription and name for a - given variable. Variable values are scoped to the variable for which they are created for. + ) -> _models.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given management group + with the given name and version. - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str - :param parameters: Parameters for the variable value. Is either a VariableValue type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.VariableValue or - ~azure.mgmt.resource.policy.types.VariableValue or IO[bytes] - :return: VariableValue. The VariableValue is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str + :param parameters: The policy set definition version properties. Is either a + PolicySetDefinitionVersion type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion or + ~azure.mgmt.resource.policy.types.PolicySetDefinitionVersion or IO[bytes] + :return: PolicySetDefinitionVersion. The PolicySetDefinitionVersion is compatible with + MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -12346,7 +7829,7 @@ def create_or_update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VariableValue] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) content_type = content_type or "application/json" _content = None @@ -12355,10 +7838,10 @@ def create_or_update( else: _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_variable_values_create_or_update_request( - variable_name=variable_name, - variable_value_name=variable_value_name, - subscription_id=self._config.subscription_id, + _request = build_policy_set_definition_versions_create_or_update_at_management_group_request( + management_group_name=management_group_name, + policy_set_definition_name=policy_set_definition_name, + policy_definition_version=policy_definition_version, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -12394,7 +7877,7 @@ def create_or_update( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.VariableValue, response.json()) + deserialized = _deserialize(_models.PolicySetDefinitionVersion, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -12402,26 +7885,21 @@ def create_or_update( return deserialized # type: ignore @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": ["api_version", "subscription_id", "variable_name", "variable_value_name"] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def delete( # pylint: disable=inconsistent-return-statements - self, variable_name: str, variable_value_name: str, **kwargs: Any + def delete_at_management_group( # pylint: disable=inconsistent-return-statements + self, management_group_name: str, policy_set_definition_name: str, policy_definition_version: str, **kwargs: Any ) -> None: - """Deletes a variable value. - - This operation deletes a variable value, given its name, the subscription it was created in, - and the variable it belongs to. The scope of a variable value is the part of its ID preceding - '/providers/Microsoft.Authorization/variables/{variableName}'. + """This operation deletes the policy set definition version in the given management group with the + given name and version. - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param policy_definition_version: The policy set definition version. The format is x.y.z where + x is the major version number, y is the minor version number, and z is the patch number. + Required. + :type policy_definition_version: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -12439,10 +7917,10 @@ def delete( # pylint: disable=inconsistent-return-statements cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_variable_values_delete_request( - variable_name=variable_name, - variable_value_name=variable_value_name, - subscription_id=self._config.subscription_id, + _request = build_policy_set_definition_versions_delete_at_management_group_request( + management_group_name=management_group_name, + policy_set_definition_name=policy_set_definition_name, + policy_definition_version=policy_definition_version, api_version=self._config.api_version, headers=_headers, params=_params, @@ -12471,27 +7949,39 @@ def delete( # pylint: disable=inconsistent-return-statements return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "subscription_id", "variable_name", "accept"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def list(self, variable_name: str, **kwargs: Any) -> ItemPaged["_models.VariableValue"]: - """List variable values for a variable. - - This operation retrieves the list of all variable values associated with the given variable - that is at a subscription level. + def list_by_management_group( + self, + management_group_name: str, + policy_set_definition_name: str, + *, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any, + ) -> ItemPaged["_models.PolicySetDefinitionVersion"]: + """This operation retrieves a list of all the policy set definition versions for the given policy + set definition in a given management group. - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :return: An iterator like instance of VariableValue - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.VariableValue] + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :keyword expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :paramtype expand: str + :keyword top: Maximum number of records to return. When the $top filter is not provided, it + will return 500 records. Default value is None. + :paramtype top: int + :return: An iterator like instance of PolicySetDefinitionVersion + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.VariableValue]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.PolicySetDefinitionVersion]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -12504,9 +7994,11 @@ def list(self, variable_name: str, **kwargs: Any) -> ItemPaged["_models.Variable def prepare_request(next_link=None): if not next_link: - _request = build_variable_values_list_request( - variable_name=variable_name, - subscription_id=self._config.subscription_id, + _request = build_policy_set_definition_versions_list_by_management_group_request( + management_group_name=management_group_name, + policy_set_definition_name=policy_set_definition_name, + expand=expand, + top=top, api_version=self._config.api_version, headers=_headers, params=_params, @@ -12546,7 +8038,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.VariableValue], + List[_models.PolicySetDefinitionVersion], deserialized.get("value", []), ) if cls: @@ -12575,35 +8067,15 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": [ - "api_version", - "management_group_id", - "variable_name", - "variable_value_name", - "accept", - ] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def get_at_management_group( - self, management_group_id: str, variable_name: str, variable_value_name: str, **kwargs: Any - ) -> _models.VariableValue: - """Retrieves a variable value. + def list_all_builtins(self, **kwargs: Any) -> _models.PolicySetDefinitionVersionListResult: + """Lists all built-in policy set definition versions. - This operation retrieves a single variable value; given its name, management group it was - created at and the variable it's created for. + This operation lists all the built-in policy set definition versions for all built-in policy + set definitions. - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str - :return: VariableValue. The VariableValue is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :return: PolicySetDefinitionVersionListResult. The PolicySetDefinitionVersionListResult is + compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersionListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -12617,12 +8089,9 @@ def get_at_management_group( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.VariableValue] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) - _request = build_variable_values_get_at_management_group_request( - management_group_id=management_group_id, - variable_name=variable_name, - variable_value_name=variable_value_name, + _request = build_policy_set_definition_versions_list_all_builtins_request( api_version=self._config.api_version, headers=_headers, params=_params, @@ -12656,149 +8125,28 @@ def get_at_management_group( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.VariableValue, response.json()) + deserialized = _deserialize(_models.PolicySetDefinitionVersionListResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - variable_value_name: str, - parameters: _models.VariableValue, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.VariableValue: - """Creates or updates a variable value. - - This operation creates or updates a variable value with the given management group and name for - a given variable. Variable values are scoped to the variable for which they are created for. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str - :param parameters: Parameters for the variable value. Required. - :type parameters: ~azure.mgmt.resource.policy.models.VariableValue - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: VariableValue. The VariableValue is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.VariableValue - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - variable_value_name: str, - parameters: _types.VariableValue, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.VariableValue: - """Creates or updates a variable value. - - This operation creates or updates a variable value with the given management group and name for - a given variable. Variable values are scoped to the variable for which they are created for. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str - :param parameters: Parameters for the variable value. Required. - :type parameters: ~azure.mgmt.resource.policy.types.VariableValue - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: VariableValue. The VariableValue is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.VariableValue - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - variable_value_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.VariableValue: - """Creates or updates a variable value. - - This operation creates or updates a variable value with the given management group and name for - a given variable. Variable values are scoped to the variable for which they are created for. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str - :param parameters: Parameters for the variable value. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: VariableValue. The VariableValue is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.VariableValue - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": [ - "api_version", - "management_group_id", - "variable_name", - "variable_value_name", - "content_type", - "accept", - ] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - variable_value_name: str, - parameters: Union[_models.VariableValue, _types.VariableValue, IO[bytes]], - **kwargs: Any, - ) -> _models.VariableValue: - """Creates or updates a variable value. + def list_all_at_management_group( + self, management_group_name: str, **kwargs: Any + ) -> _models.PolicySetDefinitionVersionListResult: + """Lists all policy set definition versions at management group scope. - This operation creates or updates a variable value with the given management group and name for - a given variable. Variable values are scoped to the variable for which they are created for. + This operation lists all the policy set definition versions for all policy set definitions at + the management group scope. - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str - :param parameters: Parameters for the variable value. Is either a VariableValue type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.VariableValue or - ~azure.mgmt.resource.policy.types.VariableValue or IO[bytes] - :return: VariableValue. The VariableValue is compatible with MutableMapping - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :return: PolicySetDefinitionVersionListResult. The PolicySetDefinitionVersionListResult is + compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersionListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -12809,26 +8157,14 @@ def create_or_update_at_management_group( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VariableValue] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) - _request = build_variable_values_create_or_update_at_management_group_request( - management_group_id=management_group_id, - variable_name=variable_name, - variable_value_name=variable_value_name, - content_type=content_type, + _request = build_policy_set_definition_versions_list_all_at_management_group_request( + management_group_name=management_group_name, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -12845,7 +8181,7 @@ def create_or_update_at_management_group( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: if _stream: try: response.read() # Load the body in memory and close the socket @@ -12861,7 +8197,7 @@ def create_or_update_at_management_group( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.VariableValue, response.json()) + deserialized = _deserialize(_models.PolicySetDefinitionVersionListResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -12869,30 +8205,15 @@ def create_or_update_at_management_group( return deserialized # type: ignore @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={ - "2025-12-01-preview": ["api_version", "management_group_id", "variable_name", "variable_value_name"] - }, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, management_group_id: str, variable_name: str, variable_value_name: str, **kwargs: Any - ) -> None: - """Deletes a variable value. + def list_all(self, **kwargs: Any) -> _models.PolicySetDefinitionVersionListResult: + """Lists all policy set definition versions within a subscription. - This operation deletes a variable value, given its name, the management group it was created - in, and the variable it belongs to. The scope of a variable value is the part of its ID - preceding '/providers/Microsoft.Authorization/variables/{variableName}'. + This operation lists all the policy set definition versions for all policy set definitions + within a subscription. - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param variable_value_name: The name of the variable value to operate on. Required. - :type variable_value_name: str - :return: None - :rtype: None + :return: PolicySetDefinitionVersionListResult. The PolicySetDefinitionVersionListResult is + compatible with MutableMapping + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersionListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -12906,12 +8227,10 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) - _request = build_variable_values_delete_at_management_group_request( - management_group_id=management_group_id, - variable_name=variable_name, - variable_value_name=variable_value_name, + _request = build_policy_set_definition_versions_list_all_request( + subscription_id=self._config.subscription_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -12921,14 +8240,20 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _failsafe_deserialize( _models.ErrorResponse, @@ -12936,116 +8261,15 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - @api_version_validation( - method_added_on="2025-12-01-preview", - params_added_on={"2025-12-01-preview": ["api_version", "management_group_id", "variable_name", "accept"]}, - api_versions_list=["2025-12-01-preview", "2026-01-01-preview"], - ) - def list_for_management_group( - self, management_group_id: str, variable_name: str, **kwargs: Any - ) -> ItemPaged["_models.VariableValue"]: - """List variable values at management group level. - - This operation retrieves the list of all variable values applicable the variable indicated at - the management group scope. - - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :return: An iterator like instance of VariableValue - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.VariableValue] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.VariableValue]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_variable_values_list_for_management_group_request( - management_group_id=management_group_id, - variable_name=variable_name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.VariableValue], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicySetDefinitionVersionListResult, response.json()) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - return ItemPaged(get_next, extract_data) + return deserialized # type: ignore class PolicyTokensOperations: # pylint: disable=docstring-missing-param diff --git a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/types.py b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/types.py index 9b61a20b2a77..9da263002c62 100644 --- a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/types.py +++ b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/types.py @@ -1,4 +1,4 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -12,12 +12,9 @@ if TYPE_CHECKING: from .models import ( - AssignmentScopeValidation, AssignmentType, CreatedByType, EnforcementMode, - ExemptionCategory, - ExemptionManagementMode, OverrideKind, ParameterType, PolicyType, @@ -672,230 +669,6 @@ class PolicyDefinitionVersionProperties(TypedDict, total=False): enforcement evaluation.""" -class PolicyEnrollment(ExtensionResource): - """The policy enrollment. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar systemData: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype systemData: "SystemData" - :ivar properties: The properties of the policy enrollment. - :vartype properties: "PolicyEnrollmentProperties" - :ivar eTag: The ETag for the policy enrollment. - :vartype eTag: str - """ - - properties: "PolicyEnrollmentProperties" - """The properties of the policy enrollment.""" - eTag: str - """The ETag for the policy enrollment.""" - - -class PolicyEnrollmentProperties(TypedDict, total=False): - """The policy enrollment properties. - - :ivar policyAssignmentId: The ID of the policy assignment that is being enrolled. Required. - :vartype policyAssignmentId: str - :ivar policyAssignmentInstanceId: The policy assignment instance ID associated with this - enrollment. The value is set to the instance ID of the policy assignment the policyAssignmentId - references when the enrollment is created or updated. The format is a GUID string. - :vartype policyAssignmentInstanceId: str - :ivar policyDefinitionReferenceIds: The policy definition reference IDs for policy definitions - in an assigned policy set definition. These IDs correspond to a subset of - ``policyDefinitions[*].policyDefinitionReferenceId`` in the policy set definition. When - specified and not empty, only the referenced policy definitions will be enrolled to. Otherwise, - the entire policy set is enrolled to. - :vartype policyDefinitionReferenceIds: list[str] - :ivar displayName: The display name of the policy enrollment. - :vartype displayName: str - :ivar description: The description of the policy enrollment. - :vartype description: str - :ivar metadata: The policy enrollment metadata. Metadata is an open ended object and is - typically a collection of key value pairs. - :vartype metadata: Any - :ivar assignmentScopeValidation: The option whether to validate the enrollment is at or under - the assignment scope. Known values are: "Default" and "DoNotValidate". - :vartype assignmentScopeValidation: Union[str, "AssignmentScopeValidation"] - :ivar resourceSelectors: The resource selector list to filter policies by resource properties. - :vartype resourceSelectors: list["ResourceSelector"] - """ - - policyAssignmentId: Required[str] - """The ID of the policy assignment that is being enrolled. Required.""" - policyAssignmentInstanceId: str - """The policy assignment instance ID associated with this enrollment. The value is set to the - instance ID of the policy assignment the policyAssignmentId references when the enrollment is - created or updated. The format is a GUID string.""" - policyDefinitionReferenceIds: list[str] - """The policy definition reference IDs for policy definitions in an assigned policy set - definition. These IDs correspond to a subset of - ``policyDefinitions[*].policyDefinitionReferenceId`` in the policy set definition. When - specified and not empty, only the referenced policy definitions will be enrolled to. Otherwise, - the entire policy set is enrolled to.""" - displayName: str - """The display name of the policy enrollment.""" - description: str - """The description of the policy enrollment.""" - metadata: Any - """The policy enrollment metadata. Metadata is an open ended object and is typically a collection - of key value pairs.""" - assignmentScopeValidation: Union[str, "AssignmentScopeValidation"] - """The option whether to validate the enrollment is at or under the assignment scope. Known values - are: \"Default\" and \"DoNotValidate\".""" - resourceSelectors: list["ResourceSelector"] - """The resource selector list to filter policies by resource properties.""" - - -class PolicyEnrollmentUpdate(TypedDict, total=False): - """The policy enrollment for Patch request. - - :ivar properties: The policy enrollment properties for Patch request. - :vartype properties: "PolicyEnrollmentUpdateProperties" - """ - - properties: "PolicyEnrollmentUpdateProperties" - """The policy enrollment properties for Patch request.""" - - -class PolicyEnrollmentUpdateProperties(TypedDict, total=False): - """The policy enrollment properties for Patch request. - - :ivar assignmentScopeValidation: The option whether to validate the enrollment is at or under - the assignment scope. Known values are: "Default" and "DoNotValidate". - :vartype assignmentScopeValidation: Union[str, "AssignmentScopeValidation"] - :ivar resourceSelectors: The resource selector list to filter policies by resource properties. - :vartype resourceSelectors: list["ResourceSelector"] - """ - - assignmentScopeValidation: Union[str, "AssignmentScopeValidation"] - """The option whether to validate the enrollment is at or under the assignment scope. Known values - are: \"Default\" and \"DoNotValidate\".""" - resourceSelectors: list["ResourceSelector"] - """The resource selector list to filter policies by resource properties.""" - - -class PolicyExemption(ExtensionResource): - """The policy exemption. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar systemData: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype systemData: "SystemData" - :ivar properties: Properties for the policy exemption. - :vartype properties: "PolicyExemptionProperties" - """ - - properties: "PolicyExemptionProperties" - """Properties for the policy exemption.""" - - -class PolicyExemptionProperties(TypedDict, total=False): - """The policy exemption properties. - - :ivar policyAssignmentId: The ID of the policy assignment that is being exempted. Required. - :vartype policyAssignmentId: str - :ivar policyDefinitionReferenceIds: The policy definition reference ID list when the associated - policy assignment is an assignment of a policy set definition. - :vartype policyDefinitionReferenceIds: list[str] - :ivar exemptionCategory: The policy exemption category. Possible values are Waiver and - Mitigated. Required. Known values are: "Waiver" and "Mitigated". - :vartype exemptionCategory: Union[str, "ExemptionCategory"] - :ivar expiresOn: The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) of - the policy exemption. - :vartype expiresOn: str - :ivar displayName: The display name of the policy exemption. - :vartype displayName: str - :ivar description: The description of the policy exemption. - :vartype description: str - :ivar metadata: The policy exemption metadata. Metadata is an open ended object and is - typically a collection of key value pairs. - :vartype metadata: Any - :ivar resourceSelectors: The resource selector list to filter policies by resource properties. - :vartype resourceSelectors: list["ResourceSelector"] - :ivar assignmentScopeValidation: The option whether validate the exemption is at or under the - assignment scope. Known values are: "Default" and "DoNotValidate". - :vartype assignmentScopeValidation: Union[str, "AssignmentScopeValidation"] - :ivar exemptionManagementMode: The mode indicating how the policy exemption is managed. Known - values are: "Admin" and "UserSelfServe". - :vartype exemptionManagementMode: Union[str, "ExemptionManagementMode"] - """ - - policyAssignmentId: Required[str] - """The ID of the policy assignment that is being exempted. Required.""" - policyDefinitionReferenceIds: list[str] - """The policy definition reference ID list when the associated policy assignment is an assignment - of a policy set definition.""" - exemptionCategory: Required[Union[str, "ExemptionCategory"]] - """The policy exemption category. Possible values are Waiver and Mitigated. Required. Known values - are: \"Waiver\" and \"Mitigated\".""" - expiresOn: str - """The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) of the policy - exemption.""" - displayName: str - """The display name of the policy exemption.""" - description: str - """The description of the policy exemption.""" - metadata: Any - """The policy exemption metadata. Metadata is an open ended object and is typically a collection - of key value pairs.""" - resourceSelectors: list["ResourceSelector"] - """The resource selector list to filter policies by resource properties.""" - assignmentScopeValidation: Union[str, "AssignmentScopeValidation"] - """The option whether validate the exemption is at or under the assignment scope. Known values - are: \"Default\" and \"DoNotValidate\".""" - exemptionManagementMode: Union[str, "ExemptionManagementMode"] - """The mode indicating how the policy exemption is managed. Known values are: \"Admin\" and - \"UserSelfServe\".""" - - -class PolicyExemptionUpdate(TypedDict, total=False): - """The policy exemption for Patch request. - - :ivar properties: The policy exemption properties for Patch request. - :vartype properties: "PolicyExemptionUpdateProperties" - """ - - properties: "PolicyExemptionUpdateProperties" - """The policy exemption properties for Patch request.""" - - -class PolicyExemptionUpdateProperties(TypedDict, total=False): - """The policy exemption properties for Patch request. - - :ivar resourceSelectors: The resource selector list to filter policies by resource properties. - :vartype resourceSelectors: list["ResourceSelector"] - :ivar assignmentScopeValidation: The option whether validate the exemption is at or under the - assignment scope. Known values are: "Default" and "DoNotValidate". - :vartype assignmentScopeValidation: Union[str, "AssignmentScopeValidation"] - :ivar exemptionManagementMode: The mode indicating how the policy exemption is managed. Known - values are: "Admin" and "UserSelfServe". - :vartype exemptionManagementMode: Union[str, "ExemptionManagementMode"] - """ - - resourceSelectors: list["ResourceSelector"] - """The resource selector list to filter policies by resource properties.""" - assignmentScopeValidation: Union[str, "AssignmentScopeValidation"] - """The option whether validate the exemption is at or under the assignment scope. Known values - are: \"Default\" and \"DoNotValidate\".""" - exemptionManagementMode: Union[str, "ExemptionManagementMode"] - """The mode indicating how the policy exemption is managed. Known values are: \"Admin\" and - \"UserSelfServe\".""" - - class PolicySetDefinition(ProxyResource): """The policy set definition. @@ -1070,56 +843,6 @@ class PolicyTokenRequest(TypedDict, total=False): """The change reference.""" -class PolicyVariableColumn(TypedDict, total=False): - """The variable column. - - :ivar columnName: The name of this policy variable column. Required. - :vartype columnName: str - """ - - columnName: Required[str] - """The name of this policy variable column. Required.""" - - -class PolicyVariableProperties(TypedDict, total=False): - """The variable properties. - - :ivar columns: Variable column definitions. Required. - :vartype columns: list["PolicyVariableColumn"] - """ - - columns: Required[list["PolicyVariableColumn"]] - """Variable column definitions. Required.""" - - -class PolicyVariableValueColumnValue(TypedDict, total=False): - """The name value tuple for this variable value column. - - :ivar columnName: Column name for the variable value. Required. - :vartype columnName: str - :ivar columnValue: Column value for the variable value; this can be an integer, double, - boolean, null or a string. Required. - :vartype columnValue: Any - """ - - columnName: Required[str] - """Column name for the variable value. Required.""" - columnValue: Required[Any] - """Column value for the variable value; this can be an integer, double, boolean, null or a string. - Required.""" - - -class PolicyVariableValueProperties(TypedDict, total=False): - """The variable value properties. - - :ivar values: Variable value column value array. Required. - :vartype values: list["PolicyVariableValueColumnValue"] - """ - - values: Required[list["PolicyVariableValueColumnValue"]] - """Variable value column value array. Required.""" - - class ResourceSelector(TypedDict, total=False): """The resource selector to filter policies by resource properties. @@ -1141,19 +864,22 @@ class ResourceSelector(TypedDict, total=False): "kind": Union[str, "SelectorKind"], "in": list[str], "notIn": list[str], + "progress": int, }, total=False, ) Selector.__doc__ = """The selector expression. :ivar kind: The selector kind. Known values are: "resourceLocation", "resourceType", - "resourceWithoutLocation", "policyDefinitionReferenceId", "userPrincipalId", and - "groupPrincipalId". + "resourceWithoutLocation", "policyDefinitionReferenceId", "resourceRolloutPercentage", + "userPrincipalId", and "groupPrincipalId". :vartype kind: Union[str, "SelectorKind"] :ivar in: The list of values to filter in. :vartype in: list[str] :ivar notIn: The list of values to filter out. :vartype notIn: list[str] +:ivar progress: The percent of total resources that will be governed by the policy. +:vartype progress: int """ @@ -1221,47 +947,3 @@ class UserAssignedIdentitiesValue(TypedDict, total=False): """The principal id of user assigned identity.""" clientId: str """The client id of user assigned identity.""" - - -class Variable(ProxyResource): - """The variable. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar systemData: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype systemData: "SystemData" - :ivar properties: Properties for the variable. - :vartype properties: "PolicyVariableProperties" - """ - - properties: "PolicyVariableProperties" - """Properties for the variable.""" - - -class VariableValue(ProxyResource): - """The variable value. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar systemData: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype systemData: "SystemData" - :ivar properties: Properties for the variable value. - :vartype properties: "PolicyVariableValueProperties" - """ - - properties: "PolicyVariableValueProperties" - """Properties for the variable value.""" diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/acquire_policy_token.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/acquire_policy_token.py index 9b9dbedc209e..b99d042c20c3 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/acquire_policy_token.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/acquire_policy_token.py @@ -42,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/acquirePolicyToken.json +# x-ms-original-file: 2026-06-01/acquirePolicyToken.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/acquire_policy_token_at_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/acquire_policy_token_at_management_group.py index fd092970c2fe..c82e64279f50 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/acquire_policy_token_at_management_group.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/acquire_policy_token_at_management_group.py @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/acquirePolicyTokenAtManagementGroup.json +# x-ms-original-file: 2026-06-01/acquirePolicyTokenAtManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition.py index 649c2466eaa3..1f3c9b571a87 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition.py @@ -60,6 +60,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/createOrUpdatePolicyDefinition.json +# x-ms-original-file: 2026-06-01/createOrUpdatePolicyDefinition.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition_advanced_params.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition_advanced_params.py index 114c6f2440a8..00bbe5a6e1d3 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition_advanced_params.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition_advanced_params.py @@ -77,6 +77,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/createOrUpdatePolicyDefinitionAdvancedParams.json +# x-ms-original-file: 2026-06-01/createOrUpdatePolicyDefinitionAdvancedParams.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition_at_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition_at_management_group.py index cc4d796bc263..b1802fda8274 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition_at_management_group.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition_at_management_group.py @@ -61,6 +61,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/createOrUpdatePolicyDefinitionAtManagementGroup.json +# x-ms-original-file: 2026-06-01/createOrUpdatePolicyDefinitionAtManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition_external_evaluation_enforcement_settings.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition_external_evaluation_enforcement_settings.py index 8c08423aa6ea..72c669b883cd 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition_external_evaluation_enforcement_settings.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition_external_evaluation_enforcement_settings.py @@ -62,6 +62,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/createOrUpdatePolicyDefinitionExternalEvaluationEnforcementSettings.json +# x-ms-original-file: 2026-06-01/createOrUpdatePolicyDefinitionExternalEvaluationEnforcementSettings.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition_version.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition_version.py index 9b91686d646a..62c844d33318 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition_version.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition_version.py @@ -62,6 +62,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/createOrUpdatePolicyDefinitionVersion.json +# x-ms-original-file: 2026-06-01/createOrUpdatePolicyDefinitionVersion.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition_version_at_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition_version_at_management_group.py index 0a4f84025d79..63919b36ef8f 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition_version_at_management_group.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition_version_at_management_group.py @@ -63,6 +63,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/createOrUpdatePolicyDefinitionVersionAtManagementGroup.json +# x-ms-original-file: 2026-06-01/createOrUpdatePolicyDefinitionVersionAtManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_enrollment_with_resource_selectors.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_enrollment_with_resource_selectors.py deleted file mode 100644 index b9e7bb8c2d9a..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_enrollment_with_resource_selectors.py +++ /dev/null @@ -1,59 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python create_or_update_policy_enrollment_with_resource_selectors.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.policy_enrollments.create_or_update( - scope="subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", - policy_enrollment_name="DemoExpensiveVM", - parameters={ - "properties": { - "assignmentScopeValidation": "Default", - "description": "Enroll demo cluster from limit sku", - "displayName": "Enroll demo cluster", - "metadata": {"reason": "Enrollment for a expensive VM demo"}, - "policyAssignmentId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement", - "policyDefinitionReferenceIds": ["Limit_Skus"], - "resourceSelectors": [ - { - "name": "SDPRegions", - "selectors": [{"in": ["eastus2euap", "centraluseuap"], "kind": "resourceLocation"}], - } - ], - } - }, - ) - print(response) - - -# x-ms-original-file: 2026-01-01-preview/createOrUpdatePolicyEnrollmentWithResourceSelectors.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_exemption.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_exemption.py deleted file mode 100644 index c383ae173bfc..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_exemption.py +++ /dev/null @@ -1,53 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python create_or_update_policy_exemption.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.policy_exemptions.create_or_update( - scope="subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", - policy_exemption_name="DemoExpensiveVM", - parameters={ - "properties": { - "description": "Exempt demo cluster from limit sku", - "displayName": "Exempt demo cluster", - "exemptionCategory": "Waiver", - "metadata": {"reason": "Temporary exemption for a expensive VM demo"}, - "policyAssignmentId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement", - "policyDefinitionReferenceIds": ["Limit_Skus"], - } - }, - ) - print(response) - - -# x-ms-original-file: 2026-01-01-preview/createOrUpdatePolicyExemption.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_exemption_with_exemption_management_mode.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_exemption_with_exemption_management_mode.py deleted file mode 100644 index 5804a267a5d2..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_exemption_with_exemption_management_mode.py +++ /dev/null @@ -1,54 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python create_or_update_policy_exemption_with_exemption_management_mode.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.policy_exemptions.create_or_update( - scope="subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", - policy_exemption_name="DemoExpensiveVM", - parameters={ - "properties": { - "description": "Exempt demo cluster from limit sku", - "displayName": "Exempt demo cluster", - "exemptionCategory": "Waiver", - "exemptionManagementMode": "UserSelfServe", - "metadata": {"reason": "Temporary exemption for a expensive VM demo"}, - "policyAssignmentId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement", - "policyDefinitionReferenceIds": ["Limit_Skus"], - } - }, - ) - print(response) - - -# x-ms-original-file: 2026-01-01-preview/createOrUpdatePolicyExemptionWithExemptionManagementMode.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_exemption_with_resource_selectors.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_exemption_with_resource_selectors.py deleted file mode 100644 index 7a07524e186d..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_exemption_with_resource_selectors.py +++ /dev/null @@ -1,60 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python create_or_update_policy_exemption_with_resource_selectors.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.policy_exemptions.create_or_update( - scope="subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", - policy_exemption_name="DemoExpensiveVM", - parameters={ - "properties": { - "assignmentScopeValidation": "Default", - "description": "Exempt demo cluster from limit sku", - "displayName": "Exempt demo cluster", - "exemptionCategory": "Waiver", - "metadata": {"reason": "Temporary exemption for a expensive VM demo"}, - "policyAssignmentId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement", - "policyDefinitionReferenceIds": ["Limit_Skus"], - "resourceSelectors": [ - { - "name": "SDPRegions", - "selectors": [{"in": ["eastus2euap", "centraluseuap"], "kind": "resourceLocation"}], - } - ], - } - }, - ) - print(response) - - -# x-ms-original-file: 2026-01-01-preview/createOrUpdatePolicyExemptionWithResourceSelectors.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition.py index 3813cb5b9377..26b7cf905ee4 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition.py @@ -63,6 +63,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/createOrUpdatePolicySetDefinition.json +# x-ms-original-file: 2026-06-01/createOrUpdatePolicySetDefinition.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition_at_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition_at_management_group.py index 0bf0ba9dafa6..612a3caf4f09 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition_at_management_group.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition_at_management_group.py @@ -42,12 +42,12 @@ def main(): "policyDefinitions": [ { "parameters": {"listOfAllowedSKUs": {"value": ["Standard_GRS", "Standard_LRS"]}}, - "policyDefinitionId": "/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + "policyDefinitionId": "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", "policyDefinitionReferenceId": "Limit_Skus", }, { "parameters": {"prefix": {"value": "DeptA"}, "suffix": {"value": "-LC"}}, - "policyDefinitionId": "/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + "policyDefinitionId": "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", "policyDefinitionReferenceId": "Resource_Naming", }, ], @@ -57,6 +57,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/createOrUpdatePolicySetDefinitionAtManagementGroup.json +# x-ms-original-file: 2026-06-01/createOrUpdatePolicySetDefinitionAtManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition_version.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition_version.py index 2d4bf3744c40..605b5d5637e7 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition_version.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition_version.py @@ -65,6 +65,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/createOrUpdatePolicySetDefinitionVersion.json +# x-ms-original-file: 2026-06-01/createOrUpdatePolicySetDefinitionVersion.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition_version_at_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition_version_at_management_group.py index b4200e37e32d..094474bfb722 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition_version_at_management_group.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition_version_at_management_group.py @@ -43,12 +43,12 @@ def main(): "policyDefinitions": [ { "parameters": {"listOfAllowedSKUs": {"value": ["Standard_GRS", "Standard_LRS"]}}, - "policyDefinitionId": "/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + "policyDefinitionId": "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", "policyDefinitionReferenceId": "Limit_Skus", }, { "parameters": {"prefix": {"value": "DeptA"}, "suffix": {"value": "-LC"}}, - "policyDefinitionId": "/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + "policyDefinitionId": "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", "policyDefinitionReferenceId": "Resource_Naming", }, ], @@ -59,6 +59,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/createOrUpdatePolicySetDefinitionVersionAtManagementGroup.json +# x-ms-original-file: 2026-06-01/createOrUpdatePolicySetDefinitionVersionAtManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition_with_groups.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition_with_groups.py index e93e2a119cec..f0ff1306db6d 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition_with_groups.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition_with_groups.py @@ -72,6 +72,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/createOrUpdatePolicySetDefinitionWithGroups.json +# x-ms-original-file: 2026-06-01/createOrUpdatePolicySetDefinitionWithGroups.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition_with_groups_at_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition_with_groups_at_management_group.py index afeb2a589359..99285d0a4551 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition_with_groups_at_management_group.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_set_definition_with_groups_at_management_group.py @@ -71,6 +71,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/createOrUpdatePolicySetDefinitionWithGroupsAtManagementGroup.json +# x-ms-original-file: 2026-06-01/createOrUpdatePolicySetDefinitionWithGroupsAtManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_variable.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_variable.py deleted file mode 100644 index 2d3cc5d19fc8..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_variable.py +++ /dev/null @@ -1,42 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python create_or_update_variable.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.variables.create_or_update( - variable_name="DemoTestVariable", - parameters={"properties": {"columns": [{"columnName": "TestColumn"}]}}, - ) - print(response) - - -# x-ms-original-file: 2026-01-01-preview/createOrUpdateVariable.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_variable_at_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_variable_at_management_group.py deleted file mode 100644 index 9c643d6e63a6..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_variable_at_management_group.py +++ /dev/null @@ -1,43 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python create_or_update_variable_at_management_group.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.variables.create_or_update_at_management_group( - management_group_id="DevOrg", - variable_name="DemoTestVariable", - parameters={"properties": {"columns": [{"columnName": "TestColumn"}]}}, - ) - print(response) - - -# x-ms-original-file: 2026-01-01-preview/createOrUpdateVariableAtManagementGroup.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_variable_value_at_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_variable_value_at_management_group.py deleted file mode 100644 index 47725eb22968..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_variable_value_at_management_group.py +++ /dev/null @@ -1,51 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python create_or_update_variable_value_at_management_group.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.variable_values.create_or_update_at_management_group( - management_group_id="DevOrg", - variable_name="DemoTestVariable", - variable_value_name="TestValue", - parameters={ - "properties": { - "values": [ - {"columnName": "StringColumn", "columnValue": "SampleValue"}, - {"columnName": "IntegerColumn", "columnValue": 10}, - ] - } - }, - ) - print(response) - - -# x-ms-original-file: 2026-01-01-preview/createOrUpdateVariableValueAtManagementGroup.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment.py index 5c2078c78372..5c72ab196899 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment.py @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/createPolicyAssignment.json +# x-ms-original-file: 2026-06-01/createPolicyAssignment.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_non_compliance_messages.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_non_compliance_messages.py index 5f7ffa628907..c7cd41f35a3f 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_non_compliance_messages.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_non_compliance_messages.py @@ -57,6 +57,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/createPolicyAssignmentNonComplianceMessages.json +# x-ms-original-file: 2026-06-01/createPolicyAssignmentNonComplianceMessages.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_enroll_enforcement.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_enroll_enforcement.py index ce5df33e6c57..2f33bf57bf6c 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_enroll_enforcement.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_enroll_enforcement.py @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/createPolicyAssignmentWithEnrollEnforcement.json +# x-ms-original-file: 2026-06-01/createPolicyAssignmentWithEnrollEnforcement.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_identity.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_identity.py index bb7789cfe398..d926cc71d37e 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_identity.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_identity.py @@ -50,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/createPolicyAssignmentWithIdentity.json +# x-ms-original-file: 2026-06-01/createPolicyAssignmentWithIdentity.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_overrides.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_overrides.py index 89379cb59f72..317b643d16e5 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_overrides.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_overrides.py @@ -59,6 +59,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/createPolicyAssignmentWithOverrides.json +# x-ms-original-file: 2026-06-01/createPolicyAssignmentWithOverrides.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_enrollment.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_resource_rollout_percentage_selector.py similarity index 66% rename from sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_enrollment.py rename to sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_resource_rollout_percentage_selector.py index e6539f6072a2..af10b4eabbd6 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_enrollment.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_resource_rollout_percentage_selector.py @@ -16,7 +16,7 @@ pip install azure-identity pip install azure-mgmt-resource-policy # USAGE - python create_or_update_policy_enrollment.py + python create_policy_assignment_with_resource_rollout_percentage_selector.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -31,22 +31,24 @@ def main(): subscription_id="SUBSCRIPTION_ID", ) - response = client.policy_enrollments.create_or_update( - scope="subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", - policy_enrollment_name="DemoExpensiveVM", + response = client.policy_assignments.create( + scope="subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + policy_assignment_name="CostManagement", parameters={ "properties": { - "description": "Enroll demo cluster from limit sku", - "displayName": "Enroll demo cluster", - "metadata": {"reason": "Enrollment for a expensive VM demo"}, - "policyAssignmentId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement", - "policyDefinitionReferenceIds": ["Limit_Skus"], + "description": "Limit resources by rollout percentage", + "displayName": "Limit resources by rollout percentage", + "metadata": {"assignedBy": "Special Someone"}, + "policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement", + "resourceSelectors": [ + {"name": "SDPRollout", "selectors": [{"kind": "resourceRolloutPercentage", "progress": 80}]} + ], } }, ) print(response) -# x-ms-original-file: 2026-01-01-preview/createOrUpdatePolicyEnrollment.json +# x-ms-original-file: 2026-06-01/createPolicyAssignmentWithResourceRolloutPercentageSelector.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_resource_selectors.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_resource_selectors.py index 2ce558608c60..5c85ee5fd28f 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_resource_selectors.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_resource_selectors.py @@ -52,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/createPolicyAssignmentWithResourceSelectors.json +# x-ms-original-file: 2026-06-01/createPolicyAssignmentWithResourceSelectors.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_selfserve_exemption_settings.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_selfserve_exemption_settings.py index 8750e8dc4479..545bcc96d396 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_selfserve_exemption_settings.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_selfserve_exemption_settings.py @@ -50,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/createPolicyAssignmentWithSelfserveExemptionSettings.json +# x-ms-original-file: 2026-06-01/createPolicyAssignmentWithSelfserveExemptionSettings.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_user_assigned_identity.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_user_assigned_identity.py index d0e7f7a968e4..db324d25447b 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_user_assigned_identity.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_user_assigned_identity.py @@ -55,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/createPolicyAssignmentWithUserAssignedIdentity.json +# x-ms-original-file: 2026-06-01/createPolicyAssignmentWithUserAssignedIdentity.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_without_enforcement.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_without_enforcement.py index 6982f5748ca1..fa8556920ff3 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_without_enforcement.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_without_enforcement.py @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/createPolicyAssignmentWithoutEnforcement.json +# x-ms-original-file: 2026-06-01/createPolicyAssignmentWithoutEnforcement.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_assignment.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_assignment.py index 950ed22ecd48..7f97805c1047 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_assignment.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_assignment.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/deletePolicyAssignment.json +# x-ms-original-file: 2026-06-01/deletePolicyAssignment.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_definition.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_definition.py index 3d1ae1b4c538..fbdfa8313ac3 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_definition.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_definition.py @@ -35,6 +35,6 @@ def main(): ) -# x-ms-original-file: 2026-01-01-preview/deletePolicyDefinition.json +# x-ms-original-file: 2026-06-01/deletePolicyDefinition.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_definition_at_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_definition_at_management_group.py index e605dfeb29ff..3173cbc5d406 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_definition_at_management_group.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_definition_at_management_group.py @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: 2026-01-01-preview/deletePolicyDefinitionAtManagementGroup.json +# x-ms-original-file: 2026-06-01/deletePolicyDefinitionAtManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_definition_version.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_definition_version.py index c46da00e0398..3d33b5ba3d59 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_definition_version.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_definition_version.py @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: 2026-01-01-preview/deletePolicyDefinitionVersion.json +# x-ms-original-file: 2026-06-01/deletePolicyDefinitionVersion.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_definition_version_at_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_definition_version_at_management_group.py index fadb21a28f02..38cb43fcabbc 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_definition_version_at_management_group.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_definition_version_at_management_group.py @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: 2026-01-01-preview/deletePolicyDefinitionVersionAtManagementGroup.json +# x-ms-original-file: 2026-06-01/deletePolicyDefinitionVersionAtManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_enrollment.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_enrollment.py deleted file mode 100644 index 189c3203b81c..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_enrollment.py +++ /dev/null @@ -1,41 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python delete_policy_enrollment.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - client.policy_enrollments.delete( - scope="subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", - policy_enrollment_name="DemoExpensiveVM", - ) - - -# x-ms-original-file: 2026-01-01-preview/deletePolicyEnrollment.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_exemption.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_exemption.py deleted file mode 100644 index b3e66f81ff18..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_exemption.py +++ /dev/null @@ -1,41 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python delete_policy_exemption.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - client.policy_exemptions.delete( - scope="subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", - policy_exemption_name="DemoExpensiveVM", - ) - - -# x-ms-original-file: 2026-01-01-preview/deletePolicyExemption.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_set_definition.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_set_definition.py index f66a0f677825..6b5d5eb3c76d 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_set_definition.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_set_definition.py @@ -35,6 +35,6 @@ def main(): ) -# x-ms-original-file: 2026-01-01-preview/deletePolicySetDefinition.json +# x-ms-original-file: 2026-06-01/deletePolicySetDefinition.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_set_definition_at_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_set_definition_at_management_group.py index 4a073ada07e4..dd217e0ee2ba 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_set_definition_at_management_group.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_set_definition_at_management_group.py @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: 2026-01-01-preview/deletePolicySetDefinitionAtManagementGroup.json +# x-ms-original-file: 2026-06-01/deletePolicySetDefinitionAtManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_set_definition_version.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_set_definition_version.py index 4c15a310c326..427fc1273f14 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_set_definition_version.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_set_definition_version.py @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: 2026-01-01-preview/deletePolicySetDefinitionVersion.json +# x-ms-original-file: 2026-06-01/deletePolicySetDefinitionVersion.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_set_definition_version_at_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_set_definition_version_at_management_group.py index 8faa7a2c109c..398d9d684756 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_set_definition_version_at_management_group.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_set_definition_version_at_management_group.py @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: 2026-01-01-preview/deletePolicySetDefinitionVersionAtManagementGroup.json +# x-ms-original-file: 2026-06-01/deletePolicySetDefinitionVersionAtManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_variable.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_variable.py deleted file mode 100644 index b74b8af7715d..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_variable.py +++ /dev/null @@ -1,40 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python delete_variable.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - client.variables.delete( - variable_name="DemoTestVariable", - ) - - -# x-ms-original-file: 2026-01-01-preview/deleteVariable.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_variable_at_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_variable_at_management_group.py deleted file mode 100644 index 7fcbcb1c588b..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_variable_at_management_group.py +++ /dev/null @@ -1,41 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python delete_variable_at_management_group.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - client.variables.delete_at_management_group( - management_group_id="DevOrg", - variable_name="DemoTestVariable", - ) - - -# x-ms-original-file: 2026-01-01-preview/deleteVariableAtManagementGroup.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_variable_value.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_variable_value.py deleted file mode 100644 index 5dcfbea2569e..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_variable_value.py +++ /dev/null @@ -1,41 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python delete_variable_value.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - client.variable_values.delete( - variable_name="DemoTestVariable", - variable_value_name="TestValue", - ) - - -# x-ms-original-file: 2026-01-01-preview/deleteVariableValue.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_variable_value_at_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_variable_value_at_management_group.py deleted file mode 100644 index 05322c2e4477..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_variable_value_at_management_group.py +++ /dev/null @@ -1,42 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python delete_variable_value_at_management_group.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - client.variable_values.delete_at_management_group( - management_group_id="DevOrg", - variable_name="DemoTestVariable", - variable_value_name="TestValue", - ) - - -# x-ms-original-file: 2026-01-01-preview/deleteVariableValueAtManagementGroup.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_built_in_policy_set_definition.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_built_in_policy_set_definition.py index 01b82b1a6534..f4d7e56b3104 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_built_in_policy_set_definition.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_built_in_policy_set_definition.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/getBuiltInPolicySetDefinition.json +# x-ms-original-file: 2026-06-01/getBuiltInPolicySetDefinition.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_built_in_policy_set_definition_version.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_built_in_policy_set_definition_version.py index efed21e7e4e2..08fcd33657c7 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_built_in_policy_set_definition_version.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_built_in_policy_set_definition_version.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/getBuiltInPolicySetDefinitionVersion.json +# x-ms-original-file: 2026-06-01/getBuiltInPolicySetDefinitionVersion.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_builtin_policy_definition.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_builtin_policy_definition.py index 07bc96856048..4a576981be5d 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_builtin_policy_definition.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_builtin_policy_definition.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/getBuiltinPolicyDefinition.json +# x-ms-original-file: 2026-06-01/getBuiltinPolicyDefinition.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_builtin_policy_definition_version.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_builtin_policy_definition_version.py index bdc4a8cdc1b5..525a9e78e71c 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_builtin_policy_definition_version.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_builtin_policy_definition_version.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/getBuiltinPolicyDefinitionVersion.json +# x-ms-original-file: 2026-06-01/getBuiltinPolicyDefinitionVersion.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_data_policy_manifest.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_data_policy_manifest.py index c7546bf957f2..5bb6d1730a3d 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_data_policy_manifest.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_data_policy_manifest.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/getDataPolicyManifest.json +# x-ms-original-file: 2026-06-01/getDataPolicyManifest.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment.py index 83822eb15297..5977a518cdb7 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/getPolicyAssignment.json +# x-ms-original-file: 2026-06-01/getPolicyAssignment.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_with_identity.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_with_identity.py index c58ae43ad7a0..0f442ff0f8dd 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_with_identity.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_with_identity.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/getPolicyAssignmentWithIdentity.json +# x-ms-original-file: 2026-06-01/getPolicyAssignmentWithIdentity.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_with_overrides.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_with_overrides.py index 6d936b5ecd1a..1add02a74bcd 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_with_overrides.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_with_overrides.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/getPolicyAssignmentWithOverrides.json +# x-ms-original-file: 2026-06-01/getPolicyAssignmentWithOverrides.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_exemption.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_with_resource_rollout_percentage_selector.py similarity index 82% rename from sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_exemption.py rename to sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_with_resource_rollout_percentage_selector.py index a2f4a5864ea9..edea7bbabc04 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_exemption.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_with_resource_rollout_percentage_selector.py @@ -15,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-resource-policy # USAGE - python get_policy_exemption.py + python get_policy_assignment_with_resource_rollout_percentage_selector.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -30,13 +30,13 @@ def main(): subscription_id="SUBSCRIPTION_ID", ) - response = client.policy_exemptions.get( - scope="subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", - policy_exemption_name="DemoExpensiveVM", + response = client.policy_assignments.get( + scope="subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + policy_assignment_name="CostManagement", ) print(response) -# x-ms-original-file: 2026-01-01-preview/getPolicyExemption.json +# x-ms-original-file: 2026-06-01/getPolicyAssignmentWithResourceRolloutPercentageSelector.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_with_resource_selectors.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_with_resource_selectors.py index ad818798f5f6..f8af07a9ff09 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_with_resource_selectors.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_with_resource_selectors.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/getPolicyAssignmentWithResourceSelectors.json +# x-ms-original-file: 2026-06-01/getPolicyAssignmentWithResourceSelectors.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_with_user_assigned_identity.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_with_user_assigned_identity.py index a483444e390b..fef2eddcdabe 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_with_user_assigned_identity.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_with_user_assigned_identity.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/getPolicyAssignmentWithUserAssignedIdentity.json +# x-ms-original-file: 2026-06-01/getPolicyAssignmentWithUserAssignedIdentity.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_definition.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_definition.py index a4d68abb0b20..4cdd49e0b7ba 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_definition.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_definition.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/getPolicyDefinition.json +# x-ms-original-file: 2026-06-01/getPolicyDefinition.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_definition_at_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_definition_at_management_group.py index b50066765565..b69706720033 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_definition_at_management_group.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_definition_at_management_group.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/getPolicyDefinitionAtManagementGroup.json +# x-ms-original-file: 2026-06-01/getPolicyDefinitionAtManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_definition_version.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_definition_version.py index a35935630562..d47009fd0d13 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_definition_version.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_definition_version.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/getPolicyDefinitionVersion.json +# x-ms-original-file: 2026-06-01/getPolicyDefinitionVersion.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_definition_version_at_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_definition_version_at_management_group.py index b9593ae3b78d..7966b58ca5cf 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_definition_version_at_management_group.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_definition_version_at_management_group.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/getPolicyDefinitionVersionAtManagementGroup.json +# x-ms-original-file: 2026-06-01/getPolicyDefinitionVersionAtManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_enrollment.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_enrollment.py deleted file mode 100644 index 5029bb12aaf0..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_enrollment.py +++ /dev/null @@ -1,42 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python get_policy_enrollment.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.policy_enrollments.get( - scope="subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", - policy_enrollment_name="DemoExpensiveVM", - ) - print(response) - - -# x-ms-original-file: 2026-01-01-preview/getPolicyEnrollment.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_enrollment_with_resource_selectors.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_enrollment_with_resource_selectors.py deleted file mode 100644 index 7354045d8b53..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_enrollment_with_resource_selectors.py +++ /dev/null @@ -1,42 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python get_policy_enrollment_with_resource_selectors.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.policy_enrollments.get( - scope="subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", - policy_enrollment_name="DemoExpensiveVM", - ) - print(response) - - -# x-ms-original-file: 2026-01-01-preview/getPolicyEnrollmentWithResourceSelectors.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_exemption_with_resource_selectors.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_exemption_with_resource_selectors.py deleted file mode 100644 index d29d1d6c3da2..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_exemption_with_resource_selectors.py +++ /dev/null @@ -1,42 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python get_policy_exemption_with_resource_selectors.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.policy_exemptions.get( - scope="subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", - policy_exemption_name="DemoExpensiveVM", - ) - print(response) - - -# x-ms-original-file: 2026-01-01-preview/getPolicyExemptionWithResourceSelectors.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_set_definition.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_set_definition.py index 01976c9db439..0f6a395ae448 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_set_definition.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_set_definition.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/getPolicySetDefinition.json +# x-ms-original-file: 2026-06-01/getPolicySetDefinition.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_set_definition_at_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_set_definition_at_management_group.py index f7f0ce7dcbae..4acd7d7f4393 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_set_definition_at_management_group.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_set_definition_at_management_group.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/getPolicySetDefinitionAtManagementGroup.json +# x-ms-original-file: 2026-06-01/getPolicySetDefinitionAtManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_set_definition_version.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_set_definition_version.py index d311f213aa0a..c79d14999239 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_set_definition_version.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_set_definition_version.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/getPolicySetDefinitionVersion.json +# x-ms-original-file: 2026-06-01/getPolicySetDefinitionVersion.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_set_definition_version_at_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_set_definition_version_at_management_group.py index e4f7300ba62f..4e4548596b06 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_set_definition_version_at_management_group.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_set_definition_version_at_management_group.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/getPolicySetDefinitionVersionAtManagementGroup.json +# x-ms-original-file: 2026-06-01/getPolicySetDefinitionVersionAtManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_variable.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_variable.py deleted file mode 100644 index de81df7ef69a..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_variable.py +++ /dev/null @@ -1,41 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python get_variable.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.variables.get( - variable_name="DemoTestVariable", - ) - print(response) - - -# x-ms-original-file: 2026-01-01-preview/getVariable.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_variable_at_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_variable_at_management_group.py deleted file mode 100644 index 44ce9dc7004d..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_variable_at_management_group.py +++ /dev/null @@ -1,42 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python get_variable_at_management_group.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.variables.get_at_management_group( - management_group_id="DevOrg", - variable_name="DemoTestVariable", - ) - print(response) - - -# x-ms-original-file: 2026-01-01-preview/getVariableAtManagementGroup.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_variable_value.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_variable_value.py deleted file mode 100644 index 417b1bd9fa6d..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_variable_value.py +++ /dev/null @@ -1,42 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python get_variable_value.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.variable_values.get( - variable_name="DemoTestVariable", - variable_value_name="TestValue", - ) - print(response) - - -# x-ms-original-file: 2026-01-01-preview/getVariableValue.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_variable_value_at_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_variable_value_at_management_group.py deleted file mode 100644 index f5f7cd533701..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_variable_value_at_management_group.py +++ /dev/null @@ -1,43 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python get_variable_value_at_management_group.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.variable_values.get_at_management_group( - management_group_id="DevOrg", - variable_name="DemoTestVariable", - variable_value_name="TestValue", - ) - print(response) - - -# x-ms-original-file: 2026-01-01-preview/getVariableValueAtManagementGroup.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_built_in_policy_definition_versions.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_built_in_policy_definition_versions.py index 6d0d6ed5442b..e578a736c686 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_built_in_policy_definition_versions.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_built_in_policy_definition_versions.py @@ -34,6 +34,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/listAllBuiltInPolicyDefinitionVersions.json +# x-ms-original-file: 2026-06-01/listAllBuiltInPolicyDefinitionVersions.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_built_in_policy_set_definition_versions.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_built_in_policy_set_definition_versions.py index 2ca236f6406f..793cde7fcd2b 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_built_in_policy_set_definition_versions.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_built_in_policy_set_definition_versions.py @@ -34,6 +34,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/listAllBuiltInPolicySetDefinitionVersions.json +# x-ms-original-file: 2026-06-01/listAllBuiltInPolicySetDefinitionVersions.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_policy_definition_versions.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_policy_definition_versions.py index 0bac4c4b9eb2..544d4b640589 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_policy_definition_versions.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_policy_definition_versions.py @@ -34,6 +34,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/listAllPolicyDefinitionVersions.json +# x-ms-original-file: 2026-06-01/listAllPolicyDefinitionVersions.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_policy_definition_versions_by_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_policy_definition_versions_by_management_group.py index a76cab647d5e..804c0c8e67ba 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_policy_definition_versions_by_management_group.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_policy_definition_versions_by_management_group.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/listAllPolicyDefinitionVersionsByManagementGroup.json +# x-ms-original-file: 2026-06-01/listAllPolicyDefinitionVersionsByManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_policy_set_definition_versions.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_policy_set_definition_versions.py index dabd91dc2363..9f953248469e 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_policy_set_definition_versions.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_policy_set_definition_versions.py @@ -34,6 +34,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/listAllPolicySetDefinitionVersions.json +# x-ms-original-file: 2026-06-01/listAllPolicySetDefinitionVersions.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_policy_set_definition_versions_by_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_policy_set_definition_versions_by_management_group.py index 5cc10db91da0..0e1863e3fd50 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_policy_set_definition_versions_by_management_group.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_all_policy_set_definition_versions_by_management_group.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/listAllPolicySetDefinitionVersionsByManagementGroup.json +# x-ms-original-file: 2026-06-01/listAllPolicySetDefinitionVersionsByManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_built_in_policy_definition_versions.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_built_in_policy_definition_versions.py index d0d3be4dc92a..0fd5c7042a9b 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_built_in_policy_definition_versions.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_built_in_policy_definition_versions.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: 2026-01-01-preview/listBuiltInPolicyDefinitionVersions.json +# x-ms-original-file: 2026-06-01/listBuiltInPolicyDefinitionVersions.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_built_in_policy_definitions.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_built_in_policy_definitions.py index 20476ca54e43..144bf8001b59 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_built_in_policy_definitions.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_built_in_policy_definitions.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: 2026-01-01-preview/listBuiltInPolicyDefinitions.json +# x-ms-original-file: 2026-06-01/listBuiltInPolicyDefinitions.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_built_in_policy_set_definition_versions.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_built_in_policy_set_definition_versions.py index 871d92f72b9c..788682c5a93e 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_built_in_policy_set_definition_versions.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_built_in_policy_set_definition_versions.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: 2026-01-01-preview/listBuiltInPolicySetDefinitionVersions.json +# x-ms-original-file: 2026-06-01/listBuiltInPolicySetDefinitionVersions.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_built_in_policy_set_definitions.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_built_in_policy_set_definitions.py index 3334f41eafd8..329651683a7f 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_built_in_policy_set_definitions.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_built_in_policy_set_definitions.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: 2026-01-01-preview/listBuiltInPolicySetDefinitions.json +# x-ms-original-file: 2026-06-01/listBuiltInPolicySetDefinitions.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_data_policy_manifests.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_data_policy_manifests.py index 45dc4028c1e5..ed0ca7fc6f60 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_data_policy_manifests.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_data_policy_manifests.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: 2026-01-01-preview/listDataPolicyManifests.json +# x-ms-original-file: 2026-06-01/listDataPolicyManifests.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_data_policy_manifests_namespace_filter.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_data_policy_manifests_namespace_filter.py index bbb42d24c898..7b00766f3895 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_data_policy_manifests_namespace_filter.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_data_policy_manifests_namespace_filter.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: 2026-01-01-preview/listDataPolicyManifestsNamespaceFilter.json +# x-ms-original-file: 2026-06-01/listDataPolicyManifestsNamespaceFilter.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_assignments.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_assignments.py index 2a3e48362677..1f5ea6a39c49 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_assignments.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_assignments.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: 2026-01-01-preview/listPolicyAssignments.json +# x-ms-original-file: 2026-06-01/listPolicyAssignments.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_assignments_for_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_assignments_for_management_group.py index 8e77133b0053..b9631377ad94 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_assignments_for_management_group.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_assignments_for_management_group.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: 2026-01-01-preview/listPolicyAssignmentsForManagementGroup.json +# x-ms-original-file: 2026-06-01/listPolicyAssignmentsForManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_assignments_for_resource.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_assignments_for_resource.py index a636beb2f122..2eb3ab25e9e1 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_assignments_for_resource.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_assignments_for_resource.py @@ -41,6 +41,6 @@ def main(): print(item) -# x-ms-original-file: 2026-01-01-preview/listPolicyAssignmentsForResource.json +# x-ms-original-file: 2026-06-01/listPolicyAssignmentsForResource.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_assignments_for_resource_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_assignments_for_resource_group.py index 2a3d666af327..7ae411e23167 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_assignments_for_resource_group.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_assignments_for_resource_group.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: 2026-01-01-preview/listPolicyAssignmentsForResourceGroup.json +# x-ms-original-file: 2026-06-01/listPolicyAssignmentsForResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_definition_versions.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_definition_versions.py index 33c5de0b6fd7..1265a9f34438 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_definition_versions.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_definition_versions.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: 2026-01-01-preview/listPolicyDefinitionVersions.json +# x-ms-original-file: 2026-06-01/listPolicyDefinitionVersions.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_definition_versions_by_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_definition_versions_by_management_group.py index f85a55c208b8..bdd3a08476c6 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_definition_versions_by_management_group.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_definition_versions_by_management_group.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: 2026-01-01-preview/listPolicyDefinitionVersionsByManagementGroup.json +# x-ms-original-file: 2026-06-01/listPolicyDefinitionVersionsByManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_definitions.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_definitions.py index 8e4f7a07c243..30453fa7e519 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_definitions.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_definitions.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: 2026-01-01-preview/listPolicyDefinitions.json +# x-ms-original-file: 2026-06-01/listPolicyDefinitions.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_definitions_by_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_definitions_by_management_group.py index 68b0afaf6c45..cb3e320cdc91 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_definitions_by_management_group.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_definitions_by_management_group.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: 2026-01-01-preview/listPolicyDefinitionsByManagementGroup.json +# x-ms-original-file: 2026-06-01/listPolicyDefinitionsByManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_enrollments_for_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_enrollments_for_management_group.py deleted file mode 100644 index e4453337c51b..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_enrollments_for_management_group.py +++ /dev/null @@ -1,42 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python list_policy_enrollments_for_management_group.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.policy_enrollments.list_for_management_group( - management_group_id="DevOrg", - ) - for item in response: - print(item) - - -# x-ms-original-file: 2026-01-01-preview/listPolicyEnrollmentsForManagementGroup.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_enrollments_for_resource.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_enrollments_for_resource.py deleted file mode 100644 index ea8574cb82de..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_enrollments_for_resource.py +++ /dev/null @@ -1,46 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python list_policy_enrollments_for_resource.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.policy_enrollments.list_for_resource( - resource_group_name="TestResourceGroup", - resource_provider_namespace="Microsoft.Compute", - parent_resource_path="virtualMachines/MyTestVm", - resource_type="domainNames", - resource_name="MyTestComputer.cloudapp.net", - ) - for item in response: - print(item) - - -# x-ms-original-file: 2026-01-01-preview/listPolicyEnrollmentsForResource.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_enrollments_for_resource_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_enrollments_for_resource_group.py deleted file mode 100644 index eb02edaaa6b7..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_enrollments_for_resource_group.py +++ /dev/null @@ -1,42 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python list_policy_enrollments_for_resource_group.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.policy_enrollments.list_for_resource_group( - resource_group_name="TestResourceGroup", - ) - for item in response: - print(item) - - -# x-ms-original-file: 2026-01-01-preview/listPolicyEnrollmentsForResourceGroup.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_enrollments_for_subscription.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_enrollments_for_subscription.py deleted file mode 100644 index 34c35ae79bf4..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_enrollments_for_subscription.py +++ /dev/null @@ -1,40 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python list_policy_enrollments_for_subscription.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.policy_enrollments.list() - for item in response: - print(item) - - -# x-ms-original-file: 2026-01-01-preview/listPolicyEnrollmentsForSubscription.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_exemptions_for_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_exemptions_for_management_group.py deleted file mode 100644 index 735cf2955c00..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_exemptions_for_management_group.py +++ /dev/null @@ -1,42 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python list_policy_exemptions_for_management_group.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.policy_exemptions.list_for_management_group( - management_group_id="DevOrg", - ) - for item in response: - print(item) - - -# x-ms-original-file: 2026-01-01-preview/listPolicyExemptionsForManagementGroup.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_exemptions_for_resource.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_exemptions_for_resource.py deleted file mode 100644 index bad72bf935d1..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_exemptions_for_resource.py +++ /dev/null @@ -1,46 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python list_policy_exemptions_for_resource.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.policy_exemptions.list_for_resource( - resource_group_name="TestResourceGroup", - resource_provider_namespace="Microsoft.Compute", - parent_resource_path="virtualMachines/MyTestVm", - resource_type="domainNames", - resource_name="MyTestComputer.cloudapp.net", - ) - for item in response: - print(item) - - -# x-ms-original-file: 2026-01-01-preview/listPolicyExemptionsForResource.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_exemptions_for_resource_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_exemptions_for_resource_group.py deleted file mode 100644 index 74789dce6061..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_exemptions_for_resource_group.py +++ /dev/null @@ -1,42 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python list_policy_exemptions_for_resource_group.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.policy_exemptions.list_for_resource_group( - resource_group_name="TestResourceGroup", - ) - for item in response: - print(item) - - -# x-ms-original-file: 2026-01-01-preview/listPolicyExemptionsForResourceGroup.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_exemptions_for_subscription.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_exemptions_for_subscription.py deleted file mode 100644 index f519cb844cdc..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_exemptions_for_subscription.py +++ /dev/null @@ -1,40 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python list_policy_exemptions_for_subscription.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.policy_exemptions.list() - for item in response: - print(item) - - -# x-ms-original-file: 2026-01-01-preview/listPolicyExemptionsForSubscription.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_set_definition_versions.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_set_definition_versions.py index 224281cf2ab7..d8b8e6680b34 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_set_definition_versions.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_set_definition_versions.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: 2026-01-01-preview/listPolicySetDefinitionVersions.json +# x-ms-original-file: 2026-06-01/listPolicySetDefinitionVersions.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_set_definition_versions_by_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_set_definition_versions_by_management_group.py index ba2603664b20..b949ef63c97f 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_set_definition_versions_by_management_group.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_set_definition_versions_by_management_group.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: 2026-01-01-preview/listPolicySetDefinitionVersionsByManagementGroup.json +# x-ms-original-file: 2026-06-01/listPolicySetDefinitionVersionsByManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_set_definitions.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_set_definitions.py index 79945be86214..47186dd98246 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_set_definitions.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_set_definitions.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: 2026-01-01-preview/listPolicySetDefinitions.json +# x-ms-original-file: 2026-06-01/listPolicySetDefinitions.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_set_definitions_by_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_set_definitions_by_management_group.py index ba87400cc51b..b3045f4232cf 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_set_definitions_by_management_group.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_set_definitions_by_management_group.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: 2026-01-01-preview/listPolicySetDefinitionsByManagementGroup.json +# x-ms-original-file: 2026-06-01/listPolicySetDefinitionsByManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_variable_values_for_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_variable_values_for_management_group.py deleted file mode 100644 index 4416a8a34c7e..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_variable_values_for_management_group.py +++ /dev/null @@ -1,43 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python list_variable_values_for_management_group.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.variable_values.list_for_management_group( - management_group_id="DevOrg", - variable_name="DemoTestVariable", - ) - for item in response: - print(item) - - -# x-ms-original-file: 2026-01-01-preview/listVariableValuesForManagementGroup.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_variable_values_for_subscription.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_variable_values_for_subscription.py deleted file mode 100644 index 0361f4e63d8a..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_variable_values_for_subscription.py +++ /dev/null @@ -1,42 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python list_variable_values_for_subscription.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.variable_values.list( - variable_name="DemoTestVariable", - ) - for item in response: - print(item) - - -# x-ms-original-file: 2026-01-01-preview/listVariableValuesForSubscription.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_variables_for_management_group.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_variables_for_management_group.py deleted file mode 100644 index 37609b09a57d..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_variables_for_management_group.py +++ /dev/null @@ -1,42 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python list_variables_for_management_group.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.variables.list_for_management_group( - management_group_id="DevOrg", - ) - for item in response: - print(item) - - -# x-ms-original-file: 2026-01-01-preview/listVariablesForManagementGroup.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_variables_for_subscription.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_variables_for_subscription.py deleted file mode 100644 index 8b0c54d75584..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_variables_for_subscription.py +++ /dev/null @@ -1,40 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python list_variables_for_subscription.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.variables.list() - for item in response: - print(item) - - -# x-ms-original-file: 2026-01-01-preview/listVariablesForSubscription.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_identity.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_identity.py index 136578d2886f..3623baaeea8a 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_identity.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_identity.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/updatePolicyAssignmentWithIdentity.json +# x-ms-original-file: 2026-06-01/updatePolicyAssignmentWithIdentity.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_overrides.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_overrides.py index fc1ab6d0e3db..46cd87391b54 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_overrides.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_overrides.py @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/updatePolicyAssignmentWithOverrides.json +# x-ms-original-file: 2026-06-01/updatePolicyAssignmentWithOverrides.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_variable_value.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_resource_rollout_percentage_selector.py similarity index 72% rename from sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_variable_value.py rename to sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_resource_rollout_percentage_selector.py index c19b83c4b15e..bc0408c6b2e2 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_variable_value.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_resource_rollout_percentage_selector.py @@ -15,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-resource-policy # USAGE - python create_or_update_variable_value.py + python update_policy_assignment_with_resource_rollout_percentage_selector.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -30,14 +30,13 @@ def main(): subscription_id="SUBSCRIPTION_ID", ) - response = client.variable_values.create_or_update( - variable_name="DemoTestVariable", - variable_value_name="TestValue", + response = client.policy_assignments.update( + scope="subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + policy_assignment_name="CostManagement", parameters={ "properties": { - "values": [ - {"columnName": "StringColumn", "columnValue": "SampleValue"}, - {"columnName": "IntegerColumn", "columnValue": 10}, + "resourceSelectors": [ + {"name": "SDPRollout", "selectors": [{"kind": "resourceRolloutPercentage", "progress": 80}]} ] } }, @@ -45,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/createOrUpdateVariableValue.json +# x-ms-original-file: 2026-06-01/updatePolicyAssignmentWithResourceRolloutPercentageSelector.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_resource_selectors.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_resource_selectors.py index 7b8dbce13c7d..b6c08b51990e 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_resource_selectors.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_resource_selectors.py @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/updatePolicyAssignmentWithResourceSelectors.json +# x-ms-original-file: 2026-06-01/updatePolicyAssignmentWithResourceSelectors.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_selfserve_exemption_settings.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_selfserve_exemption_settings.py index 4fb936c86743..e82fcb95d101 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_selfserve_exemption_settings.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_selfserve_exemption_settings.py @@ -42,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/updatePolicyAssignmentWithSelfserveExemptionSettings.json +# x-ms-original-file: 2026-06-01/updatePolicyAssignmentWithSelfserveExemptionSettings.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_user_assigned_identity.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_user_assigned_identity.py index d5eeff424467..47683d709224 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_user_assigned_identity.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_user_assigned_identity.py @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: 2026-01-01-preview/updatePolicyAssignmentWithUserAssignedIdentity.json +# x-ms-original-file: 2026-06-01/updatePolicyAssignmentWithUserAssignedIdentity.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_enrollment_with_resource_selectors.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_enrollment_with_resource_selectors.py deleted file mode 100644 index 467203ff45a6..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_enrollment_with_resource_selectors.py +++ /dev/null @@ -1,53 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python update_policy_enrollment_with_resource_selectors.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.policy_enrollments.update( - scope="subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", - policy_enrollment_name="DemoExpensiveVM", - parameters={ - "properties": { - "assignmentScopeValidation": "Default", - "resourceSelectors": [ - { - "name": "SDPRegions", - "selectors": [{"in": ["eastus2euap", "centraluseuap"], "kind": "resourceLocation"}], - } - ], - } - }, - ) - print(response) - - -# x-ms-original-file: 2026-01-01-preview/updatePolicyEnrollmentWithResourceSelectors.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_exemption_with_exemption_management_mode.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_exemption_with_exemption_management_mode.py deleted file mode 100644 index e0a938bcd8ad..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_exemption_with_exemption_management_mode.py +++ /dev/null @@ -1,43 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python update_policy_exemption_with_exemption_management_mode.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.policy_exemptions.update( - scope="subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", - policy_exemption_name="DemoExpensiveVM", - parameters={"properties": {"exemptionManagementMode": "Admin"}}, - ) - print(response) - - -# x-ms-original-file: 2026-01-01-preview/updatePolicyExemptionWithExemptionManagementMode.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_exemption_with_resource_selectors.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_exemption_with_resource_selectors.py deleted file mode 100644 index 1c8840c0b122..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_exemption_with_resource_selectors.py +++ /dev/null @@ -1,53 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.resource.policy import PolicyClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-resource-policy -# USAGE - python update_policy_exemption_with_resource_selectors.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = PolicyClient( - credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", - ) - - response = client.policy_exemptions.update( - scope="subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", - policy_exemption_name="DemoExpensiveVM", - parameters={ - "properties": { - "assignmentScopeValidation": "Default", - "resourceSelectors": [ - { - "name": "SDPRegions", - "selectors": [{"in": ["eastus2euap", "centraluseuap"], "kind": "resourceLocation"}], - } - ], - } - }, - ) - print(response) - - -# x-ms-original-file: 2026-01-01-preview/updatePolicyExemptionWithResourceSelectors.json -if __name__ == "__main__": - main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_assignments_operations.py index b08fd9113784..f462d48864b6 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_assignments_operations.py @@ -56,12 +56,16 @@ def test_policy_assignments_create_by_id(self, resource_group): "nonComplianceMessages": [{"message": "str", "policyDefinitionReferenceId": "str"}], "notScopes": ["str"], "overrides": [ - {"kind": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}], "value": "str"} + { + "kind": "str", + "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"], "progress": 0}], + "value": "str", + } ], "parameters": {"str": {"value": {}}}, "policyDefinitionId": "str", "resourceSelectors": [ - {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}]} + {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"], "progress": 0}]} ], "scope": "str", "selfServeExemptionSettings": {"enabled": bool, "policyDefinitionReferenceIds": ["str"]}, @@ -96,10 +100,14 @@ def test_policy_assignments_update_by_id(self, resource_group): "location": "str", "properties": { "overrides": [ - {"kind": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}], "value": "str"} + { + "kind": "str", + "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"], "progress": 0}], + "value": "str", + } ], "resourceSelectors": [ - {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}]} + {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"], "progress": 0}]} ], "selfServeExemptionSettings": {"enabled": bool, "policyDefinitionReferenceIds": ["str"]}, }, @@ -159,12 +167,16 @@ def test_policy_assignments_create(self, resource_group): "nonComplianceMessages": [{"message": "str", "policyDefinitionReferenceId": "str"}], "notScopes": ["str"], "overrides": [ - {"kind": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}], "value": "str"} + { + "kind": "str", + "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"], "progress": 0}], + "value": "str", + } ], "parameters": {"str": {"value": {}}}, "policyDefinitionId": "str", "resourceSelectors": [ - {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}]} + {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"], "progress": 0}]} ], "scope": "str", "selfServeExemptionSettings": {"enabled": bool, "policyDefinitionReferenceIds": ["str"]}, @@ -200,10 +212,14 @@ def test_policy_assignments_update(self, resource_group): "location": "str", "properties": { "overrides": [ - {"kind": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}], "value": "str"} + { + "kind": "str", + "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"], "progress": 0}], + "value": "str", + } ], "resourceSelectors": [ - {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}]} + {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"], "progress": 0}]} ], "selfServeExemptionSettings": {"enabled": bool, "policyDefinitionReferenceIds": ["str"]}, }, diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_assignments_operations_async.py b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_assignments_operations_async.py index ddcc10c1b811..3a33014b178d 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_assignments_operations_async.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_assignments_operations_async.py @@ -57,12 +57,16 @@ async def test_policy_assignments_create_by_id(self, resource_group): "nonComplianceMessages": [{"message": "str", "policyDefinitionReferenceId": "str"}], "notScopes": ["str"], "overrides": [ - {"kind": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}], "value": "str"} + { + "kind": "str", + "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"], "progress": 0}], + "value": "str", + } ], "parameters": {"str": {"value": {}}}, "policyDefinitionId": "str", "resourceSelectors": [ - {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}]} + {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"], "progress": 0}]} ], "scope": "str", "selfServeExemptionSettings": {"enabled": bool, "policyDefinitionReferenceIds": ["str"]}, @@ -97,10 +101,14 @@ async def test_policy_assignments_update_by_id(self, resource_group): "location": "str", "properties": { "overrides": [ - {"kind": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}], "value": "str"} + { + "kind": "str", + "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"], "progress": 0}], + "value": "str", + } ], "resourceSelectors": [ - {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}]} + {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"], "progress": 0}]} ], "selfServeExemptionSettings": {"enabled": bool, "policyDefinitionReferenceIds": ["str"]}, }, @@ -160,12 +168,16 @@ async def test_policy_assignments_create(self, resource_group): "nonComplianceMessages": [{"message": "str", "policyDefinitionReferenceId": "str"}], "notScopes": ["str"], "overrides": [ - {"kind": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}], "value": "str"} + { + "kind": "str", + "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"], "progress": 0}], + "value": "str", + } ], "parameters": {"str": {"value": {}}}, "policyDefinitionId": "str", "resourceSelectors": [ - {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}]} + {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"], "progress": 0}]} ], "scope": "str", "selfServeExemptionSettings": {"enabled": bool, "policyDefinitionReferenceIds": ["str"]}, @@ -201,10 +213,14 @@ async def test_policy_assignments_update(self, resource_group): "location": "str", "properties": { "overrides": [ - {"kind": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}], "value": "str"} + { + "kind": "str", + "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"], "progress": 0}], + "value": "str", + } ], "resourceSelectors": [ - {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}]} + {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"], "progress": 0}]} ], "selfServeExemptionSettings": {"enabled": bool, "policyDefinitionReferenceIds": ["str"]}, }, diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_enrollments_operations.py b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_enrollments_operations.py deleted file mode 100644 index 126e0238f855..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_enrollments_operations.py +++ /dev/null @@ -1,139 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from azure.mgmt.resource.policy import PolicyClient - -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy - -AZURE_LOCATION = "eastus" - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestPolicyPolicyEnrollmentsOperations(AzureMgmtRecordedTestCase): - def setup_method(self, method): - self.client = self.create_mgmt_client(PolicyClient) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_enrollments_get(self, resource_group): - response = self.client.policy_enrollments.get( - scope="str", - policy_enrollment_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_enrollments_create_or_update(self, resource_group): - response = self.client.policy_enrollments.create_or_update( - scope="str", - policy_enrollment_name="str", - parameters={ - "eTag": "str", - "id": "str", - "name": "str", - "properties": { - "policyAssignmentId": "str", - "assignmentScopeValidation": "str", - "description": "str", - "displayName": "str", - "metadata": {}, - "policyAssignmentInstanceId": "str", - "policyDefinitionReferenceIds": ["str"], - "resourceSelectors": [ - {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}]} - ], - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_enrollments_update(self, resource_group): - response = self.client.policy_enrollments.update( - scope="str", - policy_enrollment_name="str", - parameters={ - "properties": { - "assignmentScopeValidation": "str", - "resourceSelectors": [ - {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}]} - ], - } - }, - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_enrollments_delete(self, resource_group): - response = self.client.policy_enrollments.delete( - scope="str", - policy_enrollment_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_enrollments_list_for_resource_group(self, resource_group): - response = self.client.policy_enrollments.list_for_resource_group( - resource_group_name=resource_group.name, - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_enrollments_list_for_management_group(self, resource_group): - response = self.client.policy_enrollments.list_for_management_group( - management_group_id="str", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_enrollments_list(self, resource_group): - response = self.client.policy_enrollments.list() - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_enrollments_list_for_resource(self, resource_group): - response = self.client.policy_enrollments.list_for_resource( - resource_group_name=resource_group.name, - resource_provider_namespace="str", - parent_resource_path="str", - resource_type="str", - resource_name="str", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_enrollments_operations_async.py b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_enrollments_operations_async.py deleted file mode 100644 index ca329d63ec78..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_enrollments_operations_async.py +++ /dev/null @@ -1,140 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from azure.mgmt.resource.policy.aio import PolicyClient - -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer -from devtools_testutils.aio import recorded_by_proxy_async - -AZURE_LOCATION = "eastus" - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestPolicyPolicyEnrollmentsOperationsAsync(AzureMgmtRecordedTestCase): - def setup_method(self, method): - self.client = self.create_mgmt_client(PolicyClient, is_async=True) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_enrollments_get(self, resource_group): - response = await self.client.policy_enrollments.get( - scope="str", - policy_enrollment_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_enrollments_create_or_update(self, resource_group): - response = await self.client.policy_enrollments.create_or_update( - scope="str", - policy_enrollment_name="str", - parameters={ - "eTag": "str", - "id": "str", - "name": "str", - "properties": { - "policyAssignmentId": "str", - "assignmentScopeValidation": "str", - "description": "str", - "displayName": "str", - "metadata": {}, - "policyAssignmentInstanceId": "str", - "policyDefinitionReferenceIds": ["str"], - "resourceSelectors": [ - {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}]} - ], - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_enrollments_update(self, resource_group): - response = await self.client.policy_enrollments.update( - scope="str", - policy_enrollment_name="str", - parameters={ - "properties": { - "assignmentScopeValidation": "str", - "resourceSelectors": [ - {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}]} - ], - } - }, - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_enrollments_delete(self, resource_group): - response = await self.client.policy_enrollments.delete( - scope="str", - policy_enrollment_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_enrollments_list_for_resource_group(self, resource_group): - response = self.client.policy_enrollments.list_for_resource_group( - resource_group_name=resource_group.name, - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_enrollments_list_for_management_group(self, resource_group): - response = self.client.policy_enrollments.list_for_management_group( - management_group_id="str", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_enrollments_list(self, resource_group): - response = self.client.policy_enrollments.list() - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_enrollments_list_for_resource(self, resource_group): - response = self.client.policy_enrollments.list_for_resource( - resource_group_name=resource_group.name, - resource_provider_namespace="str", - parent_resource_path="str", - resource_type="str", - resource_name="str", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_exemptions_operations.py b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_exemptions_operations.py deleted file mode 100644 index 33f7f25772d1..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_exemptions_operations.py +++ /dev/null @@ -1,141 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from azure.mgmt.resource.policy import PolicyClient - -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy - -AZURE_LOCATION = "eastus" - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestPolicyPolicyExemptionsOperations(AzureMgmtRecordedTestCase): - def setup_method(self, method): - self.client = self.create_mgmt_client(PolicyClient) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_exemptions_get(self, resource_group): - response = self.client.policy_exemptions.get( - scope="str", - policy_exemption_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_exemptions_create_or_update(self, resource_group): - response = self.client.policy_exemptions.create_or_update( - scope="str", - policy_exemption_name="str", - parameters={ - "id": "str", - "name": "str", - "properties": { - "exemptionCategory": "str", - "policyAssignmentId": "str", - "assignmentScopeValidation": "str", - "description": "str", - "displayName": "str", - "exemptionManagementMode": "str", - "expiresOn": "2020-02-20 00:00:00", - "metadata": {}, - "policyDefinitionReferenceIds": ["str"], - "resourceSelectors": [ - {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}]} - ], - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_exemptions_update(self, resource_group): - response = self.client.policy_exemptions.update( - scope="str", - policy_exemption_name="str", - parameters={ - "properties": { - "assignmentScopeValidation": "str", - "exemptionManagementMode": "str", - "resourceSelectors": [ - {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}]} - ], - } - }, - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_exemptions_delete(self, resource_group): - response = self.client.policy_exemptions.delete( - scope="str", - policy_exemption_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_exemptions_list_for_resource_group(self, resource_group): - response = self.client.policy_exemptions.list_for_resource_group( - resource_group_name=resource_group.name, - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_exemptions_list_for_management_group(self, resource_group): - response = self.client.policy_exemptions.list_for_management_group( - management_group_id="str", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_exemptions_list(self, resource_group): - response = self.client.policy_exemptions.list() - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_exemptions_list_for_resource(self, resource_group): - response = self.client.policy_exemptions.list_for_resource( - resource_group_name=resource_group.name, - resource_provider_namespace="str", - parent_resource_path="str", - resource_type="str", - resource_name="str", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_exemptions_operations_async.py b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_exemptions_operations_async.py deleted file mode 100644 index 2c3ffbcf7c6c..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_exemptions_operations_async.py +++ /dev/null @@ -1,142 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from azure.mgmt.resource.policy.aio import PolicyClient - -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer -from devtools_testutils.aio import recorded_by_proxy_async - -AZURE_LOCATION = "eastus" - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestPolicyPolicyExemptionsOperationsAsync(AzureMgmtRecordedTestCase): - def setup_method(self, method): - self.client = self.create_mgmt_client(PolicyClient, is_async=True) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_exemptions_get(self, resource_group): - response = await self.client.policy_exemptions.get( - scope="str", - policy_exemption_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_exemptions_create_or_update(self, resource_group): - response = await self.client.policy_exemptions.create_or_update( - scope="str", - policy_exemption_name="str", - parameters={ - "id": "str", - "name": "str", - "properties": { - "exemptionCategory": "str", - "policyAssignmentId": "str", - "assignmentScopeValidation": "str", - "description": "str", - "displayName": "str", - "exemptionManagementMode": "str", - "expiresOn": "2020-02-20 00:00:00", - "metadata": {}, - "policyDefinitionReferenceIds": ["str"], - "resourceSelectors": [ - {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}]} - ], - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_exemptions_update(self, resource_group): - response = await self.client.policy_exemptions.update( - scope="str", - policy_exemption_name="str", - parameters={ - "properties": { - "assignmentScopeValidation": "str", - "exemptionManagementMode": "str", - "resourceSelectors": [ - {"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}]} - ], - } - }, - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_exemptions_delete(self, resource_group): - response = await self.client.policy_exemptions.delete( - scope="str", - policy_exemption_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_exemptions_list_for_resource_group(self, resource_group): - response = self.client.policy_exemptions.list_for_resource_group( - resource_group_name=resource_group.name, - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_exemptions_list_for_management_group(self, resource_group): - response = self.client.policy_exemptions.list_for_management_group( - management_group_id="str", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_exemptions_list(self, resource_group): - response = self.client.policy_exemptions.list() - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_exemptions_list_for_resource(self, resource_group): - response = self.client.policy_exemptions.list_for_resource( - resource_group_name=resource_group.name, - resource_provider_namespace="str", - parent_resource_path="str", - resource_type="str", - resource_name="str", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_variable_values_operations.py b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_variable_values_operations.py deleted file mode 100644 index 4d4b27b72a24..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_variable_values_operations.py +++ /dev/null @@ -1,137 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from azure.mgmt.resource.policy import PolicyClient - -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy - -AZURE_LOCATION = "eastus" - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestPolicyVariableValuesOperations(AzureMgmtRecordedTestCase): - def setup_method(self, method): - self.client = self.create_mgmt_client(PolicyClient) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_variable_values_get(self, resource_group): - response = self.client.variable_values.get( - variable_name="str", - variable_value_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_variable_values_create_or_update(self, resource_group): - response = self.client.variable_values.create_or_update( - variable_name="str", - variable_value_name="str", - parameters={ - "id": "str", - "name": "str", - "properties": {"values": [{"columnName": "str", "columnValue": {}}]}, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_variable_values_delete(self, resource_group): - response = self.client.variable_values.delete( - variable_name="str", - variable_value_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_variable_values_list(self, resource_group): - response = self.client.variable_values.list( - variable_name="str", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_variable_values_get_at_management_group(self, resource_group): - response = self.client.variable_values.get_at_management_group( - management_group_id="str", - variable_name="str", - variable_value_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_variable_values_create_or_update_at_management_group(self, resource_group): - response = self.client.variable_values.create_or_update_at_management_group( - management_group_id="str", - variable_name="str", - variable_value_name="str", - parameters={ - "id": "str", - "name": "str", - "properties": {"values": [{"columnName": "str", "columnValue": {}}]}, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_variable_values_delete_at_management_group(self, resource_group): - response = self.client.variable_values.delete_at_management_group( - management_group_id="str", - variable_name="str", - variable_value_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_variable_values_list_for_management_group(self, resource_group): - response = self.client.variable_values.list_for_management_group( - management_group_id="str", - variable_name="str", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_variable_values_operations_async.py b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_variable_values_operations_async.py deleted file mode 100644 index b8ee1b7d85b2..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_variable_values_operations_async.py +++ /dev/null @@ -1,138 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from azure.mgmt.resource.policy.aio import PolicyClient - -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer -from devtools_testutils.aio import recorded_by_proxy_async - -AZURE_LOCATION = "eastus" - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestPolicyVariableValuesOperationsAsync(AzureMgmtRecordedTestCase): - def setup_method(self, method): - self.client = self.create_mgmt_client(PolicyClient, is_async=True) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_variable_values_get(self, resource_group): - response = await self.client.variable_values.get( - variable_name="str", - variable_value_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_variable_values_create_or_update(self, resource_group): - response = await self.client.variable_values.create_or_update( - variable_name="str", - variable_value_name="str", - parameters={ - "id": "str", - "name": "str", - "properties": {"values": [{"columnName": "str", "columnValue": {}}]}, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_variable_values_delete(self, resource_group): - response = await self.client.variable_values.delete( - variable_name="str", - variable_value_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_variable_values_list(self, resource_group): - response = self.client.variable_values.list( - variable_name="str", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_variable_values_get_at_management_group(self, resource_group): - response = await self.client.variable_values.get_at_management_group( - management_group_id="str", - variable_name="str", - variable_value_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_variable_values_create_or_update_at_management_group(self, resource_group): - response = await self.client.variable_values.create_or_update_at_management_group( - management_group_id="str", - variable_name="str", - variable_value_name="str", - parameters={ - "id": "str", - "name": "str", - "properties": {"values": [{"columnName": "str", "columnValue": {}}]}, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_variable_values_delete_at_management_group(self, resource_group): - response = await self.client.variable_values.delete_at_management_group( - management_group_id="str", - variable_name="str", - variable_value_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_variable_values_list_for_management_group(self, resource_group): - response = self.client.variable_values.list_for_management_group( - management_group_id="str", - variable_name="str", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_variables_operations.py b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_variables_operations.py deleted file mode 100644 index d9771bd90a31..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_variables_operations.py +++ /dev/null @@ -1,128 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from azure.mgmt.resource.policy import PolicyClient - -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy - -AZURE_LOCATION = "eastus" - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestPolicyVariablesOperations(AzureMgmtRecordedTestCase): - def setup_method(self, method): - self.client = self.create_mgmt_client(PolicyClient) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_variables_get(self, resource_group): - response = self.client.variables.get( - variable_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_variables_create_or_update(self, resource_group): - response = self.client.variables.create_or_update( - variable_name="str", - parameters={ - "id": "str", - "name": "str", - "properties": {"columns": [{"columnName": "str"}]}, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_variables_delete(self, resource_group): - response = self.client.variables.delete( - variable_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_variables_list(self, resource_group): - response = self.client.variables.list() - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_variables_get_at_management_group(self, resource_group): - response = self.client.variables.get_at_management_group( - management_group_id="str", - variable_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_variables_create_or_update_at_management_group(self, resource_group): - response = self.client.variables.create_or_update_at_management_group( - management_group_id="str", - variable_name="str", - parameters={ - "id": "str", - "name": "str", - "properties": {"columns": [{"columnName": "str"}]}, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_variables_delete_at_management_group(self, resource_group): - response = self.client.variables.delete_at_management_group( - management_group_id="str", - variable_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_variables_list_for_management_group(self, resource_group): - response = self.client.variables.list_for_management_group( - management_group_id="str", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_variables_operations_async.py b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_variables_operations_async.py deleted file mode 100644 index 3a80e76482eb..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_variables_operations_async.py +++ /dev/null @@ -1,129 +0,0 @@ -# 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) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from azure.mgmt.resource.policy.aio import PolicyClient - -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer -from devtools_testutils.aio import recorded_by_proxy_async - -AZURE_LOCATION = "eastus" - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestPolicyVariablesOperationsAsync(AzureMgmtRecordedTestCase): - def setup_method(self, method): - self.client = self.create_mgmt_client(PolicyClient, is_async=True) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_variables_get(self, resource_group): - response = await self.client.variables.get( - variable_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_variables_create_or_update(self, resource_group): - response = await self.client.variables.create_or_update( - variable_name="str", - parameters={ - "id": "str", - "name": "str", - "properties": {"columns": [{"columnName": "str"}]}, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_variables_delete(self, resource_group): - response = await self.client.variables.delete( - variable_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_variables_list(self, resource_group): - response = self.client.variables.list() - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_variables_get_at_management_group(self, resource_group): - response = await self.client.variables.get_at_management_group( - management_group_id="str", - variable_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_variables_create_or_update_at_management_group(self, resource_group): - response = await self.client.variables.create_or_update_at_management_group( - management_group_id="str", - variable_name="str", - parameters={ - "id": "str", - "name": "str", - "properties": {"columns": [{"columnName": "str"}]}, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str", - }, - "type": "str", - }, - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_variables_delete_at_management_group(self, resource_group): - response = await self.client.variables.delete_at_management_group( - management_group_id="str", - variable_name="str", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_variables_list_for_management_group(self, resource_group): - response = self.client.variables.list_for_management_group( - management_group_id="str", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/resources/azure-mgmt-resource-policy/pyproject.toml b/sdk/resources/azure-mgmt-resource-policy/pyproject.toml index d8b7599fa7b8..dd9683771d93 100644 --- a/sdk/resources/azure-mgmt-resource-policy/pyproject.toml +++ b/sdk/resources/azure-mgmt-resource-policy/pyproject.toml @@ -13,7 +13,7 @@ authors = [ description = "Microsoft Azure Policy Management Client Library for Python" license = "MIT" classifiers = [ - "Development Status :: 4 - Beta", + "Development Status :: 5 - Production/Stable", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", @@ -78,7 +78,7 @@ package_name = "azure-mgmt-resource-policy" package_nspkg = "azure-mgmt-resource-nspkg" package_pprint_name = "Resource Policy Management" package_doc_id = "" -is_stable = false +is_stable = true is_arm = true need_msrestazure = false need_azuremgmtcore = true diff --git a/sdk/resources/azure-mgmt-resource-policy/tsp-location.yaml b/sdk/resources/azure-mgmt-resource-policy/tsp-location.yaml index e98829b75173..50f999b5ce46 100644 --- a/sdk/resources/azure-mgmt-resource-policy/tsp-location.yaml +++ b/sdk/resources/azure-mgmt-resource-policy/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/resources/resource-manager/Microsoft.Authorization/policy -commit: fb93aacb4b6f5bcd058e6730b113f1fcdcba8157 +commit: 710828f4424a112000ac9a81896a8648f87b7548 repo: Azure/azure-rest-api-specs additionalDirectories: