diff --git a/sdk/resources/azure-mgmt-resource-policy/CHANGELOG.md b/sdk/resources/azure-mgmt-resource-policy/CHANGELOG.md index 728d2fbcb3f8..3bf063a62b77 100644 --- a/sdk/resources/azure-mgmt-resource-policy/CHANGELOG.md +++ b/sdk/resources/azure-mgmt-resource-policy/CHANGELOG.md @@ -1,7 +1,57 @@ # Release History +## 1.0.0b2 (2026-02-06) + +### Features Added + + - Client `PolicyClient` added operation group `policy_tokens` + - Enum `EnforcementMode` added member `ENROLL` + - Model `ErrorResponse` added property `error` + - Enum `OverrideKind` added member `DEFINITION_VERSION` + - Model `PolicyAssignment` added property `assignment_type` + - Model `PolicyAssignment` added property `instance_id` + - Model `PolicyDefinition` added property `external_evaluation_enforcement_settings` + - Model `PolicyDefinitionVersion` added property `external_evaluation_enforcement_settings` + - Added enum `AssignmentType` + - Added model `ErrorDetail` + - Added enum `ExternalEndpointResult` + - Added model `ExternalEvaluationEndpointInvocationResult` + - Added model `ExternalEvaluationEndpointSettings` + - Added model `ExternalEvaluationEnforcementSettings` + - Added model `PolicyLogInfo` + - Added model `PolicyTokenOperation` + - Added model `PolicyTokenRequest` + - Added model `PolicyTokenResponse` + - Added enum `PolicyTokenResult` + - Added model `ProxyResource` + - Added model `Resource` + +### Breaking Changes + + - Deleted client operation group `PolicyClient.policy_exemptions` + - Deleted client operation group `PolicyClient.variables` + - Deleted client operation group `PolicyClient.variable_values` + - Model `ErrorResponse` deleted its instance variable `code` + - Model `ErrorResponse` deleted its instance variable `message` + - Model `ErrorResponse` deleted its instance variable `target` + - Model `ErrorResponse` deleted its instance variable `details` + - Model `ErrorResponse` deleted its instance variable `additional_info` + - Property `value` of model `PolicyAssignmentListResult` is required + - Property `value` of model `PolicyDefinitionListResult` is required + - Property `value` of model `PolicyDefinitionVersionListResult` is required + - Property `value` of model `PolicySetDefinitionListResult` is required + - Property `value` of model `PolicySetDefinitionVersionListResult` is required + - Deleted model `AssignmentScopeValidation` + - Deleted model `ExemptionCategory` + - Deleted model `PolicyExemption` + - Deleted model `PolicyExemptionUpdate` + - Deleted model `PolicyVariableColumn` + - Deleted model `PolicyVariableValueColumnValue` + - Deleted model `Variable` + - Deleted model `VariableValue` + ## 1.0.0b1 (2026-02-04) ### Other Changes - - Initial version \ No newline at end of file + - Initial version diff --git a/sdk/resources/azure-mgmt-resource-policy/_metadata.json b/sdk/resources/azure-mgmt-resource-policy/_metadata.json index a92976f3f261..5d7f54bcefc7 100644 --- a/sdk/resources/azure-mgmt-resource-policy/_metadata.json +++ b/sdk/resources/azure-mgmt-resource-policy/_metadata.json @@ -1,11 +1,11 @@ { - "commit": "3805079312b2cd71f794e1a5a9b1e74e72e2986f", + "commit": "da3e3a42110d96609505c4bcb5b4d768341203a8", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.10.2", "use": [ "@autorest/python@6.48.0", "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/resources/resource-manager/Microsoft.Authorization/policy/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --package-mode=azure-mgmt --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --tag=package-policy-2023-04 --use=@autorest/python@6.48.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", + "autorest_command": "autorest specification/resources/resource-manager/Microsoft.Authorization/policy/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --package-mode=azure-mgmt --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --tag=package-policy-python --use=@autorest/python@6.48.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/resources/resource-manager/Microsoft.Authorization/policy/readme.md" } \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource-policy/apiview-properties.json b/sdk/resources/azure-mgmt-resource-policy/apiview-properties.json index 517a6d871ee6..169065a1625f 100644 --- a/sdk/resources/azure-mgmt-resource-policy/apiview-properties.json +++ b/sdk/resources/azure-mgmt-resource-policy/apiview-properties.json @@ -10,13 +10,19 @@ "azure.mgmt.resource.policy.models.DataPolicyManifest": null, "azure.mgmt.resource.policy.models.DataPolicyManifestListResult": null, "azure.mgmt.resource.policy.models.ErrorAdditionalInfo": null, + "azure.mgmt.resource.policy.models.ErrorDetail": null, "azure.mgmt.resource.policy.models.ErrorResponse": null, + "azure.mgmt.resource.policy.models.ExternalEvaluationEndpointInvocationResult": null, + "azure.mgmt.resource.policy.models.ExternalEvaluationEndpointSettings": null, + "azure.mgmt.resource.policy.models.ExternalEvaluationEnforcementSettings": null, "azure.mgmt.resource.policy.models.Identity": null, "azure.mgmt.resource.policy.models.NonComplianceMessage": null, "azure.mgmt.resource.policy.models.Override": null, "azure.mgmt.resource.policy.models.ParameterDefinitionsValue": null, "azure.mgmt.resource.policy.models.ParameterDefinitionsValueMetadata": null, "azure.mgmt.resource.policy.models.ParameterValuesValue": null, + "azure.mgmt.resource.policy.models.Resource": null, + "azure.mgmt.resource.policy.models.ProxyResource": null, "azure.mgmt.resource.policy.models.PolicyAssignment": null, "azure.mgmt.resource.policy.models.PolicyAssignmentListResult": null, "azure.mgmt.resource.policy.models.PolicyAssignmentUpdate": null, @@ -26,204 +32,156 @@ "azure.mgmt.resource.policy.models.PolicyDefinitionReference": null, "azure.mgmt.resource.policy.models.PolicyDefinitionVersion": null, "azure.mgmt.resource.policy.models.PolicyDefinitionVersionListResult": null, - "azure.mgmt.resource.policy.models.PolicyExemption": null, - "azure.mgmt.resource.policy.models.PolicyExemptionListResult": null, - "azure.mgmt.resource.policy.models.PolicyExemptionUpdate": null, + "azure.mgmt.resource.policy.models.PolicyLogInfo": null, "azure.mgmt.resource.policy.models.PolicySetDefinition": null, "azure.mgmt.resource.policy.models.PolicySetDefinitionListResult": null, "azure.mgmt.resource.policy.models.PolicySetDefinitionVersion": null, "azure.mgmt.resource.policy.models.PolicySetDefinitionVersionListResult": null, - "azure.mgmt.resource.policy.models.PolicyVariableColumn": null, - "azure.mgmt.resource.policy.models.PolicyVariableValueColumnValue": null, + "azure.mgmt.resource.policy.models.PolicyTokenOperation": null, + "azure.mgmt.resource.policy.models.PolicyTokenRequest": null, + "azure.mgmt.resource.policy.models.PolicyTokenResponse": null, "azure.mgmt.resource.policy.models.ResourceSelector": null, "azure.mgmt.resource.policy.models.ResourceTypeAliases": null, "azure.mgmt.resource.policy.models.Selector": null, "azure.mgmt.resource.policy.models.SystemData": null, "azure.mgmt.resource.policy.models.UserAssignedIdentitiesValue": null, - "azure.mgmt.resource.policy.models.Variable": null, - "azure.mgmt.resource.policy.models.VariableListResult": null, - "azure.mgmt.resource.policy.models.VariableValue": null, - "azure.mgmt.resource.policy.models.VariableValueListResult": null, - "azure.mgmt.resource.policy.models.AliasPatternType": null, - "azure.mgmt.resource.policy.models.AliasPathTokenType": null, - "azure.mgmt.resource.policy.models.AliasPathAttributes": null, - "azure.mgmt.resource.policy.models.AliasType": null, + "azure.mgmt.resource.policy.models.SelectorKind": null, + "azure.mgmt.resource.policy.models.OverrideKind": null, "azure.mgmt.resource.policy.models.CreatedByType": null, "azure.mgmt.resource.policy.models.PolicyType": null, "azure.mgmt.resource.policy.models.ParameterType": null, - "azure.mgmt.resource.policy.models.SelectorKind": null, - "azure.mgmt.resource.policy.models.OverrideKind": null, + "azure.mgmt.resource.policy.models.ExternalEndpointResult": null, "azure.mgmt.resource.policy.models.ResourceIdentityType": null, "azure.mgmt.resource.policy.models.EnforcementMode": null, - "azure.mgmt.resource.policy.models.ExemptionCategory": null, - "azure.mgmt.resource.policy.models.AssignmentScopeValidation": null, - "azure.mgmt.resource.policy.operations.DataPolicyManifestsOperations.get_by_policy_mode": null, - "azure.mgmt.resource.policy.aio.operations.DataPolicyManifestsOperations.get_by_policy_mode": null, - "azure.mgmt.resource.policy.operations.DataPolicyManifestsOperations.list": null, - "azure.mgmt.resource.policy.aio.operations.DataPolicyManifestsOperations.list": null, - "azure.mgmt.resource.policy.operations.PolicyDefinitionsOperations.create_or_update": null, - "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionsOperations.create_or_update": null, - "azure.mgmt.resource.policy.operations.PolicyDefinitionsOperations.delete": null, - "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionsOperations.delete": null, - "azure.mgmt.resource.policy.operations.PolicyDefinitionsOperations.get": null, - "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionsOperations.get": null, - "azure.mgmt.resource.policy.operations.PolicyDefinitionsOperations.get_built_in": null, - "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionsOperations.get_built_in": null, - "azure.mgmt.resource.policy.operations.PolicyDefinitionsOperations.create_or_update_at_management_group": null, - "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionsOperations.create_or_update_at_management_group": null, - "azure.mgmt.resource.policy.operations.PolicyDefinitionsOperations.delete_at_management_group": null, - "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionsOperations.delete_at_management_group": null, - "azure.mgmt.resource.policy.operations.PolicyDefinitionsOperations.get_at_management_group": null, - "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionsOperations.get_at_management_group": null, - "azure.mgmt.resource.policy.operations.PolicyDefinitionsOperations.list": null, - "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionsOperations.list": null, - "azure.mgmt.resource.policy.operations.PolicyDefinitionsOperations.list_built_in": null, - "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionsOperations.list_built_in": null, - "azure.mgmt.resource.policy.operations.PolicyDefinitionsOperations.list_by_management_group": null, - "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionsOperations.list_by_management_group": null, + "azure.mgmt.resource.policy.models.AssignmentType": null, + "azure.mgmt.resource.policy.models.AliasPatternType": null, + "azure.mgmt.resource.policy.models.AliasPathTokenType": null, + "azure.mgmt.resource.policy.models.AliasPathAttributes": null, + "azure.mgmt.resource.policy.models.AliasType": null, + "azure.mgmt.resource.policy.models.PolicyTokenResult": null, + "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.get": null, + "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.get": null, + "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.create": null, + "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.create": null, + "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.update": null, + "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.update": null, + "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.delete": null, + "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.delete": null, + "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.list_for_management_group": null, + "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.list_for_management_group": null, + "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.list": null, + "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.list": null, + "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.list_for_resource": null, + "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.list_for_resource": null, + "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.list_for_resource_group": null, + "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.list_for_resource_group": null, + "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.delete_by_id": null, + "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.delete_by_id": null, + "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.create_by_id": null, + "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.create_by_id": null, + "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.get_by_id": null, + "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.get_by_id": null, + "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.update_by_id": null, + "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.update_by_id": null, "azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations.list_all_builtins": null, "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.list_all_builtins": null, - "azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations.list_all_at_management_group": null, - "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.list_all_at_management_group": null, - "azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations.list_all": null, - "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.list_all": null, - "azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations.create_or_update": null, - "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.create_or_update": null, - "azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations.delete": null, - "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.delete": null, - "azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations.get": null, - "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.get": null, + "azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations.list_built_in": null, + "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.list_built_in": null, "azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations.get_built_in": null, "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.get_built_in": null, + "azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations.list_all_at_management_group": null, + "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.list_all_at_management_group": null, + "azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations.list_by_management_group": null, + "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.list_by_management_group": null, + "azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations.get_at_management_group": null, + "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.get_at_management_group": null, "azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations.create_or_update_at_management_group": null, "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.create_or_update_at_management_group": null, "azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations.delete_at_management_group": null, "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.delete_at_management_group": null, - "azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations.get_at_management_group": null, - "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.get_at_management_group": null, + "azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations.list_all": null, + "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.list_all": null, "azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations.list": null, "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.list": null, - "azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations.list_built_in": null, - "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.list_built_in": null, - "azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations.list_by_management_group": null, - "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.list_by_management_group": null, - "azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations.create_or_update": null, - "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations.create_or_update": null, - "azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations.delete": null, - "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations.delete": null, - "azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations.get": null, - "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations.get": null, - "azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations.get_built_in": null, - "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations.get_built_in": null, - "azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations.list": null, - "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations.list": null, - "azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations.list_built_in": null, - "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations.list_built_in": null, - "azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations.create_or_update_at_management_group": null, - "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations.create_or_update_at_management_group": null, - "azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations.delete_at_management_group": null, - "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations.delete_at_management_group": null, - "azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations.get_at_management_group": null, - "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations.get_at_management_group": null, - "azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations.list_by_management_group": null, - "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations.list_by_management_group": null, + "azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations.get": null, + "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.get": null, + "azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations.create_or_update": null, + "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.create_or_update": null, + "azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations.delete": null, + "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations.delete": null, "azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations.list_all_builtins": null, "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.list_all_builtins": null, + "azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations.list_built_in": null, + "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.list_built_in": null, + "azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations.get_built_in": null, + "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.get_built_in": null, "azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations.list_all_at_management_group": null, "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.list_all_at_management_group": null, + "azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations.list_by_management_group": null, + "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.list_by_management_group": null, + "azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations.get_at_management_group": null, + "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.get_at_management_group": null, + "azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations.create_or_update_at_management_group": null, + "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.create_or_update_at_management_group": null, + "azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations.delete_at_management_group": null, + "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.delete_at_management_group": null, "azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations.list_all": null, "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.list_all": null, + "azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations.list": null, + "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.list": null, + "azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations.get": null, + "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.get": null, "azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations.create_or_update": null, "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.create_or_update": null, "azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations.delete": null, "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.delete": null, - "azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations.get": null, - "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.get": null, - "azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations.get_built_in": null, - "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.get_built_in": null, - "azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations.list": null, - "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.list": null, - "azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations.list_built_in": null, - "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.list_built_in": null, - "azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations.create_or_update_at_management_group": null, - "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.create_or_update_at_management_group": null, - "azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations.delete_at_management_group": null, - "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.delete_at_management_group": null, - "azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations.get_at_management_group": null, - "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.get_at_management_group": null, - "azure.mgmt.resource.policy.operations.PolicySetDefinitionVersionsOperations.list_by_management_group": null, - "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionVersionsOperations.list_by_management_group": null, - "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.delete": null, - "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.delete": null, - "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.create": null, - "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.create": null, - "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.get": null, - "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.get": null, - "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.update": null, - "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.update": null, - "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.list_for_resource_group": null, - "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.list_for_resource_group": null, - "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.list_for_resource": null, - "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.list_for_resource": null, - "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.list_for_management_group": null, - "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.list_for_management_group": null, - "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.list": null, - "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.list": null, - "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.delete_by_id": null, - "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.delete_by_id": null, - "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.create_by_id": null, - "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.create_by_id": null, - "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.get_by_id": null, - "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.get_by_id": null, - "azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations.update_by_id": null, - "azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations.update_by_id": null, - "azure.mgmt.resource.policy.operations.PolicyExemptionsOperations.delete": null, - "azure.mgmt.resource.policy.aio.operations.PolicyExemptionsOperations.delete": null, - "azure.mgmt.resource.policy.operations.PolicyExemptionsOperations.create_or_update": null, - "azure.mgmt.resource.policy.aio.operations.PolicyExemptionsOperations.create_or_update": null, - "azure.mgmt.resource.policy.operations.PolicyExemptionsOperations.get": null, - "azure.mgmt.resource.policy.aio.operations.PolicyExemptionsOperations.get": null, - "azure.mgmt.resource.policy.operations.PolicyExemptionsOperations.update": null, - "azure.mgmt.resource.policy.aio.operations.PolicyExemptionsOperations.update": null, - "azure.mgmt.resource.policy.operations.PolicyExemptionsOperations.list": null, - "azure.mgmt.resource.policy.aio.operations.PolicyExemptionsOperations.list": null, - "azure.mgmt.resource.policy.operations.PolicyExemptionsOperations.list_for_resource_group": null, - "azure.mgmt.resource.policy.aio.operations.PolicyExemptionsOperations.list_for_resource_group": null, - "azure.mgmt.resource.policy.operations.PolicyExemptionsOperations.list_for_resource": null, - "azure.mgmt.resource.policy.aio.operations.PolicyExemptionsOperations.list_for_resource": null, - "azure.mgmt.resource.policy.operations.PolicyExemptionsOperations.list_for_management_group": null, - "azure.mgmt.resource.policy.aio.operations.PolicyExemptionsOperations.list_for_management_group": null, - "azure.mgmt.resource.policy.operations.VariablesOperations.delete": null, - "azure.mgmt.resource.policy.aio.operations.VariablesOperations.delete": null, - "azure.mgmt.resource.policy.operations.VariablesOperations.create_or_update": null, - "azure.mgmt.resource.policy.aio.operations.VariablesOperations.create_or_update": null, - "azure.mgmt.resource.policy.operations.VariablesOperations.get": null, - "azure.mgmt.resource.policy.aio.operations.VariablesOperations.get": null, - "azure.mgmt.resource.policy.operations.VariablesOperations.delete_at_management_group": null, - "azure.mgmt.resource.policy.aio.operations.VariablesOperations.delete_at_management_group": null, - "azure.mgmt.resource.policy.operations.VariablesOperations.create_or_update_at_management_group": null, - "azure.mgmt.resource.policy.aio.operations.VariablesOperations.create_or_update_at_management_group": null, - "azure.mgmt.resource.policy.operations.VariablesOperations.get_at_management_group": null, - "azure.mgmt.resource.policy.aio.operations.VariablesOperations.get_at_management_group": null, - "azure.mgmt.resource.policy.operations.VariablesOperations.list": null, - "azure.mgmt.resource.policy.aio.operations.VariablesOperations.list": null, - "azure.mgmt.resource.policy.operations.VariablesOperations.list_for_management_group": null, - "azure.mgmt.resource.policy.aio.operations.VariablesOperations.list_for_management_group": null, - "azure.mgmt.resource.policy.operations.VariableValuesOperations.delete": null, - "azure.mgmt.resource.policy.aio.operations.VariableValuesOperations.delete": null, - "azure.mgmt.resource.policy.operations.VariableValuesOperations.create_or_update": null, - "azure.mgmt.resource.policy.aio.operations.VariableValuesOperations.create_or_update": null, - "azure.mgmt.resource.policy.operations.VariableValuesOperations.get": null, - "azure.mgmt.resource.policy.aio.operations.VariableValuesOperations.get": null, - "azure.mgmt.resource.policy.operations.VariableValuesOperations.list": null, - "azure.mgmt.resource.policy.aio.operations.VariableValuesOperations.list": null, - "azure.mgmt.resource.policy.operations.VariableValuesOperations.list_for_management_group": null, - "azure.mgmt.resource.policy.aio.operations.VariableValuesOperations.list_for_management_group": null, - "azure.mgmt.resource.policy.operations.VariableValuesOperations.delete_at_management_group": null, - "azure.mgmt.resource.policy.aio.operations.VariableValuesOperations.delete_at_management_group": null, - "azure.mgmt.resource.policy.operations.VariableValuesOperations.create_or_update_at_management_group": null, - "azure.mgmt.resource.policy.aio.operations.VariableValuesOperations.create_or_update_at_management_group": null, - "azure.mgmt.resource.policy.operations.VariableValuesOperations.get_at_management_group": null, - "azure.mgmt.resource.policy.aio.operations.VariableValuesOperations.get_at_management_group": null + "azure.mgmt.resource.policy.operations.PolicyDefinitionsOperations.list_built_in": null, + "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionsOperations.list_built_in": null, + "azure.mgmt.resource.policy.operations.PolicyDefinitionsOperations.get_built_in": null, + "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionsOperations.get_built_in": null, + "azure.mgmt.resource.policy.operations.PolicyDefinitionsOperations.list_by_management_group": null, + "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionsOperations.list_by_management_group": null, + "azure.mgmt.resource.policy.operations.PolicyDefinitionsOperations.get_at_management_group": null, + "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionsOperations.get_at_management_group": null, + "azure.mgmt.resource.policy.operations.PolicyDefinitionsOperations.create_or_update_at_management_group": null, + "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionsOperations.create_or_update_at_management_group": null, + "azure.mgmt.resource.policy.operations.PolicyDefinitionsOperations.delete_at_management_group": null, + "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionsOperations.delete_at_management_group": null, + "azure.mgmt.resource.policy.operations.PolicyDefinitionsOperations.list": null, + "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionsOperations.list": null, + "azure.mgmt.resource.policy.operations.PolicyDefinitionsOperations.get": null, + "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionsOperations.get": null, + "azure.mgmt.resource.policy.operations.PolicyDefinitionsOperations.create_or_update": null, + "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionsOperations.create_or_update": null, + "azure.mgmt.resource.policy.operations.PolicyDefinitionsOperations.delete": null, + "azure.mgmt.resource.policy.aio.operations.PolicyDefinitionsOperations.delete": null, + "azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations.list_built_in": null, + "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations.list_built_in": null, + "azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations.get_built_in": null, + "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations.get_built_in": null, + "azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations.list_by_management_group": null, + "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations.list_by_management_group": null, + "azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations.get_at_management_group": null, + "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations.get_at_management_group": null, + "azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations.create_or_update_at_management_group": null, + "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations.create_or_update_at_management_group": null, + "azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations.delete_at_management_group": null, + "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations.delete_at_management_group": null, + "azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations.list": null, + "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations.list": null, + "azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations.get": null, + "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations.get": null, + "azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations.create_or_update": null, + "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations.create_or_update": null, + "azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations.delete": null, + "azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations.delete": null, + "azure.mgmt.resource.policy.operations.PolicyTokensOperations.acquire_at_management_group": null, + "azure.mgmt.resource.policy.aio.operations.PolicyTokensOperations.acquire_at_management_group": null, + "azure.mgmt.resource.policy.operations.PolicyTokensOperations.acquire": null, + "azure.mgmt.resource.policy.aio.operations.PolicyTokensOperations.acquire": null, + "azure.mgmt.resource.policy.operations.DataPolicyManifestsOperations.get_by_policy_mode": null, + "azure.mgmt.resource.policy.aio.operations.DataPolicyManifestsOperations.get_by_policy_mode": null, + "azure.mgmt.resource.policy.operations.DataPolicyManifestsOperations.list": null, + "azure.mgmt.resource.policy.aio.operations.DataPolicyManifestsOperations.list": null } } \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/_policy_client.py b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/_policy_client.py index 6d154e35759f..38e8766aef78 100644 --- a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/_policy_client.py @@ -25,11 +25,9 @@ PolicyAssignmentsOperations, PolicyDefinitionVersionsOperations, PolicyDefinitionsOperations, - PolicyExemptionsOperations, PolicySetDefinitionVersionsOperations, PolicySetDefinitionsOperations, - VariableValuesOperations, - VariablesOperations, + PolicyTokensOperations, ) if TYPE_CHECKING: @@ -40,28 +38,24 @@ class PolicyClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Policy Client. - :ivar data_policy_manifests: DataPolicyManifestsOperations operations - :vartype data_policy_manifests: - azure.mgmt.resource.policy.operations.DataPolicyManifestsOperations - :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.operations.PolicyDefinitionsOperations + :ivar policy_assignments: PolicyAssignmentsOperations operations + :vartype policy_assignments: azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations :ivar policy_definition_versions: PolicyDefinitionVersionsOperations operations :vartype policy_definition_versions: azure.mgmt.resource.policy.operations.PolicyDefinitionVersionsOperations - :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 policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.operations.PolicyAssignmentsOperations - :ivar policy_exemptions: PolicyExemptionsOperations operations - :vartype policy_exemptions: azure.mgmt.resource.policy.operations.PolicyExemptionsOperations - :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_definitions: PolicyDefinitionsOperations operations + :vartype policy_definitions: azure.mgmt.resource.policy.operations.PolicyDefinitionsOperations + :ivar policy_set_definitions: PolicySetDefinitionsOperations operations + :vartype policy_set_definitions: + azure.mgmt.resource.policy.operations.PolicySetDefinitionsOperations + :ivar policy_tokens: PolicyTokensOperations operations + :vartype policy_tokens: azure.mgmt.resource.policy.operations.PolicyTokensOperations + :ivar data_policy_manifests: DataPolicyManifestsOperations operations + :vartype data_policy_manifests: + azure.mgmt.resource.policy.operations.DataPolicyManifestsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. @@ -119,29 +113,25 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.data_policy_manifests = DataPolicyManifestsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.policy_definitions = PolicyDefinitionsOperations( + self.policy_assignments = PolicyAssignmentsOperations( self._client, self._config, self._serialize, self._deserialize ) self.policy_definition_versions = PolicyDefinitionVersionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.policy_set_definitions = PolicySetDefinitionsOperations( + self.policy_set_definition_versions = PolicySetDefinitionVersionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.policy_set_definition_versions = PolicySetDefinitionVersionsOperations( + self.policy_definitions = PolicyDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.policy_assignments = PolicyAssignmentsOperations( + self.policy_set_definitions = PolicySetDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.policy_exemptions = PolicyExemptionsOperations( + self.policy_tokens = PolicyTokensOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_policy_manifests = DataPolicyManifestsOperations( 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) def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. 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 e5754a47ce68..c47f66669f1b 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.0b1" +VERSION = "1.0.0" diff --git a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/aio/_policy_client.py index 7918f89e1426..75b9a40280bd 100644 --- a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/aio/_policy_client.py @@ -25,11 +25,9 @@ PolicyAssignmentsOperations, PolicyDefinitionVersionsOperations, PolicyDefinitionsOperations, - PolicyExemptionsOperations, PolicySetDefinitionVersionsOperations, PolicySetDefinitionsOperations, - VariableValuesOperations, - VariablesOperations, + PolicyTokensOperations, ) if TYPE_CHECKING: @@ -40,31 +38,26 @@ class PolicyClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Policy Client. - :ivar data_policy_manifests: DataPolicyManifestsOperations operations - :vartype data_policy_manifests: - azure.mgmt.resource.policy.aio.operations.DataPolicyManifestsOperations - :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: - azure.mgmt.resource.policy.aio.operations.PolicyDefinitionsOperations + :ivar policy_assignments: PolicyAssignmentsOperations operations + :vartype policy_assignments: + azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations :ivar policy_definition_versions: PolicyDefinitionVersionsOperations operations :vartype policy_definition_versions: azure.mgmt.resource.policy.aio.operations.PolicyDefinitionVersionsOperations - :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 policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: - azure.mgmt.resource.policy.aio.operations.PolicyAssignmentsOperations - :ivar policy_exemptions: PolicyExemptionsOperations operations - :vartype policy_exemptions: - azure.mgmt.resource.policy.aio.operations.PolicyExemptionsOperations - :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_definitions: PolicyDefinitionsOperations operations + :vartype policy_definitions: + azure.mgmt.resource.policy.aio.operations.PolicyDefinitionsOperations + :ivar policy_set_definitions: PolicySetDefinitionsOperations operations + :vartype policy_set_definitions: + azure.mgmt.resource.policy.aio.operations.PolicySetDefinitionsOperations + :ivar policy_tokens: PolicyTokensOperations operations + :vartype policy_tokens: azure.mgmt.resource.policy.aio.operations.PolicyTokensOperations + :ivar data_policy_manifests: DataPolicyManifestsOperations operations + :vartype data_policy_manifests: + azure.mgmt.resource.policy.aio.operations.DataPolicyManifestsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. @@ -124,29 +117,25 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.data_policy_manifests = DataPolicyManifestsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.policy_definitions = PolicyDefinitionsOperations( + self.policy_assignments = PolicyAssignmentsOperations( self._client, self._config, self._serialize, self._deserialize ) self.policy_definition_versions = PolicyDefinitionVersionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.policy_set_definitions = PolicySetDefinitionsOperations( + self.policy_set_definition_versions = PolicySetDefinitionVersionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.policy_set_definition_versions = PolicySetDefinitionVersionsOperations( + self.policy_definitions = PolicyDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.policy_assignments = PolicyAssignmentsOperations( + self.policy_set_definitions = PolicySetDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.policy_exemptions = PolicyExemptionsOperations( + self.policy_tokens = PolicyTokensOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_policy_manifests = DataPolicyManifestsOperations( 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) def _send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any 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 f302859689f6..14d63c274848 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 @@ -12,30 +12,26 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._operations import DataPolicyManifestsOperations # type: ignore -from ._operations import PolicyDefinitionsOperations # type: ignore +from ._operations import PolicyAssignmentsOperations # type: ignore from ._operations import PolicyDefinitionVersionsOperations # type: ignore -from ._operations import PolicySetDefinitionsOperations # type: ignore from ._operations import PolicySetDefinitionVersionsOperations # type: ignore -from ._operations import PolicyAssignmentsOperations # type: ignore -from ._operations import PolicyExemptionsOperations # type: ignore -from ._operations import VariablesOperations # type: ignore -from ._operations import VariableValuesOperations # type: ignore +from ._operations import PolicyDefinitionsOperations # type: ignore +from ._operations import PolicySetDefinitionsOperations # type: ignore +from ._operations import PolicyTokensOperations # type: ignore +from ._operations import DataPolicyManifestsOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "DataPolicyManifestsOperations", - "PolicyDefinitionsOperations", + "PolicyAssignmentsOperations", "PolicyDefinitionVersionsOperations", - "PolicySetDefinitionsOperations", "PolicySetDefinitionVersionsOperations", - "PolicyAssignmentsOperations", - "PolicyExemptionsOperations", - "VariablesOperations", - "VariableValuesOperations", + "PolicyDefinitionsOperations", + "PolicySetDefinitionsOperations", + "PolicyTokensOperations", + "DataPolicyManifestsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() 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 b166b31b9016..b0c2af514668 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 @@ -67,14 +67,6 @@ build_policy_definitions_list_built_in_request, build_policy_definitions_list_by_management_group_request, build_policy_definitions_list_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, @@ -98,22 +90,8 @@ build_policy_set_definitions_list_built_in_request, build_policy_set_definitions_list_by_management_group_request, build_policy_set_definitions_list_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, + build_policy_tokens_acquire_at_management_group_request, + build_policy_tokens_acquire_request, ) from .._configuration import PolicyClientConfiguration @@ -122,14 +100,14 @@ List = list -class DataPolicyManifestsOperations: +class PolicyAssignmentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.resource.policy.aio.PolicyClient`'s - :attr:`data_policy_manifests` attribute. + :attr:`policy_assignments` attribute. """ models = _models @@ -142,15 +120,22 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async 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. + async 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 policy_mode: The policy mode of the data policy manifest to get. Required. - :type policy_mode: str - :return: DataPolicyManifest or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.DataPolicyManifest + :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 expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -164,11 +149,13 @@ async def get_by_policy_mode(self, policy_mode: str, **kwargs: Any) -> _models.D _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) - cls: ClsType[_models.DataPolicyManifest] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) - _request = build_data_policy_manifests_get_by_policy_mode_request( - policy_mode=policy_mode, + _request = build_policy_assignments_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -184,178 +171,96 @@ async def get_by_policy_mode(self, policy_mode: str, **kwargs: Any) -> _models.D if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DataPolicyManifest", pipeline_response.http_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_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. - - :param 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. - :type filter: str - :return: An iterator like instance of either DataPolicyManifest or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.DataPolicyManifest] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) - cls: ClsType[_models.DataPolicyManifestListResult] = 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DataPolicyManifestListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class PolicyDefinitionsOperations: - """ - .. 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_definitions` attribute. - """ - - models = _models - - 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") - @overload - async def create_or_update( + async def create( self, - policy_definition_name: str, - parameters: _models.PolicyDefinition, + scope: str, + policy_assignment_name: str, + parameters: _models.PolicyAssignment, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.PolicyDefinition: - """Creates or updates a policy definition in a subscription. - - This operation creates or updates a policy definition in the given subscription with the given - name. + ) -> _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 policy_definition_name: The name of the policy definition to create. Required. - :type policy_definition_name: str - :param parameters: The policy definition properties. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyDefinition + :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: PolicyDefinition or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_or_update( + async def create( self, - policy_definition_name: str, + scope: str, + policy_assignment_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.PolicyDefinition: - """Creates or updates a policy definition in a subscription. - - This operation creates or updates a policy definition in the given subscription with the given - name. + ) -> _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 policy_definition_name: The name of the policy definition to create. Required. - :type policy_definition_name: str - :param parameters: The policy definition properties. Required. + :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: PolicyDefinition or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def create_or_update( - self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO[bytes]], **kwargs: Any - ) -> _models.PolicyDefinition: - """Creates or updates a policy definition in a subscription. - - This operation creates or updates a policy definition in the given subscription with the given - name. + async def create( + self, + scope: str, + policy_assignment_name: str, + parameters: Union[_models.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 policy_definition_name: The name of the policy definition to create. Required. - :type policy_definition_name: str - :param parameters: The policy definition properties. Is either a PolicyDefinition type or a + :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.PolicyDefinition or IO[bytes] - :return: PolicyDefinition or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition + :type parameters: ~azure.mgmt.resource.policy.models.PolicyAssignment or IO[bytes] + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -369,9 +274,9 @@ async def create_or_update( _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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyDefinition] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -379,11 +284,11 @@ async def create_or_update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "PolicyDefinition") + _json = self._serialize.body(parameters, "PolicyAssignment") - _request = build_policy_definitions_create_or_update_request( - policy_definition_name=policy_definition_name, - subscription_id=self._config.subscription_id, + _request = build_policy_assignments_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, api_version=api_version, content_type=content_type, json=_json, @@ -402,249 +307,96 @@ async def create_or_update( if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyDefinition", pipeline_response.http_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def delete(self, policy_definition_name: str, **kwargs: Any) -> None: - """Deletes a policy definition in a subscription. - - This operation deletes the policy definition in the given subscription with the given name. + @overload + async 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 policy_definition_name: The name of the policy definition to delete. Required. - :type policy_definition_name: str - :return: None or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: - """Retrieves a policy definition in a subscription. - - This operation retrieves the policy definition in the given subscription with the given name. - - :param policy_definition_name: The name of the policy definition to get. Required. - :type policy_definition_name: str - :return: PolicyDefinition or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyDefinition", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_built_in(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: - """Retrieves a built-in policy definition. - - This operation retrieves the built-in policy definition with the given name. - - :param policy_definition_name: The name of the built-in policy definition to get. Required. - :type policy_definition_name: str - :return: PolicyDefinition or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyDefinition] = kwargs.pop("cls", None) - - _request = build_policy_definitions_get_built_in_request( - policy_definition_name=policy_definition_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyDefinition", pipeline_response.http_response) - - 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_definition_name: str, - parameters: _models.PolicyDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicyDefinition: - """Creates or updates a policy definition in a management group. - - This operation creates or updates a policy definition in the given management group with the - given name. - - :param 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 create. 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition + :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 or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_or_update_at_management_group( + async def update( self, - management_group_id: str, - policy_definition_name: str, + scope: str, + policy_assignment_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.PolicyDefinition: - """Creates or updates a policy definition in a management group. - - This operation creates or updates a policy definition in the given management group with the - given name. + ) -> _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 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 create. Required. - :type policy_definition_name: str - :param parameters: The policy definition properties. Required. + :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: PolicyDefinition or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def create_or_update_at_management_group( + async def update( self, - management_group_id: str, - policy_definition_name: str, - parameters: Union[_models.PolicyDefinition, IO[bytes]], + scope: str, + policy_assignment_name: str, + parameters: Union[_models.PolicyAssignmentUpdate, IO[bytes]], **kwargs: Any - ) -> _models.PolicyDefinition: - """Creates or updates a policy definition in a management group. - - This operation creates or updates a policy definition in the given management group with the - given name. + ) -> _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 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 create. 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 IO[bytes] - :return: PolicyDefinition or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition + :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 IO[bytes] + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -658,9 +410,9 @@ async def create_or_update_at_management_group( _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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyDefinition] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -668,11 +420,11 @@ async def create_or_update_at_management_group( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "PolicyDefinition") + _json = self._serialize.body(parameters, "PolicyAssignmentUpdate") - _request = build_policy_definitions_create_or_update_at_management_group_request( - management_group_id=management_group_id, - policy_definition_name=policy_definition_name, + _request = build_policy_assignments_update_request( + scope=scope, + policy_assignment_name=policy_assignment_name, api_version=api_version, content_type=content_type, json=_json, @@ -689,11 +441,15 @@ async def create_or_update_at_management_group( response = pipeline_response.http_response - if response.status_code not in [201]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyDefinition", pipeline_response.http_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -701,19 +457,19 @@ async def create_or_update_at_management_group( return deserialized # type: ignore @distributed_trace_async - async def delete_at_management_group( - self, management_group_id: str, policy_definition_name: str, **kwargs: Any - ) -> None: - """Deletes a policy definition in a management group. - - This operation deletes the policy definition in the given management group with the given name. + async 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 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 delete. Required. - :type policy_definition_name: str - :return: None or the result of cls(response) - :rtype: None + :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 or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -727,12 +483,12 @@ async def delete_at_management_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[Optional[_models.PolicyAssignment]] = 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, + _request = build_policy_assignments_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, api_version=api_version, headers=_headers, params=_params, @@ -748,108 +504,69 @@ async def delete_at_management_group( if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, None, {}) # type: ignore + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) - @distributed_trace_async - async def get_at_management_group( - self, management_group_id: str, policy_definition_name: str, **kwargs: Any - ) -> _models.PolicyDefinition: - """Retrieve a policy definition in a management group. + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - 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 or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyDefinition", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return deserialized # type: ignore @distributed_trace - def list( - self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyDefinition"]: - """Retrieves policy definitions in a subscription. + def list_for_management_group( + self, + management_group_id: str, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyAssignment"]: + """Retrieves all policy assignments that apply to a management group. - 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}. + 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 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. + :param management_group_id: The management group ID. Required. + :type management_group_id: str + :param 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. :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :return: An iterator like instance of either PolicyDefinition or the result of cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinition] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyDefinitionListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyAssignmentListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -862,9 +579,10 @@ def list( def prepare_request(next_link=None): if not next_link: - _request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, + _request = build_policy_assignments_list_for_management_group_request( + management_group_id=management_group_id, filter=filter, + expand=expand, top=top, api_version=api_version, headers=_headers, @@ -879,7 +597,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -896,46 +614,60 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) @distributed_trace - def list_built_in( - self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyDefinition"]: - """Retrieve built-in policy definitions. + def list( + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyAssignment"]: + """Retrieves all policy assignments that apply to a subscription. - 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}. + 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}. - :param 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. + :param 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. :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :return: An iterator like instance of either PolicyDefinition or the result of cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinition] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyDefinitionListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyAssignmentListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -948,8 +680,10 @@ def list_built_in( def prepare_request(next_link=None): if not next_link: - _request = build_policy_definitions_list_built_in_request( + _request = build_policy_assignments_list_request( + subscription_id=self._config.subscription_id, filter=filter, + expand=expand, top=top, api_version=api_version, headers=_headers, @@ -964,7 +698,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -981,54 +715,96 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) @distributed_trace - def list_by_management_group( - self, management_group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyDefinition"]: - """Retrieve policy definitions in a management group. + 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 + ) -> AsyncItemPaged["_models.PolicyAssignment"]: + """Retrieves all policy assignments that apply to a resource. - 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}. + 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 management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param 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. + :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 + :param 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. :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :return: An iterator like instance of either PolicyDefinition or the result of cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinition] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyDefinitionListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyAssignmentListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1041,9 +817,15 @@ def list_by_management_group( 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, + _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=api_version, headers=_headers, @@ -1058,7 +840,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -1075,98 +857,68 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) + @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 + ) -> AsyncItemPaged["_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. -class PolicyDefinitionVersionsOperations: - """ - .. 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_definition_versions` attribute. - """ - - models = _models - - 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 list_all_builtins(self, **kwargs: Any) -> _models.PolicyDefinitionVersionListResult: - """Lists all built-in policy definition versions. - - This operation lists all the built-in policy definition versions for all built-in policy - definitions. - - :return: PolicyDefinitionVersionListResult or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersionListResult + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param 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. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyDefinitionVersionListResult] = kwargs.pop("cls", None) - - _request = build_policy_definition_versions_list_all_builtins_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyDefinitionVersionListResult", pipeline_response.http_response) - - 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.PolicyDefinitionVersionListResult: - """Lists all policy definition versions at management group scope. - - This operation lists all the policy definition versions for all policy definitions at the - management group scope. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyAssignmentListResult] = kwargs.pop("cls", None) - :param management_group_name: The name of the management group. The name is case insensitive. - Required. - :type management_group_name: str - :return: PolicyDefinitionVersionListResult or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersionListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1175,47 +927,72 @@ async def list_all_at_management_group( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyDefinitionVersionListResult] = kwargs.pop("cls", None) + _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=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - _request = build_policy_definition_versions_list_all_at_management_group_request( - management_group_name=management_group_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + async def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - response = pipeline_response.http_response + async def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("PolicyDefinitionVersionListResult", 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 = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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) @distributed_trace_async - async def list_all(self, **kwargs: Any) -> _models.PolicyDefinitionVersionListResult: - """Lists all policy definition versions within a subscription. + async 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersionListResult + :param policy_assignment_id: The ID of the policy assignment to delete. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :return: PolicyAssignment or None or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1229,11 +1006,11 @@ async def list_all(self, **kwargs: Any) -> _models.PolicyDefinitionVersionListRe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyDefinitionVersionListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + 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=api_version, headers=_headers, params=_params, @@ -1247,11 +1024,17 @@ async def list_all(self, **kwargs: Any) -> _models.PolicyDefinitionVersionListRe response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyDefinitionVersionListResult", pipeline_response.http_response) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1259,91 +1042,95 @@ async def list_all(self, **kwargs: Any) -> _models.PolicyDefinitionVersionListRe return deserialized # type: ignore @overload - async def create_or_update( + async def create_by_id( self, - 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: - """Creates or updates a policy definition in a subscription. + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. - This operation creates or updates a policy definition in the given subscription 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 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 + :param policy_assignment_id: The ID of the policy assignment to create. 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async 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: - """Creates or updates a policy definition in a subscription. + async 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 a policy definition in the given subscription 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 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. + :param policy_assignment_id: The ID of the policy assignment to create. 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def create_or_update( - self, - policy_definition_name: str, - policy_definition_version: str, - parameters: Union[_models.PolicyDefinitionVersion, IO[bytes]], - **kwargs: Any - ) -> _models.PolicyDefinitionVersion: - """Creates or updates a policy definition in a subscription. + async def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO[bytes]], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. - This operation creates or updates a policy definition in the given subscription 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 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 IO[bytes] - :return: PolicyDefinitionVersion or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion + :param policy_assignment_id: The ID of the policy assignment to create. 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 IO[bytes] + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1357,9 +1144,9 @@ async def create_or_update( _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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyDefinitionVersion] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1367,12 +1154,10 @@ async def create_or_update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "PolicyDefinitionVersion") + _json = self._serialize.body(parameters, "PolicyAssignment") - _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, + _request = build_policy_assignments_create_by_id_request( + policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, @@ -1389,11 +1174,15 @@ async def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyDefinitionVersion", pipeline_response.http_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1401,20 +1190,29 @@ async def create_or_update( return deserialized # type: ignore @distributed_trace_async - async def delete(self, policy_definition_name: str, policy_definition_version: str, **kwargs: Any) -> None: - """Deletes a policy definition version in a subscription. + async def get_by_id( + self, policy_assignment_id: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.PolicyAssignment: + """Retrieves the policy assignment with the given ID. - This operation deletes the policy definition version in the given subscription 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 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 or the result of cls(response) - :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 expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1428,13 +1226,12 @@ async def delete(self, policy_definition_name: str, policy_definition_version: s _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyAssignment] = 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, + _request = build_policy_assignments_get_by_id_request( + policy_assignment_id=policy_assignment_id, + expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -1448,30 +1245,111 @@ async def delete(self, policy_definition_name: str, policy_definition_version: s response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async 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 update. 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 or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async 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 update. 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 or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def get( - self, policy_definition_name: str, policy_definition_version: str, **kwargs: Any - ) -> _models.PolicyDefinitionVersion: - """Retrieves a policy definition version in a subscription. + async def update_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignmentUpdate, IO[bytes]], **kwargs: Any + ) -> _models.PolicyAssignment: + """Updates a policy assignment. - This operation retrieves the policy definition version in the given subscription with the given - name. + 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_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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion + :param policy_assignment_id: The ID of the policy assignment to update. 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 IO[bytes] + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1482,17 +1360,27 @@ async def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _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", "2023-04-01")) - cls: ClsType[_models.PolicyDefinitionVersion] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + 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_get_request( - policy_definition_name=policy_definition_name, - policy_definition_version=policy_definition_version, - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignmentUpdate") + + _request = build_policy_assignments_update_by_id_request( + policy_assignment_id=policy_assignment_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -1507,31 +1395,48 @@ async def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyDefinitionVersion", pipeline_response.http_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + +class PolicyDefinitionVersionsOperations: + """ + .. 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_definition_versions` attribute. + """ + + models = _models + + 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_built_in( - self, policy_definition_name: str, policy_definition_version: str, **kwargs: Any - ) -> _models.PolicyDefinitionVersion: - """Retrieves a built-in policy definition version. + async def list_all_builtins(self, **kwargs: Any) -> _models.PolicyDefinitionVersionListResult: + """Lists all built-in policy definition versions. - This operation retrieves the built-in policy definition version with the given name. + This operation lists all the built-in policy definition versions for all built-in policy + definitions. - :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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion + :return: PolicyDefinitionVersionListResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersionListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1545,12 +1450,10 @@ async def get_built_in( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyDefinitionVersion] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinitionVersionListResult] = 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, + _request = build_policy_definition_versions_list_all_builtins_request( api_version=api_version, headers=_headers, params=_params, @@ -1566,111 +1469,109 @@ async def get_built_in( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyDefinitionVersion", pipeline_response.http_response) + deserialized = self._deserialize("PolicyDefinitionVersionListResult", pipeline_response.http_response) 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_definition_name: str, - policy_definition_version: str, - parameters: _models.PolicyDefinitionVersion, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicyDefinitionVersion: - """Creates or updates a policy definition version in a management group. - - This operation creates or updates a policy definition version in the given management group - with the given name. + @distributed_trace + def list_built_in( + self, policy_definition_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyDefinitionVersion"]: + """This operation retrieves a list of all the built-in policy definition versions for the given + policy definition. - :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 - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PolicyDefinitionVersion or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicyDefinitionVersion or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinitionVersion] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @overload - async 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: - """Creates or updates a policy definition version in a management group. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinitionVersionListResult] = kwargs.pop("cls", None) - This operation creates or updates a policy definition version in the given management group - with the given name. + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - :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: 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ + 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=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyDefinitionVersionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def create_or_update_at_management_group( - self, - management_group_name: str, - policy_definition_name: str, - policy_definition_version: str, - parameters: Union[_models.PolicyDefinitionVersion, IO[bytes]], - **kwargs: Any + async def get_built_in( + self, policy_definition_name: str, policy_definition_version: str, **kwargs: Any ) -> _models.PolicyDefinitionVersion: - """Creates or updates a policy definition version in a management group. - - This operation creates or updates a policy definition version in the given management group - with the given name. + """This operation retrieves the built-in policy definition version 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 IO[bytes] :return: PolicyDefinitionVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: @@ -1683,29 +1584,16 @@ 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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) cls: ClsType[_models.PolicyDefinitionVersion] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PolicyDefinitionVersion") - - _request = build_policy_definition_versions_create_or_update_at_management_group_request( - management_group_name=management_group_name, + _request = build_policy_definition_versions_get_built_in_request( policy_definition_name=policy_definition_name, policy_definition_version=policy_definition_version, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -1718,9 +1606,13 @@ 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("PolicyDefinitionVersion", pipeline_response.http_response) @@ -1730,24 +1622,19 @@ async def create_or_update_at_management_group( return deserialized # type: ignore @distributed_trace_async - async def delete_at_management_group( - self, management_group_name: str, policy_definition_name: str, policy_definition_version: str, **kwargs: Any - ) -> None: - """Deletes a policy definition in a management group. + async def list_all_at_management_group( + self, management_group_name: str, **kwargs: Any + ) -> _models.PolicyDefinitionVersionListResult: + """Lists all policy definition versions at management group scope. - This operation deletes the policy definition in the given management group with the given name. + 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 - :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 or the result of cls(response) - :rtype: None + :return: PolicyDefinitionVersionListResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersionListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1761,13 +1648,11 @@ async def delete_at_management_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinitionVersionListResult] = kwargs.pop("cls", None) - _request = build_policy_definition_versions_delete_at_management_group_request( + _request = build_policy_definition_versions_list_all_at_management_group_request( management_group_name=management_group_name, - policy_definition_name=policy_definition_name, - policy_definition_version=policy_definition_version, api_version=api_version, headers=_headers, params=_params, @@ -1781,86 +1666,31 @@ async def delete_at_management_group( response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PolicyDefinitionVersionListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore - @distributed_trace_async - async def get_at_management_group( - self, management_group_name: str, policy_definition_name: str, policy_definition_version: str, **kwargs: Any - ) -> _models.PolicyDefinitionVersion: - """Retrieve a policy definition version in a management group. + return deserialized # type: ignore - This operation retrieves the policy definition version in the given management group with the - given name. + @distributed_trace + def list_by_management_group( + self, management_group_name: str, policy_definition_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_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 - :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 or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyDefinitionVersion] = 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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyDefinitionVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, policy_definition_name: str, top: Optional[int] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyDefinitionVersion"]: - """Retrieves policy definition versions for a given policy definition in a subscription. - - 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 :param top: Maximum number of records to return. When the $top filter is not provided, it will @@ -1875,7 +1705,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) cls: ClsType[_models.PolicyDefinitionVersionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { @@ -1889,9 +1719,9 @@ def list( def prepare_request(next_link=None): if not next_link: - _request = build_policy_definition_versions_list_request( + _request = build_policy_definition_versions_list_by_management_group_request( + management_group_name=management_group_name, policy_definition_name=policy_definition_name, - subscription_id=self._config.subscription_id, top=top, api_version=api_version, headers=_headers, @@ -1923,38 +1753,36 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) - @distributed_trace - def list_built_in( - self, policy_definition_name: str, top: Optional[int] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyDefinitionVersion"]: - """Retrieve built-in policy definition versions. - - This operation retrieves a list of all the built-in policy definition versions for the given - policy definition. + @distributed_trace_async + async 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 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 top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicyDefinitionVersion or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinitionVersion] + :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 or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyDefinitionVersionListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1963,77 +1791,138 @@ def list_built_in( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_policy_definition_versions_list_built_in_request( - policy_definition_name=policy_definition_name, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinitionVersion] = kwargs.pop("cls", None) - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _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, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyDefinitionVersionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + _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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("PolicyDefinitionVersion", pipeline_response.http_response) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - return AsyncItemPaged(get_next, extract_data) + return deserialized # type: ignore - @distributed_trace - def list_by_management_group( - self, management_group_name: str, policy_definition_name: str, top: Optional[int] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyDefinitionVersion"]: - """Retrieve policy definition versions in a management group policy definition. + @overload + async def create_or_update_at_management_group( + self, + management_group_name: str, + 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 version in the given management group + with the given name. - 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 + :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 or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async 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. :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 top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicyDefinitionVersion or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinitionVersion] + :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 or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyDefinitionVersionListResult] = kwargs.pop("cls", None) + @distributed_trace_async + async def create_or_update_at_management_group( + self, + management_group_name: str, + policy_definition_name: str, + policy_definition_version: str, + parameters: Union[_models.PolicyDefinitionVersion, 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 IO[bytes] + :return: PolicyDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2042,153 +1931,12 @@ def list_by_management_group( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyDefinitionVersionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class PolicySetDefinitionsOperations: - """ - .. 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. - """ - - models = _models - - 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") - - @overload - async def create_or_update( - self, - policy_set_definition_name: str, - parameters: _models.PolicySetDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicySetDefinition: - """Creates or updates a policy set definition. - - This operation creates or updates a policy set definition in the given subscription with the - given name. - - :param policy_set_definition_name: The name of the policy set definition to create. 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 or the result of cls(response) - :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: - """Creates or updates a policy set definition. - - This operation creates or updates a policy set definition in the given subscription with the - given name. - - :param policy_set_definition_name: The name of the policy set definition to create. 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 or the result of cls(response) - :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, IO[bytes]], **kwargs: Any - ) -> _models.PolicySetDefinition: - """Creates or updates a policy set definition. - - This operation creates or updates a policy set definition in the given subscription with the - given name. - - :param policy_set_definition_name: The name of the policy set definition to create. 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 IO[bytes] - :return: PolicySetDefinition or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) 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" _json = None @@ -2196,11 +1944,12 @@ async def create_or_update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "PolicySetDefinition") + _json = self._serialize.body(parameters, "PolicyDefinitionVersion") - _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_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, api_version=api_version, content_type=content_type, json=_json, @@ -2219,9 +1968,13 @@ async def create_or_update( if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicySetDefinition", pipeline_response.http_response) + deserialized = self._deserialize("PolicyDefinitionVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2229,13 +1982,20 @@ async def create_or_update( return deserialized # type: ignore @distributed_trace_async - async def delete(self, policy_set_definition_name: str, **kwargs: Any) -> None: - """Deletes a policy set definition. - - This operation deletes the policy set definition in the given subscription with the given name. + async def delete_at_management_group( + 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. - :param policy_set_definition_name: The name of the policy set definition to delete. Required. - :type policy_set_definition_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_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 or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -2251,12 +2011,13 @@ async def delete(self, policy_set_definition_name: str, **kwargs: Any) -> None: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) 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, + _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, api_version=api_version, headers=_headers, params=_params, @@ -2272,28 +2033,24 @@ async def delete(self, policy_set_definition_name: str, **kwargs: Any) -> None: if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def get( - self, policy_set_definition_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> _models.PolicySetDefinition: - """Retrieves a policy set definition. + async def list_all(self, **kwargs: Any) -> _models.PolicyDefinitionVersionListResult: + """Lists all policy definition versions within a subscription. - This operation retrieves the policy set definition in the given subscription with the given - name. + This operation lists all the policy definition versions for all policy definitions within a + subscription. - :param policy_set_definition_name: The name of the policy set definition to get. Required. - :type policy_set_definition_name: str - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :return: PolicySetDefinition or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :return: PolicyDefinitionVersionListResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersionListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2307,13 +2064,11 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinitionVersionListResult] = kwargs.pop("cls", None) - _request = build_policy_set_definitions_get_request( - policy_set_definition_name=policy_set_definition_name, + _request = build_policy_definition_versions_list_all_request( subscription_id=self._config.subscription_id, - expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -2329,33 +2084,43 @@ async def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicySetDefinition", pipeline_response.http_response) + deserialized = self._deserialize("PolicyDefinitionVersionListResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def get_built_in( - self, policy_set_definition_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> _models.PolicySetDefinition: - """Retrieves a built in policy set definition. - - This operation retrieves the built-in policy set definition with the given name. + @distributed_trace + def list( + self, policy_definition_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyDefinitionVersion"]: + """This operation retrieves a list of all the policy definition versions for the given policy + definition. - :param policy_set_definition_name: The name of the policy set definition to get. Required. - :type policy_set_definition_name: str - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :return: PolicySetDefinition or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :param policy_definition_name: The name of the policy definition. Required. + :type policy_definition_name: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicyDefinitionVersion or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinitionVersion] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinitionVersionListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2364,1898 +2129,68 @@ async def get_built_in( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) + def prepare_request(next_link=None): + if not next_link: - _request = build_policy_set_definitions_get_built_in_request( - policy_set_definition_name=policy_set_definition_name, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + _request = build_policy_definition_versions_list_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicySetDefinition", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # 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 - ) -> AsyncItemPaged["_models.PolicySetDefinition"]: - """Retrieves the policy set definitions for a subscription. - - 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 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. - :type filter: str - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinitionListResult] = 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_built_in( - self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.PolicySetDefinition"]: - """Retrieves built-in policy set definitions. - - 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 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. - :type filter: str - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinitionListResult] = 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @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: - """Creates or updates a policy set definition. - - This operation creates or updates a policy set definition in the given management group with - the given name. - - :param 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 create. 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 or the result of cls(response) - :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: - """Creates or updates a policy set definition. - - This operation creates or updates a policy set definition in the given management group with - the given name. - - :param 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 create. 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 or the result of cls(response) - :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, IO[bytes]], - **kwargs: Any - ) -> _models.PolicySetDefinition: - """Creates or updates a policy set definition. - - This operation creates or updates a policy set definition in the given management group with - the given name. - - :param 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 create. 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 IO[bytes] - :return: PolicySetDefinition or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PolicySetDefinition") - - _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, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicySetDefinition", pipeline_response.http_response) - - 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: - """Deletes a policy set definition. - - 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 delete. Required. - :type policy_set_definition_name: str - :return: None or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @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: - """Retrieves a policy set definition. - - 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 - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :return: PolicySetDefinition or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicySetDefinition", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # 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"]: - """Retrieves all policy set definitions in management group. - - 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 - :param 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. - :type filter: str - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinitionListResult] = 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class PolicySetDefinitionVersionsOperations: - """ - .. 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. - """ - - models = _models - - 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 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 or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) - - _request = build_policy_set_definition_versions_list_all_builtins_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response.http_response) - - 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 or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response.http_response) - - 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 or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) - - _request = build_policy_set_definition_versions_list_all_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response.http_response) - - 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: - """Creates or updates a policy set definition version. - - 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 or the result of cls(response) - :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: - """Creates or updates a policy set definition version. - - 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 or the result of cls(response) - :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, IO[bytes]], - **kwargs: Any - ) -> _models.PolicySetDefinitionVersion: - """Creates or updates a policy set definition version. - - 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 IO[bytes] - :return: PolicySetDefinitionVersion or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PolicySetDefinitionVersion") - - _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, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicySetDefinitionVersion", pipeline_response.http_response) - - 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: - """Deletes a policy set definition version. - - 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 or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def get( - self, - policy_set_definition_name: str, - policy_definition_version: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.PolicySetDefinitionVersion: - """Retrieves a policy set definition version. - - 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 - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :return: PolicySetDefinitionVersion or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicySetDefinitionVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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: - """Retrieves a built in policy set definition version. - - 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 - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :return: PolicySetDefinitionVersion or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicySetDefinitionVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # 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"]: - """Retrieves the policy set definition versions for a given policy set definition in a - subscription. - - 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 - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicySetDefinitionVersion or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinitionVersionListResult] = 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @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"]: - """Retrieves built-in policy set definition versions. - - 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 - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicySetDefinitionVersion or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinitionVersionListResult] = 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @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: - """Creates or updates a policy set definition version. - - 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 or the result of cls(response) - :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: - """Creates or updates a policy set definition version. - - 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 or the result of cls(response) - :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, IO[bytes]], - **kwargs: Any - ) -> _models.PolicySetDefinitionVersion: - """Creates or updates a policy set definition version. - - 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 IO[bytes] - :return: PolicySetDefinitionVersion or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PolicySetDefinitionVersion") - - _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, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicySetDefinitionVersion", pipeline_response.http_response) - - 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: - """Deletes a policy set definition version. - - 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 or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @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: - """Retrieves a policy set definition version. - - 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 - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :return: PolicySetDefinitionVersion or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicySetDefinitionVersion", pipeline_response.http_response) - - if cls: - 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 - ) -> AsyncItemPaged["_models.PolicySetDefinitionVersion"]: - """Retrieves all policy set definition versions for a given policy set definition in a management - group. - - 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 - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicySetDefinitionVersion or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinitionVersionListResult] = 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class PolicyAssignmentsOperations: - """ - .. 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_assignments` attribute. - """ - - models = _models - - 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 delete( - self, scope: str, policy_assignment_name: str, **kwargs: Any - ) -> Optional[_models.PolicyAssignment]: - """Deletes a policy assignment. - - This operation deletes a policy assignment, given its name and the scope it was created in. The - scope of a policy assignment is the part of its ID preceding - '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - - :param scope: The scope of the policy assignment. Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - Required. - :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. Required. - :type policy_assignment_name: str - :return: PolicyAssignment or None or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create( - self, - scope: str, - policy_assignment_name: str, - parameters: _models.PolicyAssignment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicyAssignment: - """Creates or updates a policy assignment. - - This operation creates or updates a policy assignment with the given scope and name. Policy - assignments apply to all resources contained within their scope. For example, when you assign a - policy at resource group scope, that policy applies to all resources in the group. - - :param scope: The scope of the policy assignment. Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - Required. - :type scope: str - :param policy_assignment_name: The name of the policy assignment. 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - scope: str, - policy_assignment_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PolicyAssignment: - """Creates or updates a policy assignment. - - This operation creates or updates a policy assignment with the given scope and name. Policy - assignments apply to all resources contained within their scope. For example, when you assign a - policy at resource group scope, that policy applies to all resources in the group. - - :param scope: The scope of the policy assignment. Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - Required. - :type scope: str - :param policy_assignment_name: The name of the policy assignment. 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - scope: str, - policy_assignment_name: str, - parameters: Union[_models.PolicyAssignment, IO[bytes]], - **kwargs: Any - ) -> _models.PolicyAssignment: - """Creates or updates a policy assignment. - - This operation creates or updates a policy assignment with the given scope and name. Policy - assignments apply to all resources contained within their scope. For example, when you assign a - policy at resource group scope, that policy applies to all resources in the group. - - :param scope: The scope of the policy assignment. Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - Required. - :type scope: str - :param policy_assignment_name: The name of the policy assignment. 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 IO[bytes] - :return: PolicyAssignment or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PolicyAssignment") - - _request = build_policy_assignments_create_request( - scope=scope, - policy_assignment_name=policy_assignment_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + async def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyDefinitionVersionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - response = pipeline_response.http_response + async def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("PolicyAssignment", 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 = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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) @distributed_trace_async async def get( - self, scope: str, policy_assignment_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> _models.PolicyAssignment: - """Retrieves a policy assignment. - - This operation retrieves a single policy assignment, given its name and the scope it was - created at. + 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 scope: The scope of the policy assignment. Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :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 scope: str - :param policy_assignment_name: The name of the policy assignment to get. Required. - :type policy_assignment_name: str - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :return: PolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :type policy_definition_version: str + :return: PolicyDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4269,13 +2204,13 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinitionVersion] = kwargs.pop("cls", None) - _request = build_policy_assignments_get_request( - scope=scope, - policy_assignment_name=policy_assignment_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=api_version, headers=_headers, params=_params, @@ -4291,9 +2226,13 @@ async def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) + deserialized = self._deserialize("PolicyDefinitionVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -4301,103 +2240,85 @@ async def get( return deserialized # type: ignore @overload - async def update( + async def create_or_update( self, - scope: str, - policy_assignment_name: str, - parameters: _models.PolicyAssignmentUpdate, + policy_definition_name: str, + policy_definition_version: str, + parameters: _models.PolicyDefinitionVersion, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.PolicyAssignment: - """Updates a policy assignment. - - 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. + ) -> _models.PolicyDefinitionVersion: + """This operation creates or updates a policy definition in the given subscription with the given + name. - :param scope: The scope of the policy assignment. Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :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 scope: str - :param policy_assignment_name: The name of the policy assignment. Required. - :type policy_assignment_name: str - :param parameters: Parameters for policy assignment patch request. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyAssignmentUpdate + :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: PolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :return: PolicyDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( + async def create_or_update( self, - scope: str, - policy_assignment_name: str, + policy_definition_name: str, + policy_definition_version: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.PolicyAssignment: - """Updates a policy assignment. - - 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. + ) -> _models.PolicyDefinitionVersion: + """This operation creates or updates a policy definition in the given subscription with the given + name. - :param scope: The scope of the policy assignment. Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :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 scope: str - :param policy_assignment_name: The name of the policy assignment. Required. - :type policy_assignment_name: str - :param parameters: Parameters for policy assignment patch request. 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: PolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :return: PolicyDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def update( + async def create_or_update( self, - scope: str, - policy_assignment_name: str, - parameters: Union[_models.PolicyAssignmentUpdate, IO[bytes]], + policy_definition_name: str, + policy_definition_version: str, + parameters: Union[_models.PolicyDefinitionVersion, IO[bytes]], **kwargs: Any - ) -> _models.PolicyAssignment: - """Updates a policy assignment. - - 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. + ) -> _models.PolicyDefinitionVersion: + """This operation creates or updates a policy definition in the given subscription with the given + name. - :param scope: The scope of the policy assignment. Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :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 scope: str - :param policy_assignment_name: The name of the policy assignment. 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 IO[bytes] - :return: PolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :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 IO[bytes] + :return: PolicyDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4411,9 +2332,9 @@ async def update( _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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyDefinitionVersion] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -4421,11 +2342,12 @@ async def update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "PolicyAssignmentUpdate") + _json = self._serialize.body(parameters, "PolicyDefinitionVersion") - _request = build_policy_assignments_update_request( - scope=scope, - policy_assignment_name=policy_assignment_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, api_version=api_version, content_type=content_type, json=_json, @@ -4442,204 +2364,36 @@ async def update( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) + deserialized = self._deserialize("PolicyDefinitionVersion", pipeline_response.http_response) 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 - ) -> AsyncItemPaged["_models.PolicyAssignment"]: - """Retrieves all policy assignments that apply to a resource group. - - This operation retrieves the list of all policy assignments associated with the given resource - group in the given subscription that match the optional given $filter. Valid values for $filter - are: 'atScope()', '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 that contains policy assignments. - Required. - :type resource_group_name: str - :param 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. - :type filter: str - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicyAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyAssignmentListResult] = 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(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 - ) -> AsyncItemPaged["_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'). + @distributed_trace_async + async def delete(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 resource_group_name: The name of the resource group containing the resource. 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 - :param 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. - :type filter: str - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicyAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] + :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 or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyAssignmentListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4648,104 +2402,71 @@ def list_for_resource( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _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=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + _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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if cls: + return cls(pipeline_response, None, {}) # type: ignore - return pipeline_response - return AsyncItemPaged(get_next, extract_data) +class PolicySetDefinitionVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - @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 - ) -> AsyncItemPaged["_models.PolicyAssignment"]: - """Retrieves all policy assignments that apply to a management group. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.aio.PolicyClient`'s + :attr:`policy_set_definition_versions` attribute. + """ - 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. + models = _models - :param management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param 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. - :type filter: str - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicyAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + 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") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyAssignmentListResult] = kwargs.pop("cls", None) + @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 or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersionListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4754,77 +2475,50 @@ def list_for_management_group( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_policy_assignments_list_for_management_group_request( - management_group_id=management_group_id, - filter=filter, - expand=expand, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _request = build_policy_set_definition_versions_list_all_builtins_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + _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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response.http_response) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - return AsyncItemPaged(get_next, extract_data) + return deserialized # type: ignore @distributed_trace - def list( - self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncItemPaged["_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}. + 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 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. - :type filter: str + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str :param expand: Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is None. @@ -4832,16 +2526,17 @@ def list( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :return: An iterator like instance of either PolicyAssignment or the result of cls(response) + :return: An iterator like instance of either PolicySetDefinitionVersion or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyAssignmentListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4854,9 +2549,8 @@ def list( def prepare_request(next_link=None): if not next_link: - _request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - filter=filter, + _request = build_policy_set_definition_versions_list_built_in_request( + policy_set_definition_name=policy_set_definition_name, expand=expand, top=top, api_version=api_version, @@ -4872,7 +2566,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -4889,29 +2583,39 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async 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). + 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_assignment_id: The ID of the policy assignment to delete. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. - :type policy_assignment_id: str - :return: PolicyAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment or None + :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 expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :return: PolicySetDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4925,11 +2629,13 @@ async def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> Option _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[Optional[_models.PolicyAssignment]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) - _request = build_policy_assignments_delete_by_id_request( - policy_assignment_id=policy_assignment_id, + _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=api_version, headers=_headers, params=_params, @@ -4943,109 +2649,35 @@ async def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> Option response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) + deserialized = self._deserialize("PolicySetDefinitionVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async 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 create. 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async 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 create. 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def create_by_id( - self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO[bytes]], **kwargs: Any - ) -> _models.PolicyAssignment: - """Creates or updates a policy assignment. + 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 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}'. + This operation lists all the policy set definition versions for all policy set definitions at + the management group scope. - :param policy_assignment_id: The ID of the policy assignment to create. 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 IO[bytes] - :return: PolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :return: PolicySetDefinitionVersionListResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersionListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5056,27 +2688,15 @@ async def create_by_id( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PolicyAssignment") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) - _request = build_policy_assignments_create_by_id_request( - policy_assignment_id=policy_assignment_id, + _request = build_policy_set_definition_versions_list_all_at_management_group_request( + management_group_name=management_group_name, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -5089,41 +2709,140 @@ async def create_by_id( response = pipeline_response.http_response - if response.status_code not in [201]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) + deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def get_by_id( - self, policy_assignment_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> _models.PolicyAssignment: - """Retrieves the policy assignment with the given ID. + @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. - 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_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicySetDefinitionVersion or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionVersionListResult] = 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=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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 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 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 expand: Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is None. :type expand: str - :return: PolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :return: PolicySetDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5137,11 +2856,13 @@ async def get_by_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) - _request = build_policy_assignments_get_by_id_request( - policy_assignment_id=policy_assignment_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=api_version, headers=_headers, @@ -5158,9 +2879,13 @@ async def get_by_id( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) + deserialized = self._deserialize("PolicySetDefinitionVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -5168,95 +2893,97 @@ async def get_by_id( return deserialized # type: ignore @overload - async def update_by_id( + async def create_or_update_at_management_group( self, - policy_assignment_id: str, - parameters: _models.PolicyAssignmentUpdate, + management_group_name: str, + policy_set_definition_name: str, + policy_definition_version: str, + parameters: _models.PolicySetDefinitionVersion, *, 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}'. + ) -> _models.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given management group + with the given name and version. - :param policy_assignment_id: The ID of the policy assignment to update. 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 + :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: PolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :return: PolicySetDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async 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}'. + 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 policy_assignment_id: The ID of the policy assignment to update. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. - :type policy_assignment_id: str - :param parameters: Parameters for policy assignment patch request. 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: PolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :return: PolicySetDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def update_by_id( - self, policy_assignment_id: str, parameters: Union[_models.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}'. + 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, 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 policy_assignment_id: The ID of the policy assignment to update. 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 IO[bytes] - :return: PolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :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 IO[bytes] + :return: PolicySetDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5270,9 +2997,9 @@ async def update_by_id( _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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -5280,10 +3007,12 @@ async def update_by_id( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "PolicyAssignmentUpdate") + _json = self._serialize.body(parameters, "PolicySetDefinitionVersion") - _request = build_policy_assignments_update_by_id_request( - policy_assignment_id=policy_assignment_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, api_version=api_version, content_type=content_type, json=_json, @@ -5300,54 +3029,37 @@ async def update_by_id( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) + deserialized = self._deserialize("PolicySetDefinitionVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class PolicyExemptionsOperations: - """ - .. 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. - """ - - models = _models - - 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 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 scope of the policy exemption. 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}'. + 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 scope: str - :param policy_exemption_name: The name of the policy exemption to delete. Required. - :type policy_exemption_name: str + :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 or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -5363,12 +3075,13 @@ async def delete(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) 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_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=api_version, headers=_headers, params=_params, @@ -5384,112 +3097,24 @@ async def delete(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) # type: ignore - @overload - async 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. - - 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. - - :param scope: The scope of the policy exemption. 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}'. - Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to delete. 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption - :raises ~azure.core.exceptions.HttpResponseError: - """ + @distributed_trace_async + async def list_all(self, **kwargs: Any) -> _models.PolicySetDefinitionVersionListResult: + """Lists all policy set definition versions within a subscription. - @overload - async 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. - - 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. - - :param scope: The scope of the policy exemption. 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}'. - Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to delete. 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption - :raises ~azure.core.exceptions.HttpResponseError: - """ + This operation lists all the policy set definition versions for all policy set definitions + within a subscription. - @distributed_trace_async - async def create_or_update( - self, - scope: str, - policy_exemption_name: str, - parameters: Union[_models.PolicyExemption, 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. - - :param scope: The scope of the policy exemption. 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}'. - Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to delete. 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 IO[bytes] - :return: PolicyExemption or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption + :return: PolicySetDefinitionVersionListResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersionListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5500,28 +3125,15 @@ async 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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) - 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" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PolicyExemption") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) - _request = build_policy_exemptions_create_or_update_request( - scope=scope, - policy_exemption_name=policy_exemption_name, + _request = build_policy_set_definition_versions_list_all_request( + subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -5534,35 +3146,128 @@ async def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyExemption", pipeline_response.http_response) + deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def get(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> _models.PolicyExemption: - """Retrieves a policy exemption. + @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 + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicySetDefinitionVersion or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionVersionListResult] = 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=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) - This operation retrieves a single policy exemption, given its name and the scope it was created - at. + @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 scope: The scope of the policy exemption. 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_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 scope: str - :param policy_exemption_name: The name of the policy exemption to delete. Required. - :type policy_exemption_name: str - :return: PolicyExemption or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption + :type policy_definition_version: str + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :return: PolicySetDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5576,12 +3281,14 @@ async def get(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) - cls: ClsType[_models.PolicyExemption] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) - _request = build_policy_exemptions_get_request( - scope=scope, - policy_exemption_name=policy_exemption_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=api_version, headers=_headers, params=_params, @@ -5597,9 +3304,13 @@ async def get(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> _m if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyExemption", pipeline_response.http_response) + deserialized = self._deserialize("PolicySetDefinitionVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -5607,97 +3318,85 @@ async def get(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> _m return deserialized # type: ignore @overload - async def update( + async def create_or_update( self, - scope: str, - policy_exemption_name: str, - parameters: _models.PolicyExemptionUpdate, + policy_set_definition_name: str, + policy_definition_version: str, + parameters: _models.PolicySetDefinitionVersion, *, 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.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given subscription + with the given name and version. - :param scope: The scope of the policy exemption. 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_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 scope: str - :param policy_exemption_name: The name of the policy exemption to delete. Required. - :type policy_exemption_name: str - :param parameters: Parameters for policy exemption patch request. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyExemptionUpdate + :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: PolicyExemption or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption + :return: PolicySetDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( + async def create_or_update( self, - scope: str, - policy_exemption_name: str, + policy_set_definition_name: str, + policy_definition_version: 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.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given subscription + with the given name and version. - :param scope: The scope of the policy exemption. 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_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 scope: str - :param policy_exemption_name: The name of the policy exemption to delete. Required. - :type policy_exemption_name: str - :param parameters: Parameters for policy exemption patch request. 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: PolicyExemption or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption + :return: PolicySetDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def update( + async def create_or_update( self, - scope: str, - policy_exemption_name: str, - parameters: Union[_models.PolicyExemptionUpdate, IO[bytes]], + policy_set_definition_name: str, + policy_definition_version: str, + parameters: Union[_models.PolicySetDefinitionVersion, IO[bytes]], **kwargs: Any - ) -> _models.PolicyExemption: - """Updates a policy exemption. - - This operation updates a policy exemption with the given scope and name. + ) -> _models.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given subscription + with the given name and version. - :param scope: The scope of the policy exemption. 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_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 scope: str - :param policy_exemption_name: The name of the policy exemption to delete. 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 IO[bytes] - :return: PolicyExemption or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption + :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 IO[bytes] + :return: PolicySetDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5711,9 +3410,9 @@ async def update( _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", "2022-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyExemption] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -5721,11 +3420,12 @@ async def update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "PolicyExemptionUpdate") + _json = self._serialize.body(parameters, "PolicySetDefinitionVersion") - _request = build_policy_exemptions_update_request( - scope=scope, - policy_exemption_name=policy_exemption_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, api_version=api_version, content_type=content_type, json=_json, @@ -5742,52 +3442,36 @@ async def update( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyExemption", pipeline_response.http_response) + deserialized = self._deserialize("PolicySetDefinitionVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - 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. + @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 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. - :type filter: str - :return: An iterator like instance of either PolicyExemption or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyExemption] + :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 or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) - cls: ClsType[_models.PolicyExemptionListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5796,86 +3480,92 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_ } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_policy_exemptions_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + 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=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + if cls: + return cls(pipeline_response, None, {}) # type: ignore - 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 +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.aio.PolicyClient`'s + :attr:`policy_definitions` attribute. + """ - return pipeline_response + models = _models - return AsyncItemPaged(get_next, extract_data) + 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 - 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. + def list_built_in( + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_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 containing the resource. Required. - :type resource_group_name: str - :param 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. + :param 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. :type filter: str - :return: An iterator like instance of either PolicyExemption or the result of cls(response) + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyExemption] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) - cls: ClsType[_models.PolicyExemptionListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinitionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5888,10 +3578,9 @@ def list_for_resource_group( 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, + _request = build_policy_definitions_list_built_in_request( filter=filter, + top=top, api_version=api_version, headers=_headers, params=_params, @@ -5905,7 +3594,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -5922,82 +3611,26 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(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, - **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'). + @distributed_trace_async + async 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 resource_group_name: The name of the resource group containing the resource. 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 - :param 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. - :type filter: str - :return: An iterator like instance of either PolicyExemption or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyExemption] + :param policy_definition_name: The name of the built-in policy definition to get. Required. + :type policy_definition_name: str + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) - cls: ClsType[_models.PolicyExemptionListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6006,90 +3639,82 @@ def list_for_resource( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinition] = kwargs.pop("cls", None) - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _request = build_policy_definitions_get_built_in_request( + policy_definition_name=policy_definition_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + _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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("PolicyDefinition", pipeline_response.http_response) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - return AsyncItemPaged(get_next, extract_data) + return deserialized # type: ignore @distributed_trace - 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. + def list_by_management_group( + self, management_group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_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 - :param 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. + :param 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. :type filter: str - :return: An iterator like instance of either PolicyExemption or the result of cls(response) + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyExemption] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) - cls: ClsType[_models.PolicyExemptionListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinitionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -6102,9 +3727,10 @@ def list_for_management_group( def prepare_request(next_link=None): if not next_link: - _request = build_policy_exemptions_list_for_management_group_request( + _request = build_policy_definitions_list_by_management_group_request( management_group_id=management_group_id, filter=filter, + top=top, api_version=api_version, headers=_headers, params=_params, @@ -6118,7 +3744,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -6135,44 +3761,29 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) - -class VariablesOperations: - """ - .. 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. - """ - - models = _models - - 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 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 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 variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :return: None or the result of cls(response) - :rtype: None + :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 or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6186,12 +3797,12 @@ async def delete(self, variable_name: str, **kwargs: Any) -> None: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinition] = kwargs.pop("cls", None) - _request = build_variables_delete_request( - variable_name=variable_name, - subscription_id=self._config.subscription_id, + _request = build_policy_definitions_get_at_management_group_request( + management_group_id=management_group_id, + policy_definition_name=policy_definition_name, api_version=api_version, headers=_headers, params=_params, @@ -6205,71 +3816,95 @@ async def delete(self, variable_name: str, **kwargs: Any) -> None: response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PolicyDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore - @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. + return deserialized # type: ignore - 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. + @overload + async 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 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 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: Variable or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.Variable + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :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. + async 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 variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param parameters: Parameters for the variable. 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: Variable or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.Variable + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def create_or_update( - self, variable_name: str, parameters: Union[_models.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. + async def create_or_update_at_management_group( + self, + management_group_id: str, + policy_definition_name: str, + parameters: Union[_models.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 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. - Required. - :type parameters: ~azure.mgmt.resource.policy.models.Variable or IO[bytes] - :return: Variable or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.Variable + :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 IO[bytes] + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6283,9 +3918,9 @@ async def create_or_update( _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", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Variable] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -6293,11 +3928,11 @@ async def create_or_update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "Variable") + _json = self._serialize.body(parameters, "PolicyDefinition") - _request = build_variables_create_or_update_request( - variable_name=variable_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, api_version=api_version, content_type=content_type, json=_json, @@ -6314,11 +3949,15 @@ async def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Variable", pipeline_response.http_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -6326,16 +3965,17 @@ async def create_or_update( return deserialized # type: ignore @distributed_trace_async - 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 delete_at_management_group( + 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 variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :return: Variable or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.Variable + :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 or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6349,12 +3989,12 @@ async def get(self, variable_name: str, **kwargs: Any) -> _models.Variable: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.Variable] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_variables_get_request( - variable_name=variable_name, - subscription_id=self._config.subscription_id, + _request = build_policy_definitions_delete_at_management_group_request( + management_group_id=management_group_id, + policy_definition_name=policy_definition_name, api_version=api_version, headers=_headers, params=_params, @@ -6368,31 +4008,118 @@ async def get(self, variable_name: str, **kwargs: Any) -> _models.Variable: response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Variable", pipeline_response.http_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) 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, top: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_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}. - @distributed_trace_async - async def delete_at_management_group(self, management_group_id: str, variable_name: str, **kwargs: Any) -> None: - """Deletes a variable. + :param 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. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - 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}'. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinitionListResult] = kwargs.pop("cls", None) - :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 or the result of cls(response) - :rtype: 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=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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(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 or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6406,12 +4133,12 @@ async def delete_at_management_group(self, management_group_id: str, variable_na _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinition] = 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_definitions_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, @@ -6425,93 +4152,83 @@ async def delete_at_management_group(self, management_group_id: str, variable_na response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PolicyDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @overload - async def create_or_update_at_management_group( + async def create_or_update( self, - management_group_id: str, - variable_name: str, - parameters: _models.Variable, + policy_definition_name: str, + parameters: _models.PolicyDefinition, *, 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. + ) -> _models.PolicyDefinition: + """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 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_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: Variable or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.Variable + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_or_update_at_management_group( + async def create_or_update( self, - management_group_id: str, - variable_name: str, + policy_definition_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 management group and name. Policy - variables can only be used by a policy definition at the scope they are created or below. + ) -> _models.PolicyDefinition: + """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 variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param parameters: Parameters for the variable. 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: Variable or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.Variable + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - parameters: Union[_models.Variable, IO[bytes]], - **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. + async def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO[bytes]], **kwargs: Any + ) -> _models.PolicyDefinition: + """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 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. - Required. - :type parameters: ~azure.mgmt.resource.policy.models.Variable or IO[bytes] - :return: Variable or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.Variable + :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 IO[bytes] + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6525,9 +4242,9 @@ async def create_or_update_at_management_group( _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", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Variable] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -6535,11 +4252,11 @@ async def create_or_update_at_management_group( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "Variable") + _json = self._serialize.body(parameters, "PolicyDefinition") - _request = build_variables_create_or_update_at_management_group_request( - management_group_id=management_group_id, - variable_name=variable_name, + _request = build_policy_definitions_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, @@ -6556,11 +4273,15 @@ 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 [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Variable", pipeline_response.http_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -6568,20 +4289,13 @@ async def create_or_update_at_management_group( return deserialized # type: ignore @distributed_trace_async - 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. + async def delete(self, policy_definition_name: str, **kwargs: Any) -> None: + """This operation deletes the 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 variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :return: Variable or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.Variable + :param policy_definition_name: The name of the policy definition to get. Required. + :type policy_definition_name: str + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6595,12 +4309,12 @@ async def get_at_management_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.Variable] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_variables_get_at_management_group_request( - management_group_id=management_group_id, - variable_name=variable_name, + _request = build_policy_definitions_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, @@ -6614,32 +4328,71 @@ async def get_at_management_group( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Variable", pipeline_response.http_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) 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, **kwargs: Any) -> AsyncItemPaged["_models.Variable"]: - """Retrieves all variables that are at this subscription level. +class PolicySetDefinitionsOperations: + """ + .. 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. + """ - This operation retrieves the list of all variables associated with the given subscription. + models = _models + + 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") - :return: An iterator like instance of either Variable or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.Variable] + @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}. + + :param 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. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.VariableListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -6652,8 +4405,10 @@ def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Variable"]: def prepare_request(next_link=None): if not next_link: - _request = build_variables_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=api_version, headers=_headers, params=_params, @@ -6667,7 +4422,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("VariableListResult", pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -6684,29 +4439,126 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) - @distributed_trace - 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. + @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 + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :return: PolicySetDefinition or the result of cls(response) + :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + 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=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PolicySetDefinition", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore - This operation retrieves the list of all variables applicable to the management group. + @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 - :return: An iterator like instance of either Variable or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.Variable] + :param 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. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.VariableListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -6719,8 +4571,11 @@ 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( + _request = build_policy_set_definitions_list_by_management_group_request( management_group_id=management_group_id, + filter=filter, + expand=expand, + top=top, api_version=api_version, headers=_headers, params=_params, @@ -6734,7 +4589,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("VariableListResult", pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -6751,46 +4606,33 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) - -class VariableValuesOperations: - """ - .. 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. - """ - - models = _models - - 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 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 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 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 or the result of cls(response) - :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 + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6804,13 +4646,13 @@ async def delete(self, variable_name: str, variable_value_name: str, **kwargs: A _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinition] = 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_definitions_get_at_management_group_request( + management_group_id=management_group_id, + policy_set_definition_name=policy_set_definition_name, + expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -6824,93 +4666,95 @@ async def delete(self, variable_name: str, variable_value_name: str, **kwargs: A response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PolicySetDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + 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_id: str, + policy_set_definition_name: str, + parameters: _models.PolicySetDefinition, *, 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.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: VariableValue or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :return: PolicySetDefinition or the result of cls(response) + :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, - variable_name: str, - variable_value_name: str, + management_group_id: str, + policy_set_definition_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 subscription and name for a - given variable. Variable values are scoped to the variable for which they are created for. + ) -> _models.PolicySetDefinition: + """This operation creates or updates a policy set definition in the given management group with + the given name. - :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_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: VariableValue or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - 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, IO[bytes]], + management_group_id: str, + policy_set_definition_name: str, + parameters: Union[_models.PolicySetDefinition, 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.PolicySetDefinition: + """This operation creates or updates a policy set definition in the given management group with + the given name. - :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 IO[bytes] - :return: VariableValue or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :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 IO[bytes] + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6924,9 +4768,9 @@ async def create_or_update( _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", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VariableValue] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -6934,12 +4778,11 @@ async def create_or_update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "VariableValue") + _json = self._serialize.body(parameters, "PolicySetDefinition") - _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_definitions_create_or_update_at_management_group_request( + management_group_id=management_group_id, + policy_set_definition_name=policy_set_definition_name, api_version=api_version, content_type=content_type, json=_json, @@ -6958,9 +4801,13 @@ async def create_or_update( if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("VariableValue", pipeline_response.http_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -6968,18 +4815,18 @@ async def create_or_update( return deserialized # type: ignore @distributed_trace_async - 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + 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 or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6993,13 +4840,12 @@ async def get(self, variable_name: str, variable_value_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.VariableValue] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[None] = 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_definitions_delete_at_management_group_request( + management_group_id=management_group_id, + policy_set_definition_name=policy_set_definition_name, api_version=api_version, headers=_headers, params=_params, @@ -7013,36 +4859,58 @@ async def get(self, variable_name: str, variable_value_name: str, **kwargs: Any) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VariableValue", pipeline_response.http_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - 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( + 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 variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :return: An iterator like instance of either VariableValue or the result of cls(response) + :param 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. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.VariableValue] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.VariableValueListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7055,9 +4923,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, + _request = build_policy_set_definitions_list_request( subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + top=top, api_version=api_version, headers=_headers, params=_params, @@ -7071,7 +4941,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("VariableValueListResult", pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -7088,36 +4958,143 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) - @distributed_trace - 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. + @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 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 either VariableValue or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.VariableValue] + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :return: PolicySetDefinition or the result of cls(response) + :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.VariableValueListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + 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=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PolicySetDefinition", pipeline_response.http_response) + + 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 or the result of cls(response) + :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 or the result of cls(response) + :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, 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 IO[bytes] + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7126,64 +5103,61 @@ def list_for_management_group( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_variable_values_list_for_management_group_request( - management_group_id=management_group_id, - variable_name=variable_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") - async def extract_data(pipeline_response): - deserialized = self._deserialize("VariableValueListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + _request = build_policy_set_definitions_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - 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 + ) - _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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response.http_response) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - return AsyncItemPaged(get_next, extract_data) + return deserialized # type: ignore @distributed_trace_async - 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. - - 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}'. + 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 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 policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -7199,13 +5173,12 @@ async def delete_at_management_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) cls: ClsType[None] = 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_definitions_delete_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, @@ -7221,100 +5194,106 @@ async def delete_at_management_group( if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) # type: ignore + +class PolicyTokensOperations: + """ + .. 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_tokens` attribute. + """ + + models = _models + + 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") + @overload - async def create_or_update_at_management_group( + async def acquire_at_management_group( self, - management_group_id: str, - variable_name: str, - variable_value_name: str, - parameters: _models.VariableValue, + management_group_name: str, + parameters: _models.PolicyTokenRequest, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VariableValue: - """Creates or updates a variable value. + ) -> _models.PolicyTokenResponse: + """Acquires a policy token at management group level. - 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 acquires a policy token in the given management group for the given request + body. - :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 + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param parameters: The policy token properties. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicyTokenRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: VariableValue or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :return: PolicyTokenResponse or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyTokenResponse :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_or_update_at_management_group( + async def acquire_at_management_group( self, - management_group_id: str, - variable_name: str, - variable_value_name: str, + management_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VariableValue: - """Creates or updates a variable value. + ) -> _models.PolicyTokenResponse: + """Acquires a policy token at management group level. - 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 acquires a policy token in the given management group for the given request + body. - :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. + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param parameters: The policy token 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :return: PolicyTokenResponse or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyTokenResponse :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - variable_value_name: str, - parameters: Union[_models.VariableValue, IO[bytes]], - **kwargs: Any - ) -> _models.VariableValue: - """Creates or updates a variable value. + async def acquire_at_management_group( + self, management_group_name: str, parameters: Union[_models.PolicyTokenRequest, IO[bytes]], **kwargs: Any + ) -> _models.PolicyTokenResponse: + """Acquires a policy token at management group level. - 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 acquires a policy token in the given management group for the given request + body. - :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 + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param parameters: The policy token properties. Is either a PolicyTokenRequest type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.VariableValue or IO[bytes] - :return: VariableValue or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :type parameters: ~azure.mgmt.resource.policy.models.PolicyTokenRequest or IO[bytes] + :return: PolicyTokenResponse or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyTokenResponse :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7328,9 +5307,9 @@ async def create_or_update_at_management_group( _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", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VariableValue] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyTokenResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -7338,12 +5317,10 @@ async def create_or_update_at_management_group( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "VariableValue") + _json = self._serialize.body(parameters, "PolicyTokenRequest") - _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, + _request = build_policy_tokens_acquire_at_management_group_request( + management_group_name=management_group_name, api_version=api_version, content_type=content_type, json=_json, @@ -7360,34 +5337,158 @@ 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("VariableValue", pipeline_response.http_response) + deserialized = self._deserialize("PolicyTokenResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @overload + async def acquire( + self, parameters: _models.PolicyTokenRequest, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyTokenResponse: + """Acquires a policy token. + + This operation acquires a policy token in the given subscription for the given request body. + + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicyTokenRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyTokenResponse or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyTokenResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def acquire( + self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyTokenResponse: + """Acquires a policy token. + + This operation acquires a policy token in the given subscription for the given request body. + + :param parameters: The request body. 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: PolicyTokenResponse or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyTokenResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - 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 acquire( + self, parameters: Union[_models.PolicyTokenRequest, IO[bytes]], **kwargs: Any + ) -> _models.PolicyTokenResponse: + """Acquires a policy token. - 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 acquires a policy token in the given subscription for the given request body. - :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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :param parameters: The request body. Is either a PolicyTokenRequest type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicyTokenRequest or IO[bytes] + :return: PolicyTokenResponse or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyTokenResponse + :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicyTokenResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyTokenRequest") + + _request = build_policy_tokens_acquire_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PolicyTokenResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class DataPolicyManifestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.aio.PolicyClient`'s + :attr:`data_policy_manifests` attribute. + """ + + models = _models + + 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_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 or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.DataPolicyManifest :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7401,13 +5502,11 @@ async def get_at_management_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.VariableValue] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.DataPolicyManifest] = 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_data_policy_manifests_get_by_policy_mode_request( + policy_mode=policy_mode, api_version=api_version, headers=_headers, params=_params, @@ -7423,11 +5522,94 @@ async def get_at_management_group( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("VariableValue", pipeline_response.http_response) + deserialized = self._deserialize("DataPolicyManifest", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + + @distributed_trace + def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_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. + + :param 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. + :type filter: str + :return: An iterator like instance of either DataPolicyManifest or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.models.DataPolicyManifest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.DataPolicyManifestListResult] = 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=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DataPolicyManifestListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) 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 28b5db51f4e5..22cda67a6523 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 @@ -23,7 +23,11 @@ DataPolicyManifest, DataPolicyManifestListResult, ErrorAdditionalInfo, + ErrorDetail, ErrorResponse, + ExternalEvaluationEndpointInvocationResult, + ExternalEvaluationEndpointSettings, + ExternalEvaluationEnforcementSettings, Identity, NonComplianceMessage, Override, @@ -39,24 +43,21 @@ PolicyDefinitionReference, PolicyDefinitionVersion, PolicyDefinitionVersionListResult, - PolicyExemption, - PolicyExemptionListResult, - PolicyExemptionUpdate, + PolicyLogInfo, PolicySetDefinition, PolicySetDefinitionListResult, PolicySetDefinitionVersion, PolicySetDefinitionVersionListResult, - PolicyVariableColumn, - PolicyVariableValueColumnValue, + PolicyTokenOperation, + PolicyTokenRequest, + PolicyTokenResponse, + ProxyResource, + Resource, ResourceSelector, ResourceTypeAliases, Selector, SystemData, UserAssignedIdentitiesValue, - Variable, - VariableListResult, - VariableValue, - VariableValueListResult, ) from ._policy_client_enums import ( # type: ignore @@ -64,12 +65,13 @@ AliasPathTokenType, AliasPatternType, AliasType, - AssignmentScopeValidation, + AssignmentType, CreatedByType, EnforcementMode, - ExemptionCategory, + ExternalEndpointResult, OverrideKind, ParameterType, + PolicyTokenResult, PolicyType, ResourceIdentityType, SelectorKind, @@ -88,7 +90,11 @@ "DataPolicyManifest", "DataPolicyManifestListResult", "ErrorAdditionalInfo", + "ErrorDetail", "ErrorResponse", + "ExternalEvaluationEndpointInvocationResult", + "ExternalEvaluationEndpointSettings", + "ExternalEvaluationEnforcementSettings", "Identity", "NonComplianceMessage", "Override", @@ -104,34 +110,32 @@ "PolicyDefinitionReference", "PolicyDefinitionVersion", "PolicyDefinitionVersionListResult", - "PolicyExemption", - "PolicyExemptionListResult", - "PolicyExemptionUpdate", + "PolicyLogInfo", "PolicySetDefinition", "PolicySetDefinitionListResult", "PolicySetDefinitionVersion", "PolicySetDefinitionVersionListResult", - "PolicyVariableColumn", - "PolicyVariableValueColumnValue", + "PolicyTokenOperation", + "PolicyTokenRequest", + "PolicyTokenResponse", + "ProxyResource", + "Resource", "ResourceSelector", "ResourceTypeAliases", "Selector", "SystemData", "UserAssignedIdentitiesValue", - "Variable", - "VariableListResult", - "VariableValue", - "VariableValueListResult", "AliasPathAttributes", "AliasPathTokenType", "AliasPatternType", "AliasType", - "AssignmentScopeValidation", + "AssignmentType", "CreatedByType", "EnforcementMode", - "ExemptionCategory", + "ExternalEndpointResult", "OverrideKind", "ParameterType", + "PolicyTokenResult", "PolicyType", "ResourceIdentityType", "SelectorKind", diff --git a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/models/_models_py3.py b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/models/_models_py3.py index 5292feea9241..3f9b0c54e776 100644 --- a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/models/_models_py3.py @@ -443,9 +443,8 @@ def __init__(self, **kwargs: Any) -> None: self.info: Optional[JSON] = None -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). +class ErrorDetail(_serialization.Model): + """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -456,7 +455,7 @@ class ErrorResponse(_serialization.Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: list[~azure.mgmt.resource.policy.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.policy.models.ErrorDetail] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.policy.models.ErrorAdditionalInfo] """ @@ -473,7 +472,7 @@ class ErrorResponse(_serialization.Model): "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorResponse]"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } @@ -483,10 +482,181 @@ def __init__(self, **kwargs: Any) -> None: self.code: Optional[str] = None self.message: Optional[str] = None self.target: Optional[str] = None - self.details: Optional[list["_models.ErrorResponse"]] = None + self.details: Optional[list["_models.ErrorDetail"]] = None self.additional_info: Optional[list["_models.ErrorAdditionalInfo"]] = None +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.resource.policy.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.resource.policy.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +class ExternalEvaluationEndpointInvocationResult(_serialization.Model): # pylint: disable=name-too-long + """The external evaluation endpoint invocation results. + + :ivar policy_info: The details of the policy requiring the external endpoint invocation. + :vartype policy_info: ~azure.mgmt.resource.policy.models.PolicyLogInfo + :ivar result: The result of the external endpoint. Possible values are Succeeded and Failed. + Known values are: "Succeeded" and "Failed". + :vartype result: str or ~azure.mgmt.resource.policy.models.ExternalEndpointResult + :ivar message: The status message with additional details about the invocation result. + :vartype message: str + :ivar retry_after: The date and time after which a failed endpoint invocation can be retried. + :vartype retry_after: ~datetime.datetime + :ivar claims: The set of claims that will be attached to the policy token as an attestation for + the result of the endpoint invocation. + :vartype claims: any + :ivar expiration: The expiration of the results. + :vartype expiration: ~datetime.datetime + """ + + _attribute_map = { + "policy_info": {"key": "policyInfo", "type": "PolicyLogInfo"}, + "result": {"key": "result", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "retry_after": {"key": "retryAfter", "type": "iso-8601"}, + "claims": {"key": "claims", "type": "object"}, + "expiration": {"key": "expiration", "type": "iso-8601"}, + } + + def __init__( + self, + *, + policy_info: Optional["_models.PolicyLogInfo"] = None, + result: Optional[Union[str, "_models.ExternalEndpointResult"]] = None, + message: Optional[str] = None, + retry_after: Optional[datetime.datetime] = None, + claims: Optional[Any] = None, + expiration: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword policy_info: The details of the policy requiring the external endpoint invocation. + :paramtype policy_info: ~azure.mgmt.resource.policy.models.PolicyLogInfo + :keyword result: The result of the external endpoint. Possible values are Succeeded and Failed. + Known values are: "Succeeded" and "Failed". + :paramtype result: str or ~azure.mgmt.resource.policy.models.ExternalEndpointResult + :keyword message: The status message with additional details about the invocation result. + :paramtype message: str + :keyword retry_after: The date and time after which a failed endpoint invocation can be + retried. + :paramtype retry_after: ~datetime.datetime + :keyword claims: The set of claims that will be attached to the policy token as an attestation + for the result of the endpoint invocation. + :paramtype claims: any + :keyword expiration: The expiration of the results. + :paramtype expiration: ~datetime.datetime + """ + super().__init__(**kwargs) + self.policy_info = policy_info + self.result = result + self.message = message + self.retry_after = retry_after + self.claims = claims + self.expiration = expiration + + +class ExternalEvaluationEndpointSettings(_serialization.Model): + """The settings of an external endpoint providing evaluation results. + + :ivar kind: The kind of the endpoint. + :vartype kind: str + :ivar details: The details of the endpoint. + :vartype details: any + """ + + _attribute_map = { + "kind": {"key": "kind", "type": "str"}, + "details": {"key": "details", "type": "object"}, + } + + def __init__(self, *, kind: Optional[str] = None, details: Optional[Any] = None, **kwargs: Any) -> None: + """ + :keyword kind: The kind of the endpoint. + :paramtype kind: str + :keyword details: The details of the endpoint. + :paramtype details: any + """ + super().__init__(**kwargs) + self.kind = kind + self.details = details + + +class ExternalEvaluationEnforcementSettings(_serialization.Model): + """The details of the source of external evaluation results required by the policy during + enforcement evaluation. + + :ivar missing_token_action: What to do when evaluating an enforcement policy that requires an + external evaluation and the token is missing. Possible values are Audit and Deny and language + expressions are supported. + :vartype missing_token_action: str + :ivar result_lifespan: The lifespan of the endpoint invocation result after which it's no + longer valid. Value is expected to follow the ISO 8601 duration format and language expressions + are supported. + :vartype result_lifespan: str + :ivar endpoint_settings: The settings of an external endpoint providing evaluation results. + :vartype endpoint_settings: + ~azure.mgmt.resource.policy.models.ExternalEvaluationEndpointSettings + :ivar role_definition_ids: An array of the role definition Ids the assignment's MSI will need + in order to invoke the endpoint. + :vartype role_definition_ids: list[str] + """ + + _attribute_map = { + "missing_token_action": {"key": "missingTokenAction", "type": "str"}, + "result_lifespan": {"key": "resultLifespan", "type": "str"}, + "endpoint_settings": {"key": "endpointSettings", "type": "ExternalEvaluationEndpointSettings"}, + "role_definition_ids": {"key": "roleDefinitionIds", "type": "[str]"}, + } + + def __init__( + self, + *, + missing_token_action: Optional[str] = None, + result_lifespan: Optional[str] = None, + endpoint_settings: Optional["_models.ExternalEvaluationEndpointSettings"] = None, + role_definition_ids: Optional[list[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword missing_token_action: What to do when evaluating an enforcement policy that requires + an external evaluation and the token is missing. Possible values are Audit and Deny and + language expressions are supported. + :paramtype missing_token_action: str + :keyword result_lifespan: The lifespan of the endpoint invocation result after which it's no + longer valid. Value is expected to follow the ISO 8601 duration format and language expressions + are supported. + :paramtype result_lifespan: str + :keyword endpoint_settings: The settings of an external endpoint providing evaluation results. + :paramtype endpoint_settings: + ~azure.mgmt.resource.policy.models.ExternalEvaluationEndpointSettings + :keyword role_definition_ids: An array of the role definition Ids the assignment's MSI will + need in order to invoke the endpoint. + :paramtype role_definition_ids: list[str] + """ + super().__init__(**kwargs) + self.missing_token_action = missing_token_action + self.result_lifespan = result_lifespan + self.endpoint_settings = endpoint_settings + self.role_definition_ids = role_definition_ids + + class Identity(_serialization.Model): """Identity for the resource. Policy assignments support a maximum of one identity. That is either a system assigned identity or a single user assigned identity. @@ -592,7 +762,7 @@ def __init__(self, *, message: str, policy_definition_reference_id: Optional[str class Override(_serialization.Model): """The policy property value override. - :ivar kind: The override kind. "policyEffect" + :ivar kind: The override kind. Known values are: "policyEffect" and "definitionVersion". :vartype kind: str or ~azure.mgmt.resource.policy.models.OverrideKind :ivar value: The value to override the policy property. :vartype value: str @@ -615,7 +785,7 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword kind: The override kind. "policyEffect" + :keyword kind: The override kind. Known values are: "policyEffect" and "definitionVersion". :paramtype kind: str or ~azure.mgmt.resource.policy.models.OverrideKind :keyword value: The value to override the policy property. :paramtype value: str @@ -635,14 +805,14 @@ class ParameterDefinitionsValue(_serialization.Model): "Boolean", "Integer", "Float", and "DateTime". :vartype type: str or ~azure.mgmt.resource.policy.models.ParameterType :ivar allowed_values: The allowed values for the parameter. - :vartype allowed_values: list[JSON] + :vartype allowed_values: list[any] :ivar default_value: The default value for the parameter if no value is provided. - :vartype default_value: JSON + :vartype default_value: any :ivar schema: Provides validation of parameter inputs during assignment using a self-defined JSON schema. This property is only supported for object-type parameters and follows the Json.NET Schema 2019-09 implementation. You can learn more about using schemas at https://json-schema.org/ and test draft schemas at https://www.jsonschemavalidator.net/. - :vartype schema: JSON + :vartype schema: any :ivar metadata: General metadata for the parameter. :vartype metadata: ~azure.mgmt.resource.policy.models.ParameterDefinitionsValueMetadata """ @@ -659,9 +829,9 @@ def __init__( self, *, type: Optional[Union[str, "_models.ParameterType"]] = None, - allowed_values: Optional[list[JSON]] = None, - default_value: Optional[JSON] = None, - schema: Optional[JSON] = None, + allowed_values: Optional[list[Any]] = None, + default_value: Optional[Any] = None, + schema: Optional[Any] = None, metadata: Optional["_models.ParameterDefinitionsValueMetadata"] = None, **kwargs: Any ) -> None: @@ -670,14 +840,14 @@ def __init__( "Boolean", "Integer", "Float", and "DateTime". :paramtype type: str or ~azure.mgmt.resource.policy.models.ParameterType :keyword allowed_values: The allowed values for the parameter. - :paramtype allowed_values: list[JSON] + :paramtype allowed_values: list[any] :keyword default_value: The default value for the parameter if no value is provided. - :paramtype default_value: JSON + :paramtype default_value: any :keyword schema: Provides validation of parameter inputs during assignment using a self-defined JSON schema. This property is only supported for object-type parameters and follows the Json.NET Schema 2019-09 implementation. You can learn more about using schemas at https://json-schema.org/ and test draft schemas at https://www.jsonschemavalidator.net/. - :paramtype schema: JSON + :paramtype schema: any :keyword metadata: General metadata for the parameter. :paramtype metadata: ~azure.mgmt.resource.policy.models.ParameterDefinitionsValueMetadata """ @@ -694,7 +864,7 @@ class ParameterDefinitionsValueMetadata(_serialization.Model): :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, JSON] + :vartype additional_properties: dict[str, any] :ivar display_name: The display name for the parameter. :vartype display_name: str :ivar description: The description of the parameter. @@ -719,7 +889,7 @@ class ParameterDefinitionsValueMetadata(_serialization.Model): def __init__( self, *, - additional_properties: Optional[dict[str, JSON]] = None, + additional_properties: Optional[dict[str, Any]] = None, display_name: Optional[str] = None, description: Optional[str] = None, strong_type: Optional[str] = None, @@ -729,7 +899,7 @@ def __init__( """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, JSON] + :paramtype additional_properties: dict[str, any] :keyword display_name: The display name for the parameter. :paramtype display_name: str :keyword description: The description of the parameter. @@ -754,40 +924,104 @@ class ParameterValuesValue(_serialization.Model): """The value of a parameter. :ivar value: The value of the parameter. - :vartype value: JSON + :vartype value: any """ _attribute_map = { "value": {"key": "value", "type": "object"}, } - def __init__(self, *, value: Optional[JSON] = None, **kwargs: Any) -> None: + def __init__(self, *, value: Optional[Any] = None, **kwargs: Any) -> None: """ :keyword value: The value of the parameter. - :paramtype value: JSON + :paramtype value: any """ super().__init__(**kwargs) self.value = value -class PolicyAssignment(_serialization.Model): - """The policy assignment. +class Resource(_serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The ID of the policy assignment. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar type: The type of the policy assignment. + :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 name: The name of the policy assignment. + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resource.policy.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.system_data: Optional["_models.SystemData"] = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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 + """ + + +class PolicyAssignment(ProxyResource): + """The policy assignment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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 location: The location of the policy assignment. Only required when utilizing managed identity. :vartype location: str :ivar identity: The managed identity associated with the policy assignment. :vartype identity: ~azure.mgmt.resource.policy.models.Identity - :ivar system_data: The system metadata relating to this resource. - :vartype system_data: ~azure.mgmt.resource.policy.models.SystemData :ivar display_name: The display name of the policy assignment. :vartype display_name: str :ivar policy_definition_id: The ID of the policy definition or policy set definition being @@ -812,9 +1046,9 @@ class PolicyAssignment(_serialization.Model): :vartype description: str :ivar metadata: The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :vartype metadata: JSON - :ivar enforcement_mode: The policy assignment enforcement mode. Possible values are Default and - DoNotEnforce. Known values are: "Default" and "DoNotEnforce". + :vartype metadata: any + :ivar enforcement_mode: The policy assignment enforcement mode. Possible values are Default, + DoNotEnforce, and Enroll. Known values are: "Default", "DoNotEnforce", and "Enroll". :vartype enforcement_mode: str or ~azure.mgmt.resource.policy.models.EnforcementMode :ivar non_compliance_messages: The messages that describe why a resource is non-compliant with the policy. @@ -823,25 +1057,33 @@ class PolicyAssignment(_serialization.Model): :vartype resource_selectors: list[~azure.mgmt.resource.policy.models.ResourceSelector] :ivar overrides: The policy property value override. :vartype overrides: list[~azure.mgmt.resource.policy.models.Override] + :ivar assignment_type: The type of policy assignment. Possible values are NotSpecified, System, + SystemHidden, and Custom. Immutable. Known values are: "NotSpecified", "System", + "SystemHidden", and "Custom". + :vartype assignment_type: str or ~azure.mgmt.resource.policy.models.AssignmentType + :ivar instance_id: The instance ID of the policy assignment. This ID only and always changes + when the assignment is deleted and recreated. + :vartype instance_id: str """ _validation = { "id": {"readonly": True}, - "type": {"readonly": True}, "name": {"readonly": True}, + "type": {"readonly": True}, "system_data": {"readonly": True}, "latest_definition_version": {"readonly": True}, "effective_definition_version": {"readonly": True}, "scope": {"readonly": True}, + "instance_id": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "location": {"key": "location", "type": "str"}, "identity": {"key": "identity", "type": "Identity"}, - "system_data": {"key": "systemData", "type": "SystemData"}, "display_name": {"key": "properties.displayName", "type": "str"}, "policy_definition_id": {"key": "properties.policyDefinitionId", "type": "str"}, "definition_version": {"key": "properties.definitionVersion", "type": "str"}, @@ -856,6 +1098,8 @@ class PolicyAssignment(_serialization.Model): "non_compliance_messages": {"key": "properties.nonComplianceMessages", "type": "[NonComplianceMessage]"}, "resource_selectors": {"key": "properties.resourceSelectors", "type": "[ResourceSelector]"}, "overrides": {"key": "properties.overrides", "type": "[Override]"}, + "assignment_type": {"key": "properties.assignmentType", "type": "str"}, + "instance_id": {"key": "properties.instanceId", "type": "str"}, } def __init__( @@ -869,11 +1113,12 @@ def __init__( not_scopes: Optional[list[str]] = None, parameters: Optional[dict[str, "_models.ParameterValuesValue"]] = None, description: Optional[str] = None, - metadata: Optional[JSON] = None, + metadata: Optional[Any] = None, enforcement_mode: Union[str, "_models.EnforcementMode"] = "Default", non_compliance_messages: Optional[list["_models.NonComplianceMessage"]] = None, resource_selectors: Optional[list["_models.ResourceSelector"]] = None, overrides: Optional[list["_models.Override"]] = None, + assignment_type: Optional[Union[str, "_models.AssignmentType"]] = None, **kwargs: Any ) -> None: """ @@ -898,9 +1143,9 @@ def __init__( :paramtype description: str :keyword metadata: The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :paramtype metadata: JSON - :keyword enforcement_mode: The policy assignment enforcement mode. Possible values are Default - and DoNotEnforce. Known values are: "Default" and "DoNotEnforce". + :paramtype metadata: any + :keyword enforcement_mode: The policy assignment enforcement mode. Possible values are Default, + DoNotEnforce, and Enroll. Known values are: "Default", "DoNotEnforce", and "Enroll". :paramtype enforcement_mode: str or ~azure.mgmt.resource.policy.models.EnforcementMode :keyword non_compliance_messages: The messages that describe why a resource is non-compliant with the policy. @@ -911,14 +1156,14 @@ def __init__( :paramtype resource_selectors: list[~azure.mgmt.resource.policy.models.ResourceSelector] :keyword overrides: The policy property value override. :paramtype overrides: list[~azure.mgmt.resource.policy.models.Override] + :keyword assignment_type: The type of policy assignment. Possible values are NotSpecified, + System, SystemHidden, and Custom. Immutable. Known values are: "NotSpecified", "System", + "SystemHidden", and "Custom". + :paramtype assignment_type: str or ~azure.mgmt.resource.policy.models.AssignmentType """ super().__init__(**kwargs) - self.id: Optional[str] = None - self.type: Optional[str] = None - self.name: Optional[str] = None self.location = location self.identity = identity - self.system_data: Optional["_models.SystemData"] = None self.display_name = display_name self.policy_definition_id = policy_definition_id self.definition_version = definition_version @@ -933,33 +1178,37 @@ def __init__( self.non_compliance_messages = non_compliance_messages self.resource_selectors = resource_selectors self.overrides = overrides + self.assignment_type = assignment_type + self.instance_id: Optional[str] = None class PolicyAssignmentListResult(_serialization.Model): - """List of policy assignments. + """The response of a PolicyAssignment list operation. - :ivar value: An array of policy assignments. + All required parameters must be populated in order to send to server. + + :ivar value: The PolicyAssignment items on this page. Required. :vartype value: list[~azure.mgmt.resource.policy.models.PolicyAssignment] - :ivar next_link: The URL to use for getting the next set of results. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { "value": {"key": "value", "type": "[PolicyAssignment]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[list["_models.PolicyAssignment"]] = None, - next_link: Optional[str] = None, - **kwargs: Any + self, *, value: list["_models.PolicyAssignment"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: An array of policy assignments. + :keyword value: The PolicyAssignment items on this page. Required. :paramtype value: list[~azure.mgmt.resource.policy.models.PolicyAssignment] - :keyword next_link: The URL to use for getting the next set of results. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -1016,18 +1265,21 @@ def __init__( self.overrides = overrides -class PolicyDefinition(_serialization.Model): +class PolicyDefinition(ProxyResource): """The policy definition. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The ID of the policy definition. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: The name of the policy definition. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource (Microsoft.Authorization/policyDefinitions). + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar system_data: The system metadata relating to this resource. + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. :vartype system_data: ~azure.mgmt.resource.policy.models.SystemData :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. Known values are: "NotSpecified", "BuiltIn", "Custom", and "Static". @@ -1040,10 +1292,10 @@ class PolicyDefinition(_serialization.Model): :ivar description: The policy definition description. :vartype description: str :ivar policy_rule: The policy rule. - :vartype policy_rule: JSON + :vartype policy_rule: any :ivar metadata: The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :vartype metadata: JSON + :vartype metadata: any :ivar parameters: The parameter definitions for parameters used in the policy rule. The keys are the parameter names. :vartype parameters: dict[str, ~azure.mgmt.resource.policy.models.ParameterDefinitionsValue] @@ -1051,6 +1303,10 @@ class PolicyDefinition(_serialization.Model): :vartype version: str :ivar versions: A list of available versions for this policy definition. :vartype versions: list[str] + :ivar external_evaluation_enforcement_settings: The details of the source of external + evaluation results required by the policy during enforcement evaluation. + :vartype external_evaluation_enforcement_settings: + ~azure.mgmt.resource.policy.models.ExternalEvaluationEnforcementSettings """ _validation = { @@ -1074,6 +1330,10 @@ class PolicyDefinition(_serialization.Model): "parameters": {"key": "properties.parameters", "type": "{ParameterDefinitionsValue}"}, "version": {"key": "properties.version", "type": "str"}, "versions": {"key": "properties.versions", "type": "[str]"}, + "external_evaluation_enforcement_settings": { + "key": "properties.externalEvaluationEnforcementSettings", + "type": "ExternalEvaluationEnforcementSettings", + }, } def __init__( @@ -1083,11 +1343,12 @@ def __init__( mode: str = "Indexed", display_name: Optional[str] = None, description: Optional[str] = None, - policy_rule: Optional[JSON] = None, - metadata: Optional[JSON] = None, + policy_rule: Optional[Any] = None, + metadata: Optional[Any] = None, parameters: Optional[dict[str, "_models.ParameterDefinitionsValue"]] = None, version: Optional[str] = None, versions: Optional[list[str]] = None, + external_evaluation_enforcement_settings: Optional["_models.ExternalEvaluationEnforcementSettings"] = None, **kwargs: Any ) -> None: """ @@ -1102,10 +1363,10 @@ def __init__( :keyword description: The policy definition description. :paramtype description: str :keyword policy_rule: The policy rule. - :paramtype policy_rule: JSON + :paramtype policy_rule: any :keyword metadata: The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :paramtype metadata: JSON + :paramtype metadata: any :keyword parameters: The parameter definitions for parameters used in the policy rule. The keys are the parameter names. :paramtype parameters: dict[str, ~azure.mgmt.resource.policy.models.ParameterDefinitionsValue] @@ -1113,12 +1374,12 @@ def __init__( :paramtype version: str :keyword versions: A list of available versions for this policy definition. :paramtype versions: list[str] + :keyword external_evaluation_enforcement_settings: The details of the source of external + evaluation results required by the policy during enforcement evaluation. + :paramtype external_evaluation_enforcement_settings: + ~azure.mgmt.resource.policy.models.ExternalEvaluationEnforcementSettings """ super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.system_data: Optional["_models.SystemData"] = None self.policy_type = policy_type self.mode = mode self.display_name = display_name @@ -1128,6 +1389,7 @@ def __init__( self.parameters = parameters self.version = version self.versions = versions + self.external_evaluation_enforcement_settings = external_evaluation_enforcement_settings class PolicyDefinitionGroup(_serialization.Model): @@ -1192,30 +1454,32 @@ def __init__( class PolicyDefinitionListResult(_serialization.Model): - """List of policy definitions. + """The response of a PolicyDefinition list operation. - :ivar value: An array of policy definitions. + All required parameters must be populated in order to send to server. + + :ivar value: The PolicyDefinition items on this page. Required. :vartype value: list[~azure.mgmt.resource.policy.models.PolicyDefinition] - :ivar next_link: The URL to use for getting the next set of results. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { "value": {"key": "value", "type": "[PolicyDefinition]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[list["_models.PolicyDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs: Any + self, *, value: list["_models.PolicyDefinition"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: An array of policy definitions. + :keyword value: The PolicyDefinition items on this page. Required. :paramtype value: list[~azure.mgmt.resource.policy.models.PolicyDefinition] - :keyword next_link: The URL to use for getting the next set of results. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -1301,18 +1565,21 @@ def __init__( self.group_names = group_names -class PolicyDefinitionVersion(_serialization.Model): +class PolicyDefinitionVersion(ProxyResource): """The ID of the policy definition version. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The ID of the policy definition version. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: The name of the policy definition version. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource (Microsoft.Authorization/policyDefinitions/versions). + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar system_data: The system metadata relating to this resource. + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. :vartype system_data: ~azure.mgmt.resource.policy.models.SystemData :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. Known values are: "NotSpecified", "BuiltIn", "Custom", and "Static". @@ -1325,15 +1592,19 @@ class PolicyDefinitionVersion(_serialization.Model): :ivar description: The policy definition description. :vartype description: str :ivar policy_rule: The policy rule. - :vartype policy_rule: JSON + :vartype policy_rule: any :ivar metadata: The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :vartype metadata: JSON + :vartype metadata: any :ivar parameters: The parameter definitions for parameters used in the policy rule. The keys are the parameter names. :vartype parameters: dict[str, ~azure.mgmt.resource.policy.models.ParameterDefinitionsValue] :ivar version: The policy definition version in #.#.# format. :vartype version: str + :ivar external_evaluation_enforcement_settings: The details of the source of external + evaluation results required by the policy during enforcement evaluation. + :vartype external_evaluation_enforcement_settings: + ~azure.mgmt.resource.policy.models.ExternalEvaluationEnforcementSettings """ _validation = { @@ -1356,6 +1627,10 @@ class PolicyDefinitionVersion(_serialization.Model): "metadata": {"key": "properties.metadata", "type": "object"}, "parameters": {"key": "properties.parameters", "type": "{ParameterDefinitionsValue}"}, "version": {"key": "properties.version", "type": "str"}, + "external_evaluation_enforcement_settings": { + "key": "properties.externalEvaluationEnforcementSettings", + "type": "ExternalEvaluationEnforcementSettings", + }, } def __init__( @@ -1365,10 +1640,11 @@ def __init__( mode: str = "Indexed", display_name: Optional[str] = None, description: Optional[str] = None, - policy_rule: Optional[JSON] = None, - metadata: Optional[JSON] = None, + policy_rule: Optional[Any] = None, + metadata: Optional[Any] = None, parameters: Optional[dict[str, "_models.ParameterDefinitionsValue"]] = None, version: Optional[str] = None, + external_evaluation_enforcement_settings: Optional["_models.ExternalEvaluationEnforcementSettings"] = None, **kwargs: Any ) -> None: """ @@ -1383,21 +1659,21 @@ def __init__( :keyword description: The policy definition description. :paramtype description: str :keyword policy_rule: The policy rule. - :paramtype policy_rule: JSON + :paramtype policy_rule: any :keyword metadata: The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :paramtype metadata: JSON + :paramtype metadata: any :keyword parameters: The parameter definitions for parameters used in the policy rule. The keys are the parameter names. :paramtype parameters: dict[str, ~azure.mgmt.resource.policy.models.ParameterDefinitionsValue] :keyword version: The policy definition version in #.#.# format. :paramtype version: str + :keyword external_evaluation_enforcement_settings: The details of the source of external + evaluation results required by the policy during enforcement evaluation. + :paramtype external_evaluation_enforcement_settings: + ~azure.mgmt.resource.policy.models.ExternalEvaluationEnforcementSettings """ super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.system_data: Optional["_models.SystemData"] = None self.policy_type = policy_type self.mode = mode self.display_name = display_name @@ -1406,33 +1682,36 @@ def __init__( self.metadata = metadata self.parameters = parameters self.version = version + self.external_evaluation_enforcement_settings = external_evaluation_enforcement_settings class PolicyDefinitionVersionListResult(_serialization.Model): - """List of policy definition versions. + """The response of a PolicyDefinitionVersion list operation. + + All required parameters must be populated in order to send to server. - :ivar value: An array of policy definitions versions. + :ivar value: The PolicyDefinitionVersion items on this page. Required. :vartype value: list[~azure.mgmt.resource.policy.models.PolicyDefinitionVersion] - :ivar next_link: The URL to use for getting the next set of results. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { "value": {"key": "value", "type": "[PolicyDefinitionVersion]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[list["_models.PolicyDefinitionVersion"]] = None, - next_link: Optional[str] = None, - **kwargs: Any + self, *, value: list["_models.PolicyDefinitionVersion"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: An array of policy definitions versions. + :keyword value: The PolicyDefinitionVersion items on this page. Required. :paramtype value: list[~azure.mgmt.resource.policy.models.PolicyDefinitionVersion] - :keyword next_link: The URL to use for getting the next set of results. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -1440,210 +1719,186 @@ def __init__( self.next_link = next_link -class PolicyExemption(_serialization.Model): - """The policy exemption. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. +class PolicyLogInfo(_serialization.Model): + """The policy log info. - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.resource.policy.models.SystemData - :ivar id: The ID of the policy exemption. - :vartype id: str - :ivar name: The name of the policy exemption. - :vartype name: str - :ivar type: The type of the resource (Microsoft.Authorization/policyExemptions). - :vartype type: str - :ivar policy_assignment_id: The ID of the policy assignment that is being exempted. Required. + :ivar policy_definition_id: The policy definition Id. + :vartype policy_definition_id: str + :ivar policy_set_definition_id: The policy set definition Id. + :vartype policy_set_definition_id: str + :ivar policy_definition_reference_id: The policy definition instance Id inside a policy set. + :vartype policy_definition_reference_id: str + :ivar policy_set_definition_name: The policy set definition name. + :vartype policy_set_definition_name: str + :ivar policy_set_definition_display_name: The policy set definition display name. + :vartype policy_set_definition_display_name: str + :ivar policy_set_definition_version: The policy set definition version. + :vartype policy_set_definition_version: str + :ivar policy_set_definition_category: The policy set definition category. + :vartype policy_set_definition_category: str + :ivar policy_definition_name: The policy definition name. + :vartype policy_definition_name: str + :ivar policy_definition_display_name: The policy definition display name. + :vartype policy_definition_display_name: str + :ivar policy_definition_version: The policy definition version. + :vartype policy_definition_version: str + :ivar policy_definition_effect: The policy definition action. + :vartype policy_definition_effect: str + :ivar policy_definition_group_names: An array of policy definition group names. + :vartype policy_definition_group_names: list[str] + :ivar policy_assignment_id: The policy assignment Id. :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: JSON - :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 policy_assignment_name: The policy assignment name. + :vartype policy_assignment_name: str + :ivar policy_assignment_display_name: The policy assignment display name. + :vartype policy_assignment_display_name: str + :ivar policy_assignment_version: The policy assignment version. + :vartype policy_assignment_version: str + :ivar policy_assignment_scope: The policy assignment scope. + :vartype policy_assignment_scope: str + :ivar resource_location: The resource location. + :vartype resource_location: str + :ivar ancestors: The management group ancestors. + :vartype ancestors: str + :ivar compliance_reason_code: The policy compliance reason code. + :vartype compliance_reason_code: str + :ivar policy_exemption_ids: An array of policy exemption Ids. + :vartype policy_exemption_ids: list[str] """ - _validation = { - "system_data": {"readonly": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "policy_assignment_id": {"required": True}, - "exemption_category": {"required": True}, - } - _attribute_map = { - "system_data": {"key": "systemData", "type": "SystemData"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "policy_assignment_id": {"key": "properties.policyAssignmentId", "type": "str"}, - "policy_definition_reference_ids": {"key": "properties.policyDefinitionReferenceIds", "type": "[str]"}, - "exemption_category": {"key": "properties.exemptionCategory", "type": "str"}, - "expires_on": {"key": "properties.expiresOn", "type": "iso-8601"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "metadata": {"key": "properties.metadata", "type": "object"}, - "resource_selectors": {"key": "properties.resourceSelectors", "type": "[ResourceSelector]"}, - "assignment_scope_validation": {"key": "properties.assignmentScopeValidation", "type": "str"}, + "policy_definition_id": {"key": "policyDefinitionId", "type": "str"}, + "policy_set_definition_id": {"key": "policySetDefinitionId", "type": "str"}, + "policy_definition_reference_id": {"key": "policyDefinitionReferenceId", "type": "str"}, + "policy_set_definition_name": {"key": "policySetDefinitionName", "type": "str"}, + "policy_set_definition_display_name": {"key": "policySetDefinitionDisplayName", "type": "str"}, + "policy_set_definition_version": {"key": "policySetDefinitionVersion", "type": "str"}, + "policy_set_definition_category": {"key": "policySetDefinitionCategory", "type": "str"}, + "policy_definition_name": {"key": "policyDefinitionName", "type": "str"}, + "policy_definition_display_name": {"key": "policyDefinitionDisplayName", "type": "str"}, + "policy_definition_version": {"key": "policyDefinitionVersion", "type": "str"}, + "policy_definition_effect": {"key": "policyDefinitionEffect", "type": "str"}, + "policy_definition_group_names": {"key": "policyDefinitionGroupNames", "type": "[str]"}, + "policy_assignment_id": {"key": "policyAssignmentId", "type": "str"}, + "policy_assignment_name": {"key": "policyAssignmentName", "type": "str"}, + "policy_assignment_display_name": {"key": "policyAssignmentDisplayName", "type": "str"}, + "policy_assignment_version": {"key": "policyAssignmentVersion", "type": "str"}, + "policy_assignment_scope": {"key": "policyAssignmentScope", "type": "str"}, + "resource_location": {"key": "resourceLocation", "type": "str"}, + "ancestors": {"key": "ancestors", "type": "str"}, + "compliance_reason_code": {"key": "complianceReasonCode", "type": "str"}, + "policy_exemption_ids": {"key": "policyExemptionIds", "type": "[str]"}, } 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[JSON] = None, - resource_selectors: Optional[list["_models.ResourceSelector"]] = None, - assignment_scope_validation: Optional[Union[str, "_models.AssignmentScopeValidation"]] = None, + policy_definition_id: Optional[str] = None, + policy_set_definition_id: Optional[str] = None, + policy_definition_reference_id: Optional[str] = None, + policy_set_definition_name: Optional[str] = None, + policy_set_definition_display_name: Optional[str] = None, + policy_set_definition_version: Optional[str] = None, + policy_set_definition_category: Optional[str] = None, + policy_definition_name: Optional[str] = None, + policy_definition_display_name: Optional[str] = None, + policy_definition_version: Optional[str] = None, + policy_definition_effect: Optional[str] = None, + policy_definition_group_names: Optional[list[str]] = None, + policy_assignment_id: Optional[str] = None, + policy_assignment_name: Optional[str] = None, + policy_assignment_display_name: Optional[str] = None, + policy_assignment_version: Optional[str] = None, + policy_assignment_scope: Optional[str] = None, + resource_location: Optional[str] = None, + ancestors: Optional[str] = None, + compliance_reason_code: Optional[str] = None, + policy_exemption_ids: Optional[list[str]] = None, **kwargs: Any ) -> None: """ - :keyword policy_assignment_id: The ID of the policy assignment that is being exempted. - Required. + :keyword policy_definition_id: The policy definition Id. + :paramtype policy_definition_id: str + :keyword policy_set_definition_id: The policy set definition Id. + :paramtype policy_set_definition_id: str + :keyword policy_definition_reference_id: The policy definition instance Id inside a policy set. + :paramtype policy_definition_reference_id: str + :keyword policy_set_definition_name: The policy set definition name. + :paramtype policy_set_definition_name: str + :keyword policy_set_definition_display_name: The policy set definition display name. + :paramtype policy_set_definition_display_name: str + :keyword policy_set_definition_version: The policy set definition version. + :paramtype policy_set_definition_version: str + :keyword policy_set_definition_category: The policy set definition category. + :paramtype policy_set_definition_category: str + :keyword policy_definition_name: The policy definition name. + :paramtype policy_definition_name: str + :keyword policy_definition_display_name: The policy definition display name. + :paramtype policy_definition_display_name: str + :keyword policy_definition_version: The policy definition version. + :paramtype policy_definition_version: str + :keyword policy_definition_effect: The policy definition action. + :paramtype policy_definition_effect: str + :keyword policy_definition_group_names: An array of policy definition group names. + :paramtype policy_definition_group_names: list[str] + :keyword policy_assignment_id: The policy assignment Id. :paramtype policy_assignment_id: str - :keyword policy_definition_reference_ids: The policy definition reference ID list when the - associated policy assignment is an assignment of a policy set definition. - :paramtype policy_definition_reference_ids: list[str] - :keyword exemption_category: The policy exemption category. Possible values are Waiver and - Mitigated. Required. Known values are: "Waiver" and "Mitigated". - :paramtype exemption_category: str or ~azure.mgmt.resource.policy.models.ExemptionCategory - :keyword expires_on: The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) - of the policy exemption. - :paramtype expires_on: ~datetime.datetime - :keyword display_name: The display name of the policy exemption. - :paramtype display_name: str - :keyword description: The description of the policy exemption. - :paramtype description: str - :keyword metadata: The policy exemption metadata. Metadata is an open ended object and is - typically a collection of key value pairs. - :paramtype metadata: JSON - :keyword resource_selectors: The resource selector list to filter policies by resource - properties. - :paramtype resource_selectors: list[~azure.mgmt.resource.policy.models.ResourceSelector] - :keyword assignment_scope_validation: The option whether validate the exemption is at or under - the assignment scope. Known values are: "Default" and "DoNotValidate". - :paramtype assignment_scope_validation: str or - ~azure.mgmt.resource.policy.models.AssignmentScopeValidation + :keyword policy_assignment_name: The policy assignment name. + :paramtype policy_assignment_name: str + :keyword policy_assignment_display_name: The policy assignment display name. + :paramtype policy_assignment_display_name: str + :keyword policy_assignment_version: The policy assignment version. + :paramtype policy_assignment_version: str + :keyword policy_assignment_scope: The policy assignment scope. + :paramtype policy_assignment_scope: str + :keyword resource_location: The resource location. + :paramtype resource_location: str + :keyword ancestors: The management group ancestors. + :paramtype ancestors: str + :keyword compliance_reason_code: The policy compliance reason code. + :paramtype compliance_reason_code: str + :keyword policy_exemption_ids: An array of policy exemption Ids. + :paramtype policy_exemption_ids: list[str] """ super().__init__(**kwargs) - self.system_data: Optional["_models.SystemData"] = None - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None + self.policy_definition_id = policy_definition_id + self.policy_set_definition_id = policy_set_definition_id + self.policy_definition_reference_id = policy_definition_reference_id + self.policy_set_definition_name = policy_set_definition_name + self.policy_set_definition_display_name = policy_set_definition_display_name + self.policy_set_definition_version = policy_set_definition_version + self.policy_set_definition_category = policy_set_definition_category + self.policy_definition_name = policy_definition_name + self.policy_definition_display_name = policy_definition_display_name + self.policy_definition_version = policy_definition_version + self.policy_definition_effect = policy_definition_effect + self.policy_definition_group_names = policy_definition_group_names self.policy_assignment_id = policy_assignment_id - self.policy_definition_reference_ids = policy_definition_reference_ids - self.exemption_category = exemption_category - self.expires_on = expires_on - self.display_name = display_name - self.description = description - self.metadata = metadata - self.resource_selectors = resource_selectors - self.assignment_scope_validation = assignment_scope_validation - - -class PolicyExemptionListResult(_serialization.Model): - """List of policy exemptions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: An array of policy exemptions. - :vartype value: list[~azure.mgmt.resource.policy.models.PolicyExemption] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[PolicyExemption]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[list["_models.PolicyExemption"]] = None, **kwargs: Any) -> None: - """ - :keyword value: An array of policy exemptions. - :paramtype value: list[~azure.mgmt.resource.policy.models.PolicyExemption] - """ - super().__init__(**kwargs) - self.value = value - self.next_link: Optional[str] = None - - -class PolicyExemptionUpdate(_serialization.Model): - """The policy exemption 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 - """ - - _attribute_map = { - "resource_selectors": {"key": "properties.resourceSelectors", "type": "[ResourceSelector]"}, - "assignment_scope_validation": {"key": "properties.assignmentScopeValidation", "type": "str"}, - } - - def __init__( - self, - *, - resource_selectors: Optional[list["_models.ResourceSelector"]] = None, - assignment_scope_validation: Optional[Union[str, "_models.AssignmentScopeValidation"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword resource_selectors: The resource selector list to filter policies by resource - properties. - :paramtype resource_selectors: list[~azure.mgmt.resource.policy.models.ResourceSelector] - :keyword assignment_scope_validation: The option whether validate the exemption is at or under - the assignment scope. Known values are: "Default" and "DoNotValidate". - :paramtype assignment_scope_validation: str or - ~azure.mgmt.resource.policy.models.AssignmentScopeValidation - """ - super().__init__(**kwargs) - self.resource_selectors = resource_selectors - self.assignment_scope_validation = assignment_scope_validation + self.policy_assignment_name = policy_assignment_name + self.policy_assignment_display_name = policy_assignment_display_name + self.policy_assignment_version = policy_assignment_version + self.policy_assignment_scope = policy_assignment_scope + self.resource_location = resource_location + self.ancestors = ancestors + self.compliance_reason_code = compliance_reason_code + self.policy_exemption_ids = policy_exemption_ids -class PolicySetDefinition(_serialization.Model): +class PolicySetDefinition(ProxyResource): """The policy set definition. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The ID of the policy set definition. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: The name of the policy set definition. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar system_data: The system metadata relating to this resource. + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. :vartype system_data: ~azure.mgmt.resource.policy.models.SystemData :ivar policy_type: The type of policy set definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. Known values are: "NotSpecified", "BuiltIn", "Custom", and @@ -1655,7 +1910,7 @@ class PolicySetDefinition(_serialization.Model): :vartype description: str :ivar metadata: The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :vartype metadata: JSON + :vartype metadata: any :ivar parameters: The policy set definition parameters that can be used in policy definition references. :vartype parameters: dict[str, ~azure.mgmt.resource.policy.models.ParameterDefinitionsValue] @@ -1700,7 +1955,7 @@ def __init__( policy_type: Optional[Union[str, "_models.PolicyType"]] = None, display_name: Optional[str] = None, description: Optional[str] = None, - metadata: Optional[JSON] = None, + metadata: Optional[Any] = None, parameters: Optional[dict[str, "_models.ParameterDefinitionsValue"]] = None, policy_definitions: Optional[list["_models.PolicyDefinitionReference"]] = None, policy_definition_groups: Optional[list["_models.PolicyDefinitionGroup"]] = None, @@ -1719,7 +1974,7 @@ def __init__( :paramtype description: str :keyword metadata: The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :paramtype metadata: JSON + :paramtype metadata: any :keyword parameters: The policy set definition parameters that can be used in policy definition references. :paramtype parameters: dict[str, ~azure.mgmt.resource.policy.models.ParameterDefinitionsValue] @@ -1736,10 +1991,6 @@ def __init__( :paramtype versions: list[str] """ super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.system_data: Optional["_models.SystemData"] = None self.policy_type = policy_type self.display_name = display_name self.description = description @@ -1752,30 +2003,32 @@ def __init__( class PolicySetDefinitionListResult(_serialization.Model): - """List of policy set definitions. + """The response of a PolicySetDefinition list operation. - :ivar value: An array of policy set definitions. + All required parameters must be populated in order to send to server. + + :ivar value: The PolicySetDefinition items on this page. Required. :vartype value: list[~azure.mgmt.resource.policy.models.PolicySetDefinition] - :ivar next_link: The URL to use for getting the next set of results. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { "value": {"key": "value", "type": "[PolicySetDefinition]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[list["_models.PolicySetDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs: Any + self, *, value: list["_models.PolicySetDefinition"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: An array of policy set definitions. + :keyword value: The PolicySetDefinition items on this page. Required. :paramtype value: list[~azure.mgmt.resource.policy.models.PolicySetDefinition] - :keyword next_link: The URL to use for getting the next set of results. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -1783,18 +2036,21 @@ def __init__( self.next_link = next_link -class PolicySetDefinitionVersion(_serialization.Model): +class PolicySetDefinitionVersion(ProxyResource): """The policy set definition version. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The ID of the policy set definition version. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: The name of the policy set definition version. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions/versions). + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar system_data: The system metadata relating to this resource. + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. :vartype system_data: ~azure.mgmt.resource.policy.models.SystemData :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. Known values are: "NotSpecified", "BuiltIn", "Custom", and "Static". @@ -1805,7 +2061,7 @@ class PolicySetDefinitionVersion(_serialization.Model): :vartype description: str :ivar metadata: The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :vartype metadata: JSON + :vartype metadata: any :ivar parameters: The policy set definition parameters that can be used in policy definition references. :vartype parameters: dict[str, ~azure.mgmt.resource.policy.models.ParameterDefinitionsValue] @@ -1847,7 +2103,7 @@ def __init__( policy_type: Optional[Union[str, "_models.PolicyType"]] = None, display_name: Optional[str] = None, description: Optional[str] = None, - metadata: Optional[JSON] = None, + metadata: Optional[Any] = None, parameters: Optional[dict[str, "_models.ParameterDefinitionsValue"]] = None, policy_definitions: Optional[list["_models.PolicyDefinitionReference"]] = None, policy_definition_groups: Optional[list["_models.PolicyDefinitionGroup"]] = None, @@ -1864,7 +2120,7 @@ def __init__( :paramtype description: str :keyword metadata: The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :paramtype metadata: JSON + :paramtype metadata: any :keyword parameters: The policy set definition parameters that can be used in policy definition references. :paramtype parameters: dict[str, ~azure.mgmt.resource.policy.models.ParameterDefinitionsValue] @@ -1879,10 +2135,6 @@ def __init__( :paramtype version: str """ super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.system_data: Optional["_models.SystemData"] = None self.policy_type = policy_type self.display_name = display_name self.description = description @@ -1894,30 +2146,32 @@ def __init__( class PolicySetDefinitionVersionListResult(_serialization.Model): - """List of policy set definition versions. + """The response of a PolicySetDefinitionVersion list operation. + + All required parameters must be populated in order to send to server. - :ivar value: An array of policy set definition versions. + :ivar value: The PolicySetDefinitionVersion items on this page. Required. :vartype value: list[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] - :ivar next_link: The URL to use for getting the next set of results. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { "value": {"key": "value", "type": "[PolicySetDefinitionVersion]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[list["_models.PolicySetDefinitionVersion"]] = None, - next_link: Optional[str] = None, - **kwargs: Any + self, *, value: list["_models.PolicySetDefinitionVersion"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: An array of policy set definition versions. + :keyword value: The PolicySetDefinitionVersion items on this page. Required. :paramtype value: list[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] - :keyword next_link: The URL to use for getting the next set of results. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -1925,65 +2179,161 @@ def __init__( self.next_link = next_link -class PolicyVariableColumn(_serialization.Model): - """The variable column. +class PolicyTokenOperation(_serialization.Model): + """The resource operation to acquire a token for. All required parameters must be populated in order to send to server. - :ivar column_name: The name of this policy variable column. Required. - :vartype column_name: str + :ivar uri: The request URI of the resource operation. Required. + :vartype uri: str + :ivar http_method: The http method of the resource operation. Required. + :vartype http_method: str + :ivar content: The payload of the resource operation. + :vartype content: any """ _validation = { - "column_name": {"required": True}, + "uri": {"required": True}, + "http_method": {"required": True}, } _attribute_map = { - "column_name": {"key": "columnName", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "http_method": {"key": "httpMethod", "type": "str"}, + "content": {"key": "content", "type": "object"}, } - def __init__(self, *, column_name: str, **kwargs: Any) -> None: + def __init__(self, *, uri: str, http_method: str, content: Optional[Any] = None, **kwargs: Any) -> None: """ - :keyword column_name: The name of this policy variable column. Required. - :paramtype column_name: str + :keyword uri: The request URI of the resource operation. Required. + :paramtype uri: str + :keyword http_method: The http method of the resource operation. Required. + :paramtype http_method: str + :keyword content: The payload of the resource operation. + :paramtype content: any """ super().__init__(**kwargs) - self.column_name = column_name + self.uri = uri + self.http_method = http_method + self.content = content -class PolicyVariableValueColumnValue(_serialization.Model): - """The name value tuple for this variable value column. +class PolicyTokenRequest(_serialization.Model): + """The policy token request properties. All required parameters must be populated in order to send to server. - :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: JSON + :ivar operation: The resource operation to acquire a token for. Required. + :vartype operation: ~azure.mgmt.resource.policy.models.PolicyTokenOperation + :ivar change_reference: The change reference. + :vartype change_reference: str """ _validation = { - "column_name": {"required": True}, - "column_value": {"required": True}, + "operation": {"required": True}, } _attribute_map = { - "column_name": {"key": "columnName", "type": "str"}, - "column_value": {"key": "columnValue", "type": "object"}, + "operation": {"key": "operation", "type": "PolicyTokenOperation"}, + "change_reference": {"key": "changeReference", "type": "str"}, } - def __init__(self, *, column_name: str, column_value: JSON, **kwargs: Any) -> None: + def __init__( + self, *, operation: "_models.PolicyTokenOperation", change_reference: Optional[str] = None, **kwargs: Any + ) -> None: """ - :keyword column_name: Column name for the variable value. Required. - :paramtype column_name: str - :keyword column_value: Column value for the variable value; this can be an integer, double, - boolean, null or a string. Required. - :paramtype column_value: JSON + :keyword operation: The resource operation to acquire a token for. Required. + :paramtype operation: ~azure.mgmt.resource.policy.models.PolicyTokenOperation + :keyword change_reference: The change reference. + :paramtype change_reference: str """ super().__init__(**kwargs) - self.column_name = column_name - self.column_value = column_value + self.operation = operation + self.change_reference = change_reference + + +class PolicyTokenResponse(_serialization.Model): + """The policy token response properties. + + :ivar result: The result of the completed token acquisition operation. Possible values are + Succeeded and Failed. Known values are: "Succeeded" and "Failed". + :vartype result: str or ~azure.mgmt.resource.policy.models.PolicyTokenResult + :ivar message: Status message with additional details about the token acquisition operation + result. + :vartype message: str + :ivar retry_after: The date and time after which the client can try to acquire a token again in + the case of retry-able failures. + :vartype retry_after: ~datetime.datetime + :ivar results: An array of external evaluation endpoint invocation results. + :vartype results: + list[~azure.mgmt.resource.policy.models.ExternalEvaluationEndpointInvocationResult] + :ivar change_reference: The change reference associated with the operation for which the token + is acquired. + :vartype change_reference: str + :ivar token: The issued policy token. + :vartype token: str + :ivar token_id: The unique Id assigned to the policy token. + :vartype token_id: str + :ivar expiration: The expiration of the policy token. + :vartype expiration: ~datetime.datetime + """ + + _attribute_map = { + "result": {"key": "result", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "retry_after": {"key": "retryAfter", "type": "iso-8601"}, + "results": {"key": "results", "type": "[ExternalEvaluationEndpointInvocationResult]"}, + "change_reference": {"key": "changeReference", "type": "str"}, + "token": {"key": "token", "type": "str"}, + "token_id": {"key": "tokenId", "type": "str"}, + "expiration": {"key": "expiration", "type": "iso-8601"}, + } + + def __init__( + self, + *, + result: Optional[Union[str, "_models.PolicyTokenResult"]] = None, + message: Optional[str] = None, + retry_after: Optional[datetime.datetime] = None, + results: Optional[list["_models.ExternalEvaluationEndpointInvocationResult"]] = None, + change_reference: Optional[str] = None, + token: Optional[str] = None, + token_id: Optional[str] = None, + expiration: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword result: The result of the completed token acquisition operation. Possible values are + Succeeded and Failed. Known values are: "Succeeded" and "Failed". + :paramtype result: str or ~azure.mgmt.resource.policy.models.PolicyTokenResult + :keyword message: Status message with additional details about the token acquisition operation + result. + :paramtype message: str + :keyword retry_after: The date and time after which the client can try to acquire a token again + in the case of retry-able failures. + :paramtype retry_after: ~datetime.datetime + :keyword results: An array of external evaluation endpoint invocation results. + :paramtype results: + list[~azure.mgmt.resource.policy.models.ExternalEvaluationEndpointInvocationResult] + :keyword change_reference: The change reference associated with the operation for which the + token is acquired. + :paramtype change_reference: str + :keyword token: The issued policy token. + :paramtype token: str + :keyword token_id: The unique Id assigned to the policy token. + :paramtype token_id: str + :keyword expiration: The expiration of the policy token. + :paramtype expiration: ~datetime.datetime + """ + super().__init__(**kwargs) + self.result = result + self.message = message + self.retry_after = retry_after + self.results = results + self.change_reference = change_reference + self.token = token + self.token_id = token_id + self.expiration = expiration class ResourceSelector(_serialization.Model): @@ -2173,161 +2523,3 @@ def __init__(self, **kwargs: Any) -> None: super().__init__(**kwargs) self.principal_id: Optional[str] = None self.client_id: Optional[str] = None - - -class Variable(_serialization.Model): - """The variable. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.resource.policy.models.SystemData - :ivar id: The ID of the variable. - :vartype id: str - :ivar name: The name of the variable. - :vartype name: str - :ivar type: The type of the resource (Microsoft.Authorization/variables). - :vartype type: str - :ivar columns: Variable column definitions. Required. - :vartype columns: list[~azure.mgmt.resource.policy.models.PolicyVariableColumn] - """ - - _validation = { - "system_data": {"readonly": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "columns": {"required": True}, - } - - _attribute_map = { - "system_data": {"key": "systemData", "type": "SystemData"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "columns": {"key": "properties.columns", "type": "[PolicyVariableColumn]"}, - } - - def __init__(self, *, columns: list["_models.PolicyVariableColumn"], **kwargs: Any) -> None: - """ - :keyword columns: Variable column definitions. Required. - :paramtype columns: list[~azure.mgmt.resource.policy.models.PolicyVariableColumn] - """ - super().__init__(**kwargs) - self.system_data: Optional["_models.SystemData"] = None - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.columns = columns - - -class VariableListResult(_serialization.Model): - """List of variables. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: An array of variables. - :vartype value: list[~azure.mgmt.resource.policy.models.Variable] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Variable]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[list["_models.Variable"]] = None, **kwargs: Any) -> None: - """ - :keyword value: An array of variables. - :paramtype value: list[~azure.mgmt.resource.policy.models.Variable] - """ - super().__init__(**kwargs) - self.value = value - self.next_link: Optional[str] = None - - -class VariableValue(_serialization.Model): - """The variable value. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.resource.policy.models.SystemData - :ivar id: The ID of the variable. - :vartype id: str - :ivar name: The name of the variable. - :vartype name: str - :ivar type: The type of the resource (Microsoft.Authorization/variables/values). - :vartype type: str - :ivar values: Variable value column value array. Required. - :vartype values: list[~azure.mgmt.resource.policy.models.PolicyVariableValueColumnValue] - """ - - _validation = { - "system_data": {"readonly": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "values": {"required": True}, - } - - _attribute_map = { - "system_data": {"key": "systemData", "type": "SystemData"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "values": {"key": "properties.values", "type": "[PolicyVariableValueColumnValue]"}, - } - - def __init__(self, *, values: list["_models.PolicyVariableValueColumnValue"], **kwargs: Any) -> None: - """ - :keyword values: Variable value column value array. Required. - :paramtype values: list[~azure.mgmt.resource.policy.models.PolicyVariableValueColumnValue] - """ - super().__init__(**kwargs) - self.system_data: Optional["_models.SystemData"] = None - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.values = values - - -class VariableValueListResult(_serialization.Model): - """List of variable values. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: An array of variable values. - :vartype value: list[~azure.mgmt.resource.policy.models.VariableValue] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VariableValue]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[list["_models.VariableValue"]] = None, **kwargs: Any) -> None: - """ - :keyword value: An array of variable values. - :paramtype value: list[~azure.mgmt.resource.policy.models.VariableValue] - """ - super().__init__(**kwargs) - self.value = value - self.next_link: Optional[str] = None diff --git a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/models/_policy_client_enums.py index 72647fa2a336..4c8e0de7aadc 100644 --- a/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource-policy/azure/mgmt/resource/policy/models/_policy_client_enums.py @@ -60,14 +60,19 @@ class AliasType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Alias value is secret.""" -class AssignmentScopeValidation(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The option whether validate the exemption is at or under the assignment scope.""" +class AssignmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of policy assignment. Possible values are NotSpecified, System, SystemHidden, and + Custom. Immutable. + """ - 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.""" + NOT_SPECIFIED = "NotSpecified" + """The not specified assignment type.""" + SYSTEM = "System" + """The system assignment type.""" + SYSTEM_HIDDEN = "SystemHidden" + """The system hidden assignment type.""" + CUSTOM = "Custom" + """The custom assignment type.""" class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -80,22 +85,25 @@ class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): class EnforcementMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The policy assignment enforcement mode. Possible values are Default and DoNotEnforce.""" + """The policy assignment enforcement mode. Possible values are Default, DoNotEnforce, and Enroll.""" DEFAULT = "Default" """The policy effect is enforced during resource creation or update.""" DO_NOT_ENFORCE = "DoNotEnforce" """The policy effect is not enforced during resource creation or update.""" + ENROLL = "Enroll" + """The policy effect is not enforced during resource creation or update until the resource or + scope of the resource is enrolled to the assignment instance. Enrollment occurs upon deployment + of the policy enrollment resource.""" -class ExemptionCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The policy exemption category. Possible values are Waiver and Mitigated.""" +class ExternalEndpointResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The result of the external endpoint. Possible values are Succeeded and Failed.""" - 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.""" + SUCCEEDED = "Succeeded" + """The external endpoint succeeded.""" + FAILED = "Failed" + """The external endpoint failed.""" class OverrideKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -103,27 +111,51 @@ class OverrideKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): POLICY_EFFECT = "policyEffect" """It will override the policy effect type.""" + DEFINITION_VERSION = "definitionVersion" + """It will override the definition version property value of the policy assignment.""" class ParameterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The data type of the parameter.""" STRING = "String" + """The string parameter type.""" ARRAY = "Array" + """The array parameter type.""" OBJECT = "Object" + """The object parameter type.""" BOOLEAN = "Boolean" + """The boolean parameter type.""" INTEGER = "Integer" + """The integer parameter type.""" FLOAT = "Float" + """The float parameter type.""" DATE_TIME = "DateTime" + """The date-time parameter type.""" + + +class PolicyTokenResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The result of the completed token acquisition operation. Possible values are Succeeded and + Failed. + """ + + SUCCEEDED = "Succeeded" + """The token acquisition succeeded.""" + FAILED = "Failed" + """The token acquisition failed.""" class PolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static.""" NOT_SPECIFIED = "NotSpecified" + """The not specified policy definition type.""" BUILT_IN = "BuiltIn" + """The built in policy definition type.""" CUSTOM = "Custom" + """The custom policy definition type.""" STATIC = "Static" + """The static policy definition type.""" class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): 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 f302859689f6..14d63c274848 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 @@ -12,30 +12,26 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._operations import DataPolicyManifestsOperations # type: ignore -from ._operations import PolicyDefinitionsOperations # type: ignore +from ._operations import PolicyAssignmentsOperations # type: ignore from ._operations import PolicyDefinitionVersionsOperations # type: ignore -from ._operations import PolicySetDefinitionsOperations # type: ignore from ._operations import PolicySetDefinitionVersionsOperations # type: ignore -from ._operations import PolicyAssignmentsOperations # type: ignore -from ._operations import PolicyExemptionsOperations # type: ignore -from ._operations import VariablesOperations # type: ignore -from ._operations import VariableValuesOperations # type: ignore +from ._operations import PolicyDefinitionsOperations # type: ignore +from ._operations import PolicySetDefinitionsOperations # type: ignore +from ._operations import PolicyTokensOperations # type: ignore +from ._operations import DataPolicyManifestsOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "DataPolicyManifestsOperations", - "PolicyDefinitionsOperations", + "PolicyAssignmentsOperations", "PolicyDefinitionVersionsOperations", - "PolicySetDefinitionsOperations", "PolicySetDefinitionVersionsOperations", - "PolicyAssignmentsOperations", - "PolicyExemptionsOperations", - "VariablesOperations", - "VariableValuesOperations", + "PolicyDefinitionsOperations", + "PolicySetDefinitionsOperations", + "PolicyTokensOperations", + "DataPolicyManifestsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() 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 29e62121956e..47479b7e2c43 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 @@ -38,25 +38,32 @@ _SERIALIZER.client_side_validation = False -def build_data_policy_manifests_get_by_policy_mode_request( # pylint: disable=name-too-long - policy_mode: str, **kwargs: Any +def build_policy_assignments_get_request( + scope: str, policy_assignment_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", "2020-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "policyMode": _SERIALIZER.url("policy_mode", policy_mode, "str"), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url( + "policy_assignment_name", policy_assignment_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" + ), } _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") @@ -64,46 +71,54 @@ def build_data_policy_manifests_get_by_policy_mode_request( # pylint: disable=n return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_data_policy_manifests_list_request(*, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: +def build_policy_assignments_create_request(scope: str, policy_assignment_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", "2020-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/dataPolicyManifests") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url( + "policy_assignment_name", policy_assignment_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" + ), + } + + _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", skip_quote=True) # 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_definitions_create_or_update_request( # pylint: disable=name-too-long - policy_definition_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_policy_assignments_update_request(scope: str, policy_assignment_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "policyDefinitionName": _SERIALIZER.url( - "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url( + "policy_assignment_name", policy_assignment_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" ), } @@ -117,27 +132,24 @@ def build_policy_definitions_create_or_update_request( # pylint: disable=name-t _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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_delete_request( - policy_definition_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_policy_assignments_delete_request(scope: str, policy_assignment_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "policyDefinitionName": _SERIALIZER.url( - "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url( + "policy_assignment_name", policy_assignment_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" ), } @@ -152,31 +164,39 @@ def build_policy_definitions_delete_request( return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_get_request( - policy_definition_name: str, subscription_id: str, **kwargs: Any +def build_policy_assignments_list_for_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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments", ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "policyDefinitionName": _SERIALIZER.url( - "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" - ), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str", min_length=1), } _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", maximum=1000, minimum=1) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -184,27 +204,38 @@ def build_policy_definitions_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_get_built_in_request( # pylint: disable=name-too-long - policy_definition_name: str, **kwargs: Any +def build_policy_assignments_list_request( + 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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments" + ) path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url( - "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" - ), + "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", maximum=1000, minimum=1) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -212,59 +243,82 @@ def build_policy_definitions_get_built_in_request( # pylint: disable=name-too-l return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_create_or_update_at_management_group_request( # pylint: disable=name-too-long - management_group_id: str, policy_definition_name: str, **kwargs: Any +def build_policy_assignments_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, + 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", "2023-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments", ) path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - "policyDefinitionName": _SERIALIZER.url( - "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), + "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", pattern=r"^.+$"), } _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", maximum=1000, minimum=1) # 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="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_delete_at_management_group_request( # pylint: disable=name-too-long - management_group_id: str, policy_definition_name: str, **kwargs: Any +def build_policy_assignments_list_for_resource_group_request( # pylint: disable=name-too-long + resource_group_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments", ) path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - "policyDefinitionName": _SERIALIZER.url( - "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), } @@ -272,32 +326,32 @@ def build_policy_definitions_delete_at_management_group_request( # pylint: disa # 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", maximum=1000, minimum=1) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_get_at_management_group_request( # pylint: disable=name-too-long - management_group_id: str, policy_definition_name: str, **kwargs: Any +def build_policy_assignments_delete_by_id_request( # pylint: disable=name-too-long + policy_assignment_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", - ) + _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - "policyDefinitionName": _SERIALIZER.url( - "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" - ), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -308,59 +362,59 @@ def build_policy_definitions_get_at_management_group_request( # pylint: disable # 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, headers=_headers, **kwargs) -def build_policy_definitions_list_request( - subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any +def build_policy_assignments_create_by_id_request( # pylint: disable=name-too-long + policy_assignment_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions" - ) + _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _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", skip_quote=True) - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # 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_definitions_list_built_in_request( # pylint: disable=name-too-long - *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any +def build_policy_assignments_get_by_id_request( # pylint: disable=name-too-long + policy_assignment_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policyDefinitions") + _url = kwargs.pop("template_url", "/{policyAssignmentId}") + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -368,37 +422,33 @@ def build_policy_definitions_list_built_in_request( # pylint: disable=name-too- return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_list_by_management_group_request( # pylint: disable=name-too-long - management_group_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any +def build_policy_assignments_update_by_id_request( # pylint: disable=name-too-long + policy_assignment_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions", - ) + _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _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", skip_quote=True) - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # 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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definition_versions_list_all_builtins_request( # pylint: disable=name-too-long @@ -407,7 +457,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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -422,23 +472,22 @@ def build_policy_definition_versions_list_all_builtins_request( # pylint: disab return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definition_versions_list_all_at_management_group_request( # pylint: disable=name-too-long - management_group_name: str, **kwargs: Any +def build_policy_definition_versions_list_built_in_request( # pylint: disable=name-too-long + policy_definition_name: str, *, 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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/listPolicyDefinitionVersions", + "template_url", "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions" ) path_format_arguments = { - "managementGroupName": _SERIALIZER.url( - "management_group_name", management_group_name, "str", max_length=90, min_length=1 + "policyDefinitionName": _SERIALIZER.url( + "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" ), } @@ -446,58 +495,30 @@ def build_policy_definition_versions_list_all_at_management_group_request( # py # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_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", "2023-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/listPolicyDefinitionVersions" - ) - 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_policy_definition_versions_create_or_update_request( # pylint: disable=name-too-long - policy_definition_name: str, policy_definition_version: str, subscription_id: str, **kwargs: Any +def build_policy_definition_versions_get_built_in_request( # pylint: disable=name-too-long + policy_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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}", + "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}", ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "policyDefinitionName": _SERIALIZER.url( "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" ), @@ -512,34 +533,28 @@ def build_policy_definition_versions_create_or_update_request( # pylint: disabl _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="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definition_versions_delete_request( # pylint: disable=name-too-long - policy_definition_name: str, policy_definition_version: str, subscription_id: str, **kwargs: Any +def build_policy_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}", + "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/listPolicyDefinitionVersions", ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "policyDefinitionName": _SERIALIZER.url( - "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" - ), - "policyDefinitionVersion": _SERIALIZER.url( - "policy_definition_version", policy_definition_version, "str", pattern=r"^\d+\.\d+\.\d+$" + "managementGroupName": _SERIALIZER.url( + "management_group_name", management_group_name, "str", max_length=90, min_length=1 ), } @@ -551,37 +566,38 @@ def build_policy_definition_versions_delete_request( # pylint: disable=name-too # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definition_versions_get_request( # pylint: disable=name-too-long - policy_definition_name: str, policy_definition_version: str, subscription_id: str, **kwargs: Any +def build_policy_definition_versions_list_by_management_group_request( # pylint: disable=name-too-long + management_group_name: str, policy_definition_name: str, *, 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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}", + "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions", ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "managementGroupName": _SERIALIZER.url( + "management_group_name", management_group_name, "str", max_length=90, min_length=1 + ), "policyDefinitionName": _SERIALIZER.url( "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" ), - "policyDefinitionVersion": _SERIALIZER.url( - "policy_definition_version", policy_definition_version, "str", pattern=r"^\d+\.\d+\.\d+$" - ), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -589,21 +605,24 @@ def build_policy_definition_versions_get_request( # pylint: disable=name-too-lo return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definition_versions_get_built_in_request( # pylint: disable=name-too-long - policy_definition_name: str, policy_definition_version: str, **kwargs: Any +def build_policy_definition_versions_get_at_management_group_request( # pylint: disable=name-too-long + management_group_name: str, policy_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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}", + "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}", ) path_format_arguments = { + "managementGroupName": _SERIALIZER.url( + "management_group_name", management_group_name, "str", max_length=90, min_length=1 + ), "policyDefinitionName": _SERIALIZER.url( "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" ), @@ -629,7 +648,7 @@ def build_policy_definition_versions_create_or_update_at_management_group_reques _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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -669,7 +688,7 @@ def build_policy_definition_versions_delete_at_management_group_request( # pyli _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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -700,30 +719,21 @@ def build_policy_definition_versions_delete_at_management_group_request( # pyli return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definition_versions_get_at_management_group_request( # pylint: disable=name-too-long - management_group_name: str, policy_definition_name: str, policy_definition_version: str, **kwargs: Any +def build_policy_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}", + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/listPolicyDefinitionVersions" ) path_format_arguments = { - "managementGroupName": _SERIALIZER.url( - "management_group_name", management_group_name, "str", max_length=90, min_length=1 - ), - "policyDefinitionName": _SERIALIZER.url( - "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" - ), - "policyDefinitionVersion": _SERIALIZER.url( - "policy_definition_version", policy_definition_version, "str", pattern=r"^\d+\.\d+\.\d+$" - ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -734,7 +744,7 @@ def build_policy_definition_versions_get_at_management_group_request( # pylint: # 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_definition_versions_list_request( # pylint: disable=name-too-long @@ -743,7 +753,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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -771,31 +781,34 @@ def build_policy_definition_versions_list_request( # pylint: disable=name-too-l return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definition_versions_list_built_in_request( # pylint: disable=name-too-long - policy_definition_name: str, *, top: Optional[int] = None, **kwargs: Any +def build_policy_definition_versions_get_request( # pylint: disable=name-too-long + policy_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions" + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}", ) path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "policyDefinitionName": _SERIALIZER.url( "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" ), + "policyDefinitionVersion": _SERIALIZER.url( + "policy_definition_version", policy_definition_version, "str", pattern=r"^\d+\.\d+\.\d+$" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -803,64 +816,65 @@ def build_policy_definition_versions_list_built_in_request( # pylint: disable=n return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definition_versions_list_by_management_group_request( # pylint: disable=name-too-long - management_group_name: str, policy_definition_name: str, *, top: Optional[int] = None, **kwargs: Any +def build_policy_definition_versions_create_or_update_request( # pylint: disable=name-too-long + policy_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}", ) path_format_arguments = { - "managementGroupName": _SERIALIZER.url( - "management_group_name", management_group_name, "str", max_length=90, min_length=1 - ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "policyDefinitionName": _SERIALIZER.url( "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" ), + "policyDefinitionVersion": _SERIALIZER.url( + "policy_definition_version", policy_definition_version, "str", pattern=r"^\d+\.\d+\.\d+$" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # 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_set_definitions_create_or_update_request( # pylint: disable=name-too-long - policy_set_definition_name: str, subscription_id: str, **kwargs: Any +def build_policy_definition_versions_delete_request( # pylint: disable=name-too-long + policy_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", "2023-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/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", - pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", + "policyDefinitionName": _SERIALIZER.url( + "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" + ), + "policyDefinitionVersion": _SERIALIZER.url( + "policy_definition_version", policy_definition_version, "str", pattern=r"^\d+\.\d+\.\d+$" ), } @@ -870,29 +884,46 @@ def build_policy_set_definitions_create_or_update_request( # pylint: disable=na _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, 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 +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", "2025-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_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_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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + "template_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, @@ -905,43 +936,49 @@ def build_policy_set_definitions_delete_request( # pylint: disable=name-too-lon # 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", maximum=1000, minimum=1) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + 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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + "/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", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", ), + "policyDefinitionVersion": _SERIALIZER.url( + "policy_definition_version", policy_definition_version, "str", pattern=r"^\d+\.\d+\.\d+$" + ), } _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") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -949,45 +986,41 @@ def build_policy_set_definitions_get_request( 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 +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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/listPolicySetDefinitionVersions", ) path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url( - "policy_set_definition_name", - policy_set_definition_name, - "str", - pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", + "managementGroupName": _SERIALIZER.url( + "management_group_name", management_group_name, "str", max_length=90, min_length=1 ), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _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) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_list_request( # pylint: disable=name-too-long - subscription_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, @@ -995,23 +1028,30 @@ def build_policy_set_definitions_list_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions" + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions", ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "managementGroupName": _SERIALIZER.url( + "management_group_name", management_group_name, "str", max_length=90, min_length=1 + ), + "policySetDefinitionName": _SERIALIZER.url( + "policy_set_definition_name", + policy_set_definition_name, + "str", + pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", + ), } _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", skip_quote=True) if expand is not None: _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: @@ -1023,93 +1063,81 @@ def build_policy_set_definitions_list_request( # pylint: disable=name-too-long 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 +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", "2023-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_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", skip_quote=True) - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) - - # 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_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", "2023-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + "/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", max_length=90, min_length=1 + ), "policySetDefinitionName": _SERIALIZER.url( "policy_set_definition_name", policy_set_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", ), + "policyDefinitionVersion": _SERIALIZER.url( + "policy_definition_version", policy_definition_version, "str", pattern=r"^\d+\.\d+\.\d+$" + ), } _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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", 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_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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + "/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", max_length=90, min_length=1 + ), "policySetDefinitionName": _SERIALIZER.url( "policy_set_definition_name", policy_set_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", ), + "policyDefinitionVersion": _SERIALIZER.url( + "policy_definition_version", policy_definition_version, "str", pattern=r"^\d+\.\d+\.\d+$" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1118,100 +1146,73 @@ def build_policy_set_definitions_delete_at_management_group_request( # pylint: _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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", 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_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: _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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + "/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", max_length=90, min_length=1 + ), "policySetDefinitionName": _SERIALIZER.url( "policy_set_definition_name", policy_set_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", ), + "policyDefinitionVersion": _SERIALIZER.url( + "policy_definition_version", policy_definition_version, "str", pattern=r"^\d+\.\d+\.\d+$" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _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) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -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, +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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/listPolicySetDefinitionVersions", ) path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "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 filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) - - # 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", "2023-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/listPolicySetDefinitionVersions") - # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -1221,23 +1222,32 @@ def build_policy_set_definition_versions_list_all_builtins_request( # pylint: d 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 +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, ) -> 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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/listPolicySetDefinitionVersions", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions", ) path_format_arguments = { - "managementGroupName": _SERIALIZER.url( - "management_group_name", management_group_name, "str", max_length=90, min_length=1 + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policySetDefinitionName": _SERIALIZER.url( + "policy_set_definition_name", + policy_set_definition_name, + "str", + pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", ), } @@ -1245,40 +1255,60 @@ def build_policy_set_definition_versions_list_all_at_management_group_request( # 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", maximum=1000, minimum=1) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", 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 +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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/listPolicySetDefinitionVersions", + "/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", + pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", + ), + "policyDefinitionVersion": _SERIALIZER.url( + "policy_definition_version", policy_definition_version, "str", pattern=r"^\d+\.\d+\.\d+$" + ), } _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="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definition_versions_create_or_update_request( # pylint: disable=name-too-long @@ -1287,7 +1317,7 @@ def build_policy_set_definition_versions_create_or_update_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -1328,7 +1358,7 @@ def build_policy_set_definition_versions_delete_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1360,44 +1390,24 @@ def build_policy_set_definition_versions_delete_request( # pylint: disable=name return HttpRequest(method="DELETE", 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, - **kwargs: Any, +def build_policy_definitions_list_built_in_request( # pylint: disable=name-too-long + *, filter: 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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_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", - pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", - ), - "policyDefinitionVersion": _SERIALIZER.url( - "policy_definition_version", policy_definition_version, "str", pattern=r"^\d+\.\d+\.\d+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policyDefinitions") # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1405,37 +1415,26 @@ def build_policy_set_definition_versions_get_request( # pylint: disable=name-to return HttpRequest(method="GET", 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 +def build_policy_definitions_get_built_in_request( # pylint: disable=name-too-long + policy_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}", - ) + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url( - "policy_set_definition_name", - policy_set_definition_name, - "str", - pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", - ), - "policyDefinitionVersion": _SERIALIZER.url( - "policy_definition_version", policy_definition_version, "str", pattern=r"^\d+\.\d+\.\d+$" + "policyDefinitionName": _SERIALIZER.url( + "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" ), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -1444,41 +1443,30 @@ def build_policy_set_definition_versions_get_built_in_request( # pylint: disabl return HttpRequest(method="GET", 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_definitions_list_by_management_group_request( # pylint: disable=name-too-long + management_group_id: str, *, filter: 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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions", ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "policySetDefinitionName": _SERIALIZER.url( - "policy_set_definition_name", - policy_set_definition_name, - "str", - pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", - ), + "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 expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) @@ -1488,25 +1476,24 @@ def build_policy_set_definition_versions_list_request( # pylint: disable=name-t return HttpRequest(method="GET", 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_definitions_get_at_management_group_request( # pylint: disable=name-too-long + management_group_id: str, policy_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions" + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", ) path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url( - "policy_set_definition_name", - policy_set_definition_name, - "str", - pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "policyDefinitionName": _SERIALIZER.url( + "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" ), } @@ -1514,10 +1501,6 @@ def build_policy_set_definition_versions_list_built_in_request( # pylint: disab # 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", maximum=1000, minimum=1) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1525,33 +1508,25 @@ def build_policy_set_definition_versions_list_built_in_request( # pylint: disab 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 +def build_policy_definitions_create_or_update_at_management_group_request( # pylint: disable=name-too-long + management_group_id: str, policy_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", ) path_format_arguments = { - "managementGroupName": _SERIALIZER.url( - "management_group_name", management_group_name, "str", max_length=90, min_length=1 - ), - "policySetDefinitionName": _SERIALIZER.url( - "policy_set_definition_name", - policy_set_definition_name, - "str", - pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", - ), - "policyDefinitionVersion": _SERIALIZER.url( - "policy_definition_version", policy_definition_version, "str", pattern=r"^\d+\.\d+\.\d+$" + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "policyDefinitionName": _SERIALIZER.url( + "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" ), } @@ -1568,32 +1543,24 @@ def build_policy_set_definition_versions_create_or_update_at_management_group_re 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 +def build_policy_definitions_delete_at_management_group_request( # pylint: disable=name-too-long + management_group_id: str, policy_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", ) path_format_arguments = { - "managementGroupName": _SERIALIZER.url( - "management_group_name", management_group_name, "str", max_length=90, min_length=1 - ), - "policySetDefinitionName": _SERIALIZER.url( - "policy_set_definition_name", - policy_set_definition_name, - "str", - pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", - ), - "policyDefinitionVersion": _SERIALIZER.url( - "policy_definition_version", policy_definition_version, "str", pattern=r"^\d+\.\d+\.\d+$" + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "policyDefinitionName": _SERIALIZER.url( + "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" ), } @@ -1608,46 +1575,31 @@ def build_policy_set_definition_versions_delete_at_management_group_request( # return HttpRequest(method="DELETE", 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, +def build_policy_definitions_list_request( + subscription_id: str, *, filter: 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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}", + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions" ) path_format_arguments = { - "managementGroupName": _SERIALIZER.url( - "management_group_name", management_group_name, "str", max_length=90, min_length=1 - ), - "policySetDefinitionName": _SERIALIZER.url( - "policy_set_definition_name", - policy_set_definition_name, - "str", - pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", - ), - "policyDefinitionVersion": _SERIALIZER.url( - "policy_definition_version", policy_definition_version, "str", pattern=r"^\d+\.\d+\.\d+$" - ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1655,34 +1607,24 @@ def build_policy_set_definition_versions_get_at_management_group_request( # pyl return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **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, +def build_policy_definitions_get_request( + policy_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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", ) path_format_arguments = { - "managementGroupName": _SERIALIZER.url( - "management_group_name", management_group_name, "str", max_length=90, min_length=1 - ), - "policySetDefinitionName": _SERIALIZER.url( - "policy_set_definition_name", - policy_set_definition_name, - "str", - pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policyDefinitionName": _SERIALIZER.url( + "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" ), } @@ -1690,10 +1632,6 @@ def build_policy_set_definition_versions_list_by_management_group_request( # py # 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", maximum=1000, minimum=1) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1701,21 +1639,25 @@ def build_policy_set_definition_versions_list_by_management_group_request( # py return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_delete_request(scope: str, policy_assignment_name: str, **kwargs: Any) -> HttpRequest: +def build_policy_definitions_create_or_update_request( # pylint: disable=name-too-long + policy_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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "policyAssignmentName": _SERIALIZER.url( - "policy_assignment_name", policy_assignment_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policyDefinitionName": _SERIALIZER.url( + "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" ), } @@ -1725,27 +1667,31 @@ def build_policy_assignments_delete_request(scope: str, policy_assignment_name: _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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_request(scope: str, policy_assignment_name: str, **kwargs: Any) -> HttpRequest: +def build_policy_definitions_delete_request( + policy_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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "policyAssignmentName": _SERIALIZER.url( - "policy_assignment_name", policy_assignment_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policyDefinitionName": _SERIALIZER.url( + "policy_definition_name", policy_definition_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" ), } @@ -1755,39 +1701,31 @@ def build_policy_assignments_create_request(scope: str, policy_assignment_name: _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, headers=_headers, **kwargs) -def build_policy_assignments_get_request( - scope: str, policy_assignment_name: str, *, expand: 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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" - ) - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "policyAssignmentName": _SERIALIZER.url( - "policy_assignment_name", policy_assignment_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = kwargs.pop("template_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") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1795,22 +1733,25 @@ def build_policy_assignments_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_update_request(scope: str, policy_assignment_name: str, **kwargs: Any) -> HttpRequest: +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", "2023-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + "template_url", "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "policyAssignmentName": _SERIALIZER.url( - "policy_assignment_name", policy_assignment_name, "str", pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$" + "policySetDefinitionName": _SERIALIZER.url( + "policy_set_definition_name", + policy_set_definition_name, + "str", + pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", ), } @@ -1818,18 +1759,17 @@ def build_policy_assignments_update_request(scope: str, policy_assignment_name: # 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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_list_for_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, - subscription_id: str, +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, @@ -1839,31 +1779,28 @@ 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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/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", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), + "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", skip_quote=True) + _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", maximum=1000, minimum=1) - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1871,51 +1808,36 @@ def build_policy_assignments_list_for_resource_group_request( # pylint: disable return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_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, - expand: Optional[str] = None, - top: Optional[int] = 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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments", + "/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", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "policySetDefinitionName": _SERIALIZER.url( + "policy_set_definition_name", + policy_set_definition_name, + "str", + pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", ), - "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", pattern=r"^.+$"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) + _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", maximum=1000, minimum=1) - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1923,98 +1845,66 @@ def build_policy_assignments_list_for_resource_request( # pylint: disable=name- return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_list_for_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, +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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/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", + pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", + ), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) _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_assignments_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments" + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) - _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_assignments_delete_by_id_request( # pylint: disable=name-too-long - policy_assignment_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", "2023-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{policyAssignmentId}") - path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "policySetDefinitionName": _SERIALIZER.url( + "policy_set_definition_name", + policy_set_definition_name, + "str", + pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2028,56 +1918,75 @@ def build_policy_assignments_delete_by_id_request( # pylint: disable=name-too-l return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_by_id_request( # pylint: disable=name-too-long - policy_assignment_id: str, **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", "2023-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{policyAssignmentId}") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions" + ) path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), + "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", maximum=1000, minimum=1) # 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="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_by_id_request( # pylint: disable=name-too-long - policy_assignment_id: str, *, expand: Optional[str] = None, **kwargs: Any +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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{policyAssignmentId}") + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policySetDefinitionName": _SERIALIZER.url( + "policy_set_definition_name", + policy_set_definition_name, + "str", + pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", + ), } _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") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -2085,20 +1994,29 @@ def build_policy_assignments_get_by_id_request( # pylint: disable=name-too-long return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_update_by_id_request( # pylint: disable=name-too-long - policy_assignment_id: 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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{policyAssignmentId}") + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policySetDefinitionName": _SERIALIZER.url( + "policy_set_definition_name", + policy_set_definition_name, + "str", + pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2111,23 +2029,31 @@ def build_policy_assignments_update_by_id_request( # pylint: disable=name-too-l _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) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_exemptions_delete_request(scope: str, policy_exemption_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: _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", "2022-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" + "template_url", + "/subscriptions/{subscriptionId}/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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policySetDefinitionName": _SERIALIZER.url( + "policy_set_definition_name", + policy_set_definition_name, + "str", + pattern=r"^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$", + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2141,23 +2067,25 @@ def build_policy_exemptions_delete_request(scope: str, policy_exemption_name: st return HttpRequest(method="DELETE", 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_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", "2022-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/acquirePolicyToken", ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_name, "str"), + "managementGroupName": _SERIALIZER.url( + "management_group_name", management_group_name, "str", max_length=90, min_length=1 + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2170,51 +2098,23 @@ def build_policy_exemptions_create_or_update_request( # pylint: disable=name-to _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_exemptions_get_request(scope: str, policy_exemption_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", "2022-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_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") - - # 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_exemptions_update_request(scope: str, policy_exemption_name: str, **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", "2022-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/acquirePolicyToken" ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2227,31 +2127,27 @@ def build_policy_exemptions_update_request(scope: str, policy_exemption_name: st _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) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_exemptions_list_request( - subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +def build_data_policy_manifests_get_by_policy_mode_request( # pylint: disable=name-too-long + policy_mode: 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", "2022-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions" - ) + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policyMode": _SERIALIZER.url("policy_mode", policy_mode, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -2260,33 +2156,20 @@ def build_policy_exemptions_list_request( 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 -) -> HttpRequest: +def build_data_policy_manifests_list_request(*, filter: 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", "2022-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/dataPolicyManifests") # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -2294,2614 +2177,167 @@ 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_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, -) -> 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", "2022-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "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"), - } +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - _url: str = _url.format(**path_format_arguments) # type: ignore + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.PolicyClient`'s + :attr:`policy_assignments` attribute. + """ - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + models = _models - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + 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") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + @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 + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :return: PolicyAssignment or the result of cls(response) + :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 {}) -def build_policy_exemptions_list_for_management_group_request( # pylint: disable=name-too-long - management_group_id: str, *, filter: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) - accept = _headers.pop("Accept", "application/json") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyExemptions", - ) - path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - _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_delete_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", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_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="DELETE", 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_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_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", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_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_delete_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", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_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="DELETE", 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_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_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", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_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_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", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_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_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", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_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_delete_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", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_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="DELETE", 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_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_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", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_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_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", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_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_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", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_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_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: - _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", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_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="DELETE", 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_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_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", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_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) - - -class DataPolicyManifestsOperations: - """ - .. 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. - """ - - models = _models - - 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_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 or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) - cls: ClsType[_models.DataPolicyManifest] = kwargs.pop("cls", None) - - _request = build_data_policy_manifests_get_by_policy_mode_request( - policy_mode=policy_mode, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataPolicyManifest", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - 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. - - :param 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. - :type filter: str - :return: An iterator like instance of either DataPolicyManifest or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.DataPolicyManifest] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) - cls: ClsType[_models.DataPolicyManifestListResult] = 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DataPolicyManifestListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class PolicyDefinitionsOperations: - """ - .. 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. - """ - - models = _models - - 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") - - @overload - def create_or_update( - self, - policy_definition_name: str, - parameters: _models.PolicyDefinition, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyDefinition: - """Creates or updates a policy definition in a subscription. - - This operation creates or updates a policy definition in the given subscription with the given - name. - - :param policy_definition_name: The name of the policy definition to create. 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 or the result of cls(response) - :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: - """Creates or updates a policy definition in a subscription. - - This operation creates or updates a policy definition in the given subscription with the given - name. - - :param policy_definition_name: The name of the policy definition to create. 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 or the result of cls(response) - :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, IO[bytes]], **kwargs: Any - ) -> _models.PolicyDefinition: - """Creates or updates a policy definition in a subscription. - - This operation creates or updates a policy definition in the given subscription with the given - name. - - :param policy_definition_name: The name of the policy definition to create. 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 IO[bytes] - :return: PolicyDefinition or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PolicyDefinition") - - _request = build_policy_definitions_create_or_update_request( - policy_definition_name=policy_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyDefinition", pipeline_response.http_response) - - 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: - """Deletes a policy definition in a subscription. - - This operation deletes the policy definition in the given subscription with the given name. - - :param policy_definition_name: The name of the policy definition to delete. Required. - :type policy_definition_name: str - :return: None or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: - """Retrieves a policy definition in a subscription. - - This operation retrieves the policy definition in the given subscription with the given name. - - :param policy_definition_name: The name of the policy definition to get. Required. - :type policy_definition_name: str - :return: PolicyDefinition or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyDefinition", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get_built_in(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: - """Retrieves a built-in policy definition. - - This operation retrieves the built-in policy definition with the given name. - - :param policy_definition_name: The name of the built-in policy definition to get. Required. - :type policy_definition_name: str - :return: PolicyDefinition or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyDefinition] = kwargs.pop("cls", None) - - _request = build_policy_definitions_get_built_in_request( - policy_definition_name=policy_definition_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyDefinition", pipeline_response.http_response) - - 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: - """Creates or updates a policy definition in a management group. - - This operation creates or updates a policy definition in the given management group with the - given name. - - :param 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 create. 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 or the result of cls(response) - :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: - """Creates or updates a policy definition in a management group. - - This operation creates or updates a policy definition in the given management group with the - given name. - - :param 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 create. 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 or the result of cls(response) - :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, IO[bytes]], - **kwargs: Any, - ) -> _models.PolicyDefinition: - """Creates or updates a policy definition in a management group. - - This operation creates or updates a policy definition in the given management group with the - given name. - - :param 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 create. 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 IO[bytes] - :return: PolicyDefinition or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PolicyDefinition") - - _request = build_policy_definitions_create_or_update_at_management_group_request( - management_group_id=management_group_id, - policy_definition_name=policy_definition_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyDefinition", pipeline_response.http_response) - - 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: - """Deletes a policy definition in a management group. - - 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 delete. Required. - :type policy_definition_name: str - :return: None or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def get_at_management_group( - self, management_group_id: str, policy_definition_name: str, **kwargs: Any - ) -> _models.PolicyDefinition: - """Retrieve a policy definition in a management group. - - 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 or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyDefinition", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.PolicyDefinition"]: - """Retrieves policy definitions in a subscription. - - 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}. - - :param 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. - :type filter: str - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicyDefinition or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyDefinitionListResult] = 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_built_in( - self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.PolicyDefinition"]: - """Retrieve built-in policy definitions. - - 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 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. - :type filter: str - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicyDefinition or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyDefinitionListResult] = 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @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"]: - """Retrieve policy definitions in a management group. - - 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 - :param 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. - :type filter: str - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicyDefinition or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyDefinitionListResult] = 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class PolicyDefinitionVersionsOperations: - """ - .. 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. - """ - - models = _models - - 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_all_builtins(self, **kwargs: Any) -> _models.PolicyDefinitionVersionListResult: - """Lists all built-in policy definition versions. - - This operation lists all the built-in policy definition versions for all built-in policy - definitions. - - :return: PolicyDefinitionVersionListResult or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyDefinitionVersionListResult] = kwargs.pop("cls", None) - - _request = build_policy_definition_versions_list_all_builtins_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyDefinitionVersionListResult", pipeline_response.http_response) - - 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.PolicyDefinitionVersionListResult: - """Lists all policy definition versions at management group scope. - - 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 or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyDefinitionVersionListResult", pipeline_response.http_response) - - 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 or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyDefinitionVersionListResult] = kwargs.pop("cls", None) - - _request = build_policy_definition_versions_list_all_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyDefinitionVersionListResult", pipeline_response.http_response) - - 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: - """Creates or updates a policy definition in a subscription. - - This operation creates or updates a policy definition in the given subscription with the given - name. - - :param policy_definition_name: The name of the policy definition. 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 or the result of cls(response) - :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: - """Creates or updates a policy definition in a subscription. - - This operation creates or updates a policy definition in the given subscription with the given - name. - - :param policy_definition_name: The name of the policy definition. 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 or the result of cls(response) - :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, IO[bytes]], - **kwargs: Any, - ) -> _models.PolicyDefinitionVersion: - """Creates or updates a policy definition in a subscription. - - This operation creates or updates a policy definition in the given subscription with the given - name. - - :param policy_definition_name: The name of the policy definition. 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 IO[bytes] - :return: PolicyDefinitionVersion or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PolicyDefinitionVersion") - - _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, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyDefinitionVersion", pipeline_response.http_response) - - 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: - """Deletes a policy definition version in a subscription. - - 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 or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def get( - self, policy_definition_name: str, policy_definition_version: str, **kwargs: Any - ) -> _models.PolicyDefinitionVersion: - """Retrieves a policy definition version in a subscription. - - 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 or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyDefinitionVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get_built_in( - self, policy_definition_name: str, policy_definition_version: str, **kwargs: Any - ) -> _models.PolicyDefinitionVersion: - """Retrieves a built-in policy definition version. - - 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 or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyDefinitionVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update_at_management_group( - self, - management_group_name: str, - policy_definition_name: str, - policy_definition_version: str, - parameters: _models.PolicyDefinitionVersion, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.PolicyDefinitionVersion: - """Creates or updates a policy definition version in a management group. - - 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. 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion - :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: - """Creates or updates a policy definition version in a management group. - - 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. 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update_at_management_group( - self, - management_group_name: str, - policy_definition_name: str, - policy_definition_version: str, - parameters: Union[_models.PolicyDefinitionVersion, IO[bytes]], - **kwargs: Any, - ) -> _models.PolicyDefinitionVersion: - """Creates or updates a policy definition version in a management group. - - 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 IO[bytes] - :return: PolicyDefinitionVersion or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PolicyDefinitionVersion") - - _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, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyDefinitionVersion", pipeline_response.http_response) - - 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_name: str, policy_definition_name: str, policy_definition_version: str, **kwargs: Any - ) -> None: - """Deletes a policy definition in a management group. - - This operation deletes the policy definition 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 - :return: None or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[None] = 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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def get_at_management_group( - self, management_group_name: str, policy_definition_name: str, policy_definition_version: str, **kwargs: Any - ) -> _models.PolicyDefinitionVersion: - """Retrieve a policy definition version in a management group. - - This operation retrieves the 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 - :return: PolicyDefinitionVersion or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyDefinitionVersion] = 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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyDefinitionVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, policy_definition_name: str, top: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.PolicyDefinitionVersion"]: - """Retrieves policy definition versions for a given policy definition in a subscription. - - 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 - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicyDefinitionVersion or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinitionVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyDefinitionVersionListResult] = 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyDefinitionVersionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_built_in( - self, policy_definition_name: str, top: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.PolicyDefinitionVersion"]: - """Retrieve built-in policy definition versions. - - 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 - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicyDefinitionVersion or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinitionVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyDefinitionVersionListResult] = 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyDefinitionVersionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @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"]: - """Retrieve policy definition versions in a management group policy definition. - - 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 - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicyDefinitionVersion or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinitionVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyDefinitionVersionListResult] = 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _request = build_policy_assignments_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyDefinitionVersionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + _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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, ) - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) -class PolicySetDefinitionsOperations: - """ - .. 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. - """ - - models = _models + if cls: + return cls(pipeline_response, 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") + return deserialized # type: ignore @overload - def create_or_update( + def create( self, - policy_set_definition_name: str, - parameters: _models.PolicySetDefinition, + scope: str, + policy_assignment_name: str, + parameters: _models.PolicyAssignment, *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicySetDefinition: - """Creates or updates a policy set definition. - - This operation creates or updates a policy set definition in the given subscription with the - given name. + ) -> _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 policy_set_definition_name: The name of the policy set definition to create. Required. - :type policy_set_definition_name: str - :param parameters: The policy set definition properties. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :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: PolicySetDefinition or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( + def create( self, - policy_set_definition_name: str, + scope: str, + policy_assignment_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicySetDefinition: - """Creates or updates a policy set definition. - - This operation creates or updates a policy set definition in the given subscription with the - given name. + ) -> _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 policy_set_definition_name: The name of the policy set definition to create. Required. - :type policy_set_definition_name: str - :param parameters: The policy set definition properties. Required. + :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: PolicySetDefinition or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create_or_update( - self, policy_set_definition_name: str, parameters: Union[_models.PolicySetDefinition, IO[bytes]], **kwargs: Any - ) -> _models.PolicySetDefinition: - """Creates or updates a policy set definition. - - This operation creates or updates a policy set definition in the given subscription with the - given name. + def create( + self, + scope: str, + policy_assignment_name: str, + parameters: Union[_models.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 policy_set_definition_name: The name of the policy set definition to create. 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 IO[bytes] - :return: PolicySetDefinition or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :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 IO[bytes] + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4915,9 +2351,9 @@ def create_or_update( _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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -4925,11 +2361,11 @@ def create_or_update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "PolicySetDefinition") + _json = self._serialize.body(parameters, "PolicyAssignment") - _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_assignments_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, api_version=api_version, content_type=content_type, json=_json, @@ -4946,145 +2382,98 @@ def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicySetDefinition", pipeline_response.http_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) 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: - """Deletes a policy set definition. - - This operation deletes the policy set definition in the given subscription with the given name. + @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 policy_set_definition_name: The name of the policy set definition to delete. Required. - :type policy_set_definition_name: str - :return: None or the result of cls(response) - :rtype: None + :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 or the result of cls(response) + :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def get( - self, policy_set_definition_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> _models.PolicySetDefinition: - """Retrieves a policy set definition. - - This operation retrieves the policy set definition in the given subscription with the given - name. + @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 policy_set_definition_name: The name of the policy set definition to get. Required. - :type policy_set_definition_name: str - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :return: PolicySetDefinition or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :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 or the result of cls(response) + :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicySetDefinition", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore @distributed_trace - def get_built_in( - self, policy_set_definition_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> _models.PolicySetDefinition: - """Retrieves a built in policy set definition. - - This operation retrieves the built-in policy set definition with the given name. + def update( + self, + scope: str, + policy_assignment_name: str, + parameters: Union[_models.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 policy_set_definition_name: The name of the policy set definition to get. Required. - :type policy_set_definition_name: str - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :return: PolicySetDefinition or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :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 IO[bytes] + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5095,16 +2484,28 @@ def get_built_in( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _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", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) - _request = build_policy_set_definitions_get_built_in_request( - policy_set_definition_name=policy_set_definition_name, - expand=expand, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignmentUpdate") + + _request = build_policy_assignments_update_request( + scope=scope, + policy_assignment_name=policy_assignment_name, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -5119,58 +2520,33 @@ def get_built_in( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicySetDefinition", pipeline_response.http_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) # 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"]: - """Retrieves the policy set definitions for a subscription. - - 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 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. - :type filter: str - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinitionListResult] = kwargs.pop("cls", None) + 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 or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment or None + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5179,68 +2555,75 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_policy_set_definitions_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - expand=expand, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[Optional[_models.PolicyAssignment]] = kwargs.pop("cls", None) - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _request = build_policy_assignments_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + _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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) - 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_built_in( - self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.PolicySetDefinition"]: - """Retrieves built-in policy set definitions. + 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 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}. + 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 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. + :param management_group_id: The management group ID. Required. + :type management_group_id: str + :param 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. :type filter: str :param expand: Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is @@ -5249,15 +2632,15 @@ def list_built_in( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinitionListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyAssignmentListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5270,7 +2653,8 @@ 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_assignments_list_for_management_group_request( + management_group_id=management_group_id, filter=filter, expand=expand, top=top, @@ -5287,7 +2671,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -5304,164 +2688,60 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) - @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: - """Creates or updates a policy set definition. - - This operation creates or updates a policy set definition in the given management group with - the given name. - - :param 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 create. 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 or the result of cls(response) - :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: - """Creates or updates a policy set definition. - - This operation creates or updates a policy set definition in the given management group with - the given name. - - :param 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 create. 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 or the result of cls(response) - :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, IO[bytes]], - **kwargs: Any, - ) -> _models.PolicySetDefinition: - """Creates or updates a policy set definition. - - This operation creates or updates a policy set definition in the given management group with - the given name. - - :param 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 create. 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 IO[bytes] - :return: PolicySetDefinition or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PolicySetDefinition") - - _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, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicySetDefinition", pipeline_response.http_response) - - 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_set_definition_name: str, **kwargs: Any - ) -> None: - """Deletes a policy set definition. + 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 deletes the policy set definition in the given management group with the given - name. + 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}. - :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 delete. Required. - :type policy_set_definition_name: str - :return: None or the result of cls(response) - :rtype: None + :param 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. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyAssignmentListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5470,56 +2750,134 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + _request = build_policy_assignments_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + top=top, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - _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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - if cls: - return cls(pipeline_response, None, {}) # type: ignore + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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_set_definition_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> _models.PolicySetDefinition: - """Retrieves a policy set definition. + 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 policy set definition in the given management group with the given - name. + 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 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 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 + :param 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. + :type filter: str :param expand: Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is None. :type expand: str - :return: PolicySetDefinition or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyAssignmentListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5528,73 +2886,92 @@ def get_at_management_group( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) + _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=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - _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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("PolicySetDefinition", 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 = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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) @distributed_trace - def list_by_management_group( + def list_for_resource_group( self, - management_group_id: str, + resource_group_name: str, filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any, - ) -> ItemPaged["_models.PolicySetDefinition"]: - """Retrieves all policy set definitions in management group. - - 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}. + 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 management_group_id: The ID of the management group. Required. - :type management_group_id: str - :param 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. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param 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. :type filter: str :param expand: Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is @@ -5603,15 +2980,15 @@ def list_by_management_group( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinitionListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyAssignmentListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5624,8 +3001,9 @@ 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, + _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, @@ -5642,7 +3020,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -5659,41 +3037,33 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) - -class PolicySetDefinitionVersionsOperations: - """ - .. 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. - """ - - models = _models - - 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_all_builtins(self, **kwargs: Any) -> _models.PolicySetDefinitionVersionListResult: - """Lists all built-in policy set definition versions. + def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: + """Deletes a policy assignment. - This operation lists all the built-in policy set definition versions for all built-in policy - set definitions. + 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: PolicySetDefinitionVersionListResult or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersionListResult + :param policy_assignment_id: The ID of the policy assignment to delete. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :return: PolicyAssignment or None or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5707,10 +3077,11 @@ def list_all_builtins(self, **kwargs: Any) -> _models.PolicySetDefinitionVersion _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[Optional[_models.PolicyAssignment]] = kwargs.pop("cls", None) - _request = build_policy_set_definition_versions_list_all_builtins_request( + _request = build_policy_assignments_delete_by_id_request( + policy_assignment_id=policy_assignment_id, api_version=api_version, headers=_headers, params=_params, @@ -5724,31 +3095,113 @@ def list_all_builtins(self, **kwargs: Any) -> _models.PolicySetDefinitionVersion response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response.http_response) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) 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 create. 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 or the result of cls(response) + :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 create. 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 or the result of cls(response) + :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.PolicySetDefinitionVersionListResult: - """Lists all policy set definition versions at management group scope. + def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO[bytes]], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. - This operation lists all the policy set definition versions for all policy set definitions at - the management group scope. + 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 - :return: PolicySetDefinitionVersionListResult or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersionListResult + :param policy_assignment_id: The ID of the policy assignment to create. 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 IO[bytes] + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5759,15 +3212,27 @@ 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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicyAssignment] = 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" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") + + _request = build_policy_assignments_create_by_id_request( + policy_assignment_id=policy_assignment_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -5780,11 +3245,15 @@ def list_all_at_management_group( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response.http_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -5792,14 +3261,29 @@ 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 get_by_id( + self, policy_assignment_id: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.PolicyAssignment: + """Retrieves the policy assignment with the given ID. - This operation lists all the policy set definition versions for all policy set definitions - within a subscription. + 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}'. - :return: PolicySetDefinitionVersionListResult or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersionListResult + :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 expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5813,11 +3297,12 @@ def list_all(self, **kwargs: Any) -> _models.PolicySetDefinitionVersionListResul _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) - _request = build_policy_set_definition_versions_list_all_request( - subscription_id=self._config.subscription_id, + _request = build_policy_assignments_get_by_id_request( + policy_assignment_id=policy_assignment_id, + expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -5833,9 +3318,13 @@ def list_all(self, **kwargs: Any) -> _models.PolicySetDefinitionVersionListResul if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response.http_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -5843,91 +3332,95 @@ def list_all(self, **kwargs: Any) -> _models.PolicySetDefinitionVersionListResul return deserialized # type: ignore @overload - def create_or_update( + def update_by_id( self, - policy_set_definition_name: str, - policy_definition_version: str, - parameters: _models.PolicySetDefinitionVersion, + policy_assignment_id: str, + parameters: _models.PolicyAssignmentUpdate, *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicySetDefinitionVersion: - """Creates or updates a policy set definition version. + ) -> _models.PolicyAssignment: + """Updates a policy assignment. - This operation creates or updates a policy set definition version in the given subscription - with the given name and version. + 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_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 + :param policy_assignment_id: The ID of the policy assignment to update. 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: PolicySetDefinitionVersion or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload - 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: - """Creates or updates a policy set definition version. + 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 creates or updates a policy set definition version in the given subscription - with the given name and version. + 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_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. + :param policy_assignment_id: The ID of the policy assignment to update. 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: PolicySetDefinitionVersion or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create_or_update( - self, - policy_set_definition_name: str, - policy_definition_version: str, - parameters: Union[_models.PolicySetDefinitionVersion, IO[bytes]], - **kwargs: Any, - ) -> _models.PolicySetDefinitionVersion: - """Creates or updates a policy set definition version. + def update_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignmentUpdate, IO[bytes]], **kwargs: Any + ) -> _models.PolicyAssignment: + """Updates a policy assignment. - This operation creates or updates a policy set definition version in the given subscription - with the given name and version. + 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_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 IO[bytes] - :return: PolicySetDefinitionVersion or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion + :param policy_assignment_id: The ID of the policy assignment to update. 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 IO[bytes] + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5941,9 +3434,9 @@ def create_or_update( _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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -5951,12 +3444,10 @@ def create_or_update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "PolicySetDefinitionVersion") + _json = self._serialize.body(parameters, "PolicyAssignmentUpdate") - _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, + _request = build_policy_assignments_update_by_id_request( + policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, @@ -5973,34 +3464,50 @@ def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicySetDefinitionVersion", pipeline_response.http_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + +class PolicyDefinitionVersionsOperations: + """ + .. 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. + """ + + models = _models + + 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 delete( # pylint: disable=inconsistent-return-statements - self, policy_set_definition_name: str, policy_definition_version: str, **kwargs: Any - ) -> None: - """Deletes a policy set definition version. + def list_all_builtins(self, **kwargs: Any) -> _models.PolicyDefinitionVersionListResult: + """Lists all built-in policy definition versions. - This operation deletes the policy set definition version in the given subscription with the - given name and version. + This operation lists all the built-in policy definition versions for all built-in policy + definitions. - :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 or the result of cls(response) - :rtype: None + :return: PolicyDefinitionVersionListResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersionListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6014,58 +3521,130 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinitionVersionListResult] = kwargs.pop("cls", None) + + _request = build_policy_definition_versions_list_all_builtins_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PolicyDefinitionVersionListResult", pipeline_response.http_response) + + 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 + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicyDefinitionVersion or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinitionVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinitionVersionListResult] = 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=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyDefinitionVersionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - _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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + 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 - ) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - 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 = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + return pipeline_response - if cls: - return cls(pipeline_response, None, {}) # type: ignore + return ItemPaged(get_next, extract_data) @distributed_trace - def get( - self, - policy_set_definition_name: str, - policy_definition_version: str, - expand: Optional[str] = None, - **kwargs: Any, - ) -> _models.PolicySetDefinitionVersion: - """Retrieves a policy set definition version. - - This operation retrieves the policy set definition version in the given subscription with the - given name and version. + 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_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 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 expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :return: PolicySetDefinitionVersion or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion + :return: PolicyDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6079,14 +3658,12 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + 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_built_in_request( + policy_definition_name=policy_definition_name, policy_definition_version=policy_definition_version, - subscription_id=self._config.subscription_id, - expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -6102,9 +3679,13 @@ def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicySetDefinitionVersion", pipeline_response.http_response) + deserialized = self._deserialize("PolicyDefinitionVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -6112,30 +3693,19 @@ def get( return deserialized # type: ignore @distributed_trace - def get_built_in( - self, - policy_set_definition_name: str, - policy_definition_version: str, - expand: Optional[str] = None, - **kwargs: Any, - ) -> _models.PolicySetDefinitionVersion: - """Retrieves a built in policy set definition version. + def list_all_at_management_group( + self, management_group_name: str, **kwargs: Any + ) -> _models.PolicyDefinitionVersionListResult: + """Lists all policy definition versions at management group scope. - This operation retrieves the built-in policy set definition version with the given name and - version. + This operation lists all the policy definition versions for all policy definitions at the + management group scope. - :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 policy_definition_version: str - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :return: PolicySetDefinitionVersion or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion + :type management_group_name: str + :return: PolicyDefinitionVersionListResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersionListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6149,13 +3719,11 @@ def get_built_in( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + 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_at_management_group_request( + management_group_name=management_group_name, api_version=api_version, headers=_headers, params=_params, @@ -6171,9 +3739,13 @@ def get_built_in( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicySetDefinitionVersion", pipeline_response.http_response) + deserialized = self._deserialize("PolicyDefinitionVersionListResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -6181,35 +3753,31 @@ def get_built_in( return deserialized # 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"]: - """Retrieves the policy set definition versions for a given policy set definition in a - subscription. - - This operation retrieves a list of all the policy set definition versions for the given policy - set definition. + 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 policy_set_definition_name: The name of the policy set definition. Required. - :type policy_set_definition_name: str - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str + :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 top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :return: An iterator like instance of either PolicySetDefinitionVersion or the result of + :return: An iterator like instance of either PolicyDefinitionVersion or the result of cls(response) :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinitionVersionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -6222,10 +3790,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=api_version, headers=_headers, @@ -6240,7 +3807,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response) + deserialized = self._deserialize("PolicyDefinitionVersionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -6257,42 +3824,36 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) @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"]: - """Retrieves built-in policy set definition versions. - - This operation retrieves a list of all the built-in policy set definition versions for the - given built-in policy set definition. + 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 expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicySetDefinitionVersion or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] + :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 or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6301,81 +3862,74 @@ def list_built_in( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_policy_set_definition_versions_list_built_in_request( - policy_set_definition_name=policy_set_definition_name, - expand=expand, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinitionVersion] = kwargs.pop("cls", None) - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _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, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + _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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("PolicyDefinitionVersion", pipeline_response.http_response) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - return ItemPaged(get_next, extract_data) + return deserialized # type: ignore @overload def create_or_update_at_management_group( self, management_group_name: str, - policy_set_definition_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: - """Creates or updates a policy set definition version. - - This operation creates or updates a policy set definition version in the given management group - 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 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. + :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 version 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion + :return: PolicyDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @@ -6383,34 +3937,32 @@ def create_or_update_at_management_group( def create_or_update_at_management_group( self, management_group_name: 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.PolicySetDefinitionVersion: - """Creates or updates a policy set definition version. - - This operation creates or updates a policy set definition version in the given management group - 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 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. + :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 version 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion + :return: PolicyDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @@ -6418,30 +3970,28 @@ def create_or_update_at_management_group( def create_or_update_at_management_group( self, management_group_name: str, - policy_set_definition_name: str, + policy_definition_name: str, policy_definition_version: str, - parameters: Union[_models.PolicySetDefinitionVersion, IO[bytes]], + parameters: Union[_models.PolicyDefinitionVersion, IO[bytes]], **kwargs: Any, - ) -> _models.PolicySetDefinitionVersion: - """Creates or updates a policy set definition version. - - This operation creates or updates a policy set definition version in the given management group - 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 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. + :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 version properties. Is either a - PolicySetDefinitionVersion type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion or IO[bytes] - :return: PolicySetDefinitionVersion or the result of cls(response) - :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 IO[bytes] + :return: PolicyDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6455,9 +4005,9 @@ def create_or_update_at_management_group( _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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) 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" _json = None @@ -6465,11 +4015,11 @@ def create_or_update_at_management_group( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "PolicySetDefinitionVersion") + _json = self._serialize.body(parameters, "PolicyDefinitionVersion") - _request = build_policy_set_definition_versions_create_or_update_at_management_group_request( + _request = build_policy_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_name=policy_definition_name, policy_definition_version=policy_definition_version, api_version=api_version, content_type=content_type, @@ -6489,9 +4039,13 @@ def create_or_update_at_management_group( if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicySetDefinitionVersion", pipeline_response.http_response) + deserialized = self._deserialize("PolicyDefinitionVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -6500,20 +4054,17 @@ def create_or_update_at_management_group( @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 + self, management_group_name: str, policy_definition_name: str, policy_definition_version: str, **kwargs: Any ) -> None: - """Deletes a policy set definition version. - - This operation deletes the policy set definition version in the given management group with the - given name and version. + """This operation deletes the policy definition 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_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 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 or the result of cls(response) @@ -6531,12 +4082,12 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_policy_set_definition_versions_delete_at_management_group_request( + _request = build_policy_definition_versions_delete_at_management_group_request( management_group_name=management_group_name, - policy_set_definition_name=policy_set_definition_name, + policy_definition_name=policy_definition_name, policy_definition_version=policy_definition_version, api_version=api_version, headers=_headers, @@ -6553,215 +4104,24 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @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: - """Retrieves a policy set definition version. - - 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 - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :return: PolicySetDefinitionVersion or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicySetDefinitionVersion", pipeline_response.http_response) - - if cls: - 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"]: - """Retrieves all policy set definition versions for a given policy set definition in a management - group. - - 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 - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicySetDefinitionVersion or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicySetDefinitionVersionListResult] = 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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 + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, ) - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class PolicyAssignmentsOperations: - """ - .. 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. - """ - - models = _models + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - 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") + if cls: + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def delete(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: - """Deletes a policy assignment. + def list_all(self, **kwargs: Any) -> _models.PolicyDefinitionVersionListResult: + """Lists all policy definition versions within a subscription. - 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}'. + This operation lists all the policy definition versions for all policy definitions within a + subscription. - :param scope: The scope of the policy assignment. Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - Required. - :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. Required. - :type policy_assignment_name: str - :return: PolicyAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment or None + :return: PolicyDefinitionVersionListResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersionListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6775,12 +4135,11 @@ def delete(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> Opti _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[Optional[_models.PolicyAssignment]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinitionVersionListResult] = kwargs.pop("cls", None) - _request = build_policy_assignments_delete_request( - scope=scope, - policy_assignment_name=policy_assignment_name, + _request = build_policy_definition_versions_list_all_request( + subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, @@ -6794,119 +4153,45 @@ def delete(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> Opti response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) + deserialized = self._deserialize("PolicyDefinitionVersionListResult", pipeline_response.http_response) 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: - """Creates or updates a policy assignment. - - This operation creates or updates a policy assignment with the given scope and name. Policy - assignments apply to all resources contained within their scope. For example, when you assign a - policy at resource group scope, that policy applies to all resources in the group. - - :param scope: The scope of the policy assignment. Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - Required. - :type scope: str - :param policy_assignment_name: The name of the policy assignment. 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 or the result of cls(response) - :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: - """Creates or updates a policy assignment. - - This operation creates or updates a policy assignment with the given scope and name. Policy - assignments apply to all resources contained within their scope. For example, when you assign a - policy at resource group scope, that policy applies to all resources in the group. + @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 scope: The scope of the policy assignment. Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - Required. - :type scope: str - :param policy_assignment_name: The name of the policy assignment. 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :param policy_definition_name: The name of the policy definition. Required. + :type policy_definition_name: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicyDefinitionVersion or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinitionVersion] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @distributed_trace - def create( - self, - scope: str, - policy_assignment_name: str, - parameters: Union[_models.PolicyAssignment, IO[bytes]], - **kwargs: Any, - ) -> _models.PolicyAssignment: - """Creates or updates a policy assignment. - - This operation creates or updates a policy assignment with the given scope and name. Policy - assignments apply to all resources contained within their scope. For example, when you assign a - policy at resource group scope, that policy applies to all resources in the group. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinitionVersionListResult] = kwargs.pop("cls", None) - :param scope: The scope of the policy assignment. Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - Required. - :type scope: str - :param policy_assignment_name: The name of the policy assignment. 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 IO[bytes] - :return: PolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6915,75 +4200,68 @@ def create( } error_map.update(kwargs.pop("error_map", {}) or {}) - _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", "2023-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) + def prepare_request(next_link=None): + if not next_link: - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PolicyAssignment") + _request = build_policy_definition_versions_list_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - _request = build_policy_assignments_create_request( - scope=scope, - policy_assignment_name=policy_assignment_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyDefinitionVersionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("PolicyAssignment", 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 = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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) @distributed_trace def get( - self, scope: str, policy_assignment_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> _models.PolicyAssignment: - """Retrieves a policy assignment. - - This operation retrieves a single policy assignment, given its name and the scope it was - created at. + 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 scope: The scope of the policy assignment. Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :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 scope: str - :param policy_assignment_name: The name of the policy assignment to get. Required. - :type policy_assignment_name: str - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :return: PolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :type policy_definition_version: str + :return: PolicyDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6997,13 +4275,13 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinitionVersion] = kwargs.pop("cls", None) - _request = build_policy_assignments_get_request( - scope=scope, - policy_assignment_name=policy_assignment_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=api_version, headers=_headers, params=_params, @@ -7019,9 +4297,13 @@ def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) + deserialized = self._deserialize("PolicyDefinitionVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -7029,103 +4311,85 @@ def get( return deserialized # type: ignore @overload - def update( + def create_or_update( self, - scope: str, - policy_assignment_name: str, - parameters: _models.PolicyAssignmentUpdate, + policy_definition_name: str, + policy_definition_version: str, + parameters: _models.PolicyDefinitionVersion, *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicyAssignment: - """Updates a policy assignment. - - 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. + ) -> _models.PolicyDefinitionVersion: + """This operation creates or updates a policy definition in the given subscription with the given + name. - :param scope: The scope of the policy assignment. Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - Required. - :type scope: str - :param policy_assignment_name: The name of the policy assignment. Required. - :type policy_assignment_name: str - :param parameters: Parameters for policy assignment patch request. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyAssignmentUpdate + :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: PolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :return: PolicyDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( + def create_or_update( self, - scope: str, - policy_assignment_name: str, + policy_definition_name: str, + policy_definition_version: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.PolicyAssignment: - """Updates a policy assignment. - - 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. + ) -> _models.PolicyDefinitionVersion: + """This operation creates or updates a policy definition in the given subscription with the given + name. - :param scope: The scope of the policy assignment. Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :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 scope: str - :param policy_assignment_name: The name of the policy assignment. Required. - :type policy_assignment_name: str - :param parameters: Parameters for policy assignment patch request. 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: PolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :return: PolicyDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def update( + def create_or_update( self, - scope: str, - policy_assignment_name: str, - parameters: Union[_models.PolicyAssignmentUpdate, IO[bytes]], + policy_definition_name: str, + policy_definition_version: str, + parameters: Union[_models.PolicyDefinitionVersion, IO[bytes]], **kwargs: Any, - ) -> _models.PolicyAssignment: - """Updates a policy assignment. - - 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. + ) -> _models.PolicyDefinitionVersion: + """This operation creates or updates a policy definition in the given subscription with the given + name. - :param scope: The scope of the policy assignment. Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :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 scope: str - :param policy_assignment_name: The name of the policy assignment. 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 IO[bytes] - :return: PolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :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 IO[bytes] + :return: PolicyDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7139,9 +4403,9 @@ def update( _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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyDefinitionVersion] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -7149,11 +4413,12 @@ def update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "PolicyAssignmentUpdate") + _json = self._serialize.body(parameters, "PolicyDefinitionVersion") - _request = build_policy_assignments_update_request( - scope=scope, - policy_assignment_name=policy_assignment_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, api_version=api_version, content_type=content_type, json=_json, @@ -7170,11 +4435,15 @@ def update( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) + deserialized = self._deserialize("PolicyDefinitionVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -7182,190 +4451,22 @@ def update( 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"]: - """Retrieves all policy assignments that apply to a resource group. - - This operation retrieves the list of all policy assignments associated with the given resource - group in the given subscription that match the optional given $filter. Valid values for $filter - are: 'atScope()', '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 that contains policy assignments. - Required. - :type resource_group_name: str - :param 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. - :type filter: str - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicyAssignment or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyAssignmentListResult] = 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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link 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) - raise HttpResponseError(response=response, 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 containing the resource. 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 - :param 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. - :type filter: str - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicyAssignment or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] + 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 or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyAssignmentListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7374,103 +4475,71 @@ def list_for_resource( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _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=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + _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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if cls: + return cls(pipeline_response, None, {}) # type: ignore - return pipeline_response - return ItemPaged(get_next, extract_data) +class PolicySetDefinitionVersionsOperations: + """ + .. 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. + """ + + models = _models + + 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_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. + def list_all_builtins(self, **kwargs: Any) -> _models.PolicySetDefinitionVersionListResult: + """Lists all built-in policy set definition versions. - 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. + 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 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. - :type filter: str - :param expand: Comma-separated list of additional properties to be included in the response. - Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is - None. - :type expand: str - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :return: An iterator like instance of either PolicyAssignment or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] + :return: PolicySetDefinitionVersionListResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersionListResult :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyAssignmentListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7479,77 +4548,50 @@ def list_for_management_group( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_policy_assignments_list_for_management_group_request( - management_group_id=management_group_id, - filter=filter, - expand=expand, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _request = build_policy_set_definition_versions_list_all_builtins_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + _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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response.http_response) - 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( - 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}. + 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 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. - :type filter: str + :param policy_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str :param expand: Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is None. @@ -7557,15 +4599,17 @@ def list( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :return: An iterator like instance of either PolicyAssignment or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyAssignment] + :return: An iterator like instance of either PolicySetDefinitionVersion or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyAssignmentListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7578,9 +4622,8 @@ def list( def prepare_request(next_link=None): if not next_link: - _request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - filter=filter, + _request = build_policy_set_definition_versions_list_built_in_request( + policy_set_definition_name=policy_set_definition_name, expand=expand, top=top, api_version=api_version, @@ -7596,7 +4639,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -7613,29 +4656,39 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) @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). + 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_assignment_id: The ID of the policy assignment to delete. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. - :type policy_assignment_id: str - :return: PolicyAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment or None + :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 expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :return: PolicySetDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7649,11 +4702,13 @@ def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> Optional[_mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[Optional[_models.PolicyAssignment]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) - _request = build_policy_assignments_delete_by_id_request( - policy_assignment_id=policy_assignment_id, + _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=api_version, headers=_headers, params=_params, @@ -7667,109 +4722,35 @@ def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> Optional[_mo response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) + deserialized = self._deserialize("PolicySetDefinitionVersion", pipeline_response.http_response) 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 create. 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 or the result of cls(response) - :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 create. 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 or the result of cls(response) - :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, IO[bytes]], **kwargs: Any - ) -> _models.PolicyAssignment: - """Creates or updates a policy assignment. + 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 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}'. + This operation lists all the policy set definition versions for all policy set definitions at + the management group scope. - :param policy_assignment_id: The ID of the policy assignment to create. 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 IO[bytes] - :return: PolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :return: PolicySetDefinitionVersionListResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersionListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7780,27 +4761,15 @@ def create_by_id( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - 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" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PolicyAssignment") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) - _request = build_policy_assignments_create_by_id_request( - policy_assignment_id=policy_assignment_id, + _request = build_policy_set_definition_versions_list_all_at_management_group_request( + management_group_name=management_group_name, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -7813,11 +4782,15 @@ def create_by_id( response = pipeline_response.http_response - if response.status_code not in [201]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) + deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -7825,29 +4798,124 @@ def create_by_id( return deserialized # type: ignore @distributed_trace - def get_by_id( - self, policy_assignment_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> _models.PolicyAssignment: - """Retrieves the policy assignment with the given ID. + 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. - 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_set_definition_name: The name of the policy set definition. Required. + :type policy_set_definition_name: str + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicySetDefinitionVersion or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionVersionListResult] = 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=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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_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 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 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 expand: Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is None. :type expand: str - :return: PolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :return: PolicySetDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7861,11 +4929,13 @@ def get_by_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) - cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) - _request = build_policy_assignments_get_by_id_request( - policy_assignment_id=policy_assignment_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=api_version, headers=_headers, @@ -7882,9 +4952,13 @@ def get_by_id( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) + deserialized = self._deserialize("PolicySetDefinitionVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -7892,95 +4966,97 @@ def get_by_id( return deserialized # type: ignore @overload - def update_by_id( + def create_or_update_at_management_group( self, - policy_assignment_id: str, - parameters: _models.PolicyAssignmentUpdate, + management_group_name: str, + policy_set_definition_name: str, + policy_definition_version: str, + parameters: _models.PolicySetDefinitionVersion, *, 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}'. + ) -> _models.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given management group + with the given name and version. - :param policy_assignment_id: The ID of the policy assignment to update. 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 + :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: PolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :return: PolicySetDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :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}'. + 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 policy_assignment_id: The ID of the policy assignment to update. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. - :type policy_assignment_id: str - :param parameters: Parameters for policy assignment patch request. 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: PolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :return: PolicySetDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def update_by_id( - self, policy_assignment_id: str, parameters: Union[_models.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}'. + 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, 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 policy_assignment_id: The ID of the policy assignment to update. 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 IO[bytes] - :return: PolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyAssignment + :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 IO[bytes] + :return: PolicySetDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7994,9 +5070,9 @@ def update_by_id( _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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyAssignment] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -8004,10 +5080,12 @@ def update_by_id( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "PolicyAssignmentUpdate") + _json = self._serialize.body(parameters, "PolicySetDefinitionVersion") - _request = build_policy_assignments_update_by_id_request( - policy_assignment_id=policy_assignment_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, api_version=api_version, content_type=content_type, json=_json, @@ -8024,56 +5102,37 @@ def update_by_id( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyAssignment", pipeline_response.http_response) + deserialized = self._deserialize("PolicySetDefinitionVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class PolicyExemptionsOperations: - """ - .. 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. - """ - - models = _models - - 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 delete( # pylint: disable=inconsistent-return-statements - self, scope: str, policy_exemption_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 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 set definition version in the given management group with the + given name and version. - :param scope: The scope of the policy exemption. 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 scope: str - :param policy_exemption_name: The name of the policy exemption to delete. Required. - :type policy_exemption_name: str + :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 or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -8089,12 +5148,13 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) 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_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=api_version, headers=_headers, params=_params, @@ -8108,114 +5168,26 @@ def delete( # pylint: disable=inconsistent-return-statements 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # 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. - - 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. - - :param scope: The scope of the policy exemption. 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}'. - Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to delete. 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - 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. - - :param scope: The scope of the policy exemption. 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}'. - Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to delete. 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption - :raises ~azure.core.exceptions.HttpResponseError: - """ - + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + @distributed_trace - def create_or_update( - self, - scope: str, - policy_exemption_name: str, - parameters: Union[_models.PolicyExemption, 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. - - :param scope: The scope of the policy exemption. 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}'. - Required. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to delete. 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 IO[bytes] - :return: PolicyExemption or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption + 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 or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersionListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -8226,28 +5198,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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) - 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" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PolicyExemption") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionVersionListResult] = kwargs.pop("cls", None) - _request = build_policy_exemptions_create_or_update_request( - scope=scope, - policy_exemption_name=policy_exemption_name, + _request = build_policy_set_definition_versions_list_all_request( + subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -8260,11 +5219,15 @@ def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyExemption", pipeline_response.http_response) + deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -8272,23 +5235,112 @@ def create_or_update( return deserialized # type: ignore @distributed_trace - def get(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> _models.PolicyExemption: - """Retrieves a policy exemption. + 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 + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicySetDefinitionVersion or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionVersionListResult] = 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=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicySetDefinitionVersionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) - This operation retrieves a single policy exemption, given its name and the scope it was created - at. + @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. - :param scope: The scope of the policy exemption. 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_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 scope: str - :param policy_exemption_name: The name of the policy exemption to delete. Required. - :type policy_exemption_name: str - :return: PolicyExemption or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption + :type policy_definition_version: str + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :return: PolicySetDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -8302,12 +5354,14 @@ def get(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> _models. _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) - cls: ClsType[_models.PolicyExemption] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) - _request = build_policy_exemptions_get_request( - scope=scope, - policy_exemption_name=policy_exemption_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=api_version, headers=_headers, params=_params, @@ -8323,9 +5377,13 @@ def get(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> _models. if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyExemption", pipeline_response.http_response) + deserialized = self._deserialize("PolicySetDefinitionVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -8333,97 +5391,85 @@ def get(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> _models. return deserialized # type: ignore @overload - def update( + def create_or_update( self, - scope: str, - policy_exemption_name: str, - parameters: _models.PolicyExemptionUpdate, + policy_set_definition_name: str, + policy_definition_version: str, + parameters: _models.PolicySetDefinitionVersion, *, 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.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given subscription + with the given name and version. - :param scope: The scope of the policy exemption. 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_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 scope: str - :param policy_exemption_name: The name of the policy exemption to delete. Required. - :type policy_exemption_name: str - :param parameters: Parameters for policy exemption patch request. Required. - :type parameters: ~azure.mgmt.resource.policy.models.PolicyExemptionUpdate + :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: PolicyExemption or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption + :return: PolicySetDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( + def create_or_update( self, - scope: str, - policy_exemption_name: str, + policy_set_definition_name: str, + policy_definition_version: 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.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given subscription + with the given name and version. - :param scope: The scope of the policy exemption. 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_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 scope: str - :param policy_exemption_name: The name of the policy exemption to delete. Required. - :type policy_exemption_name: str - :param parameters: Parameters for policy exemption patch request. 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: PolicyExemption or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption + :return: PolicySetDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def update( + def create_or_update( self, - scope: str, - policy_exemption_name: str, - parameters: Union[_models.PolicyExemptionUpdate, IO[bytes]], + policy_set_definition_name: str, + policy_definition_version: str, + parameters: Union[_models.PolicySetDefinitionVersion, IO[bytes]], **kwargs: Any, - ) -> _models.PolicyExemption: - """Updates a policy exemption. - - This operation updates a policy exemption with the given scope and name. + ) -> _models.PolicySetDefinitionVersion: + """This operation creates or updates a policy set definition version in the given subscription + with the given name and version. - :param scope: The scope of the policy exemption. 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_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 scope: str - :param policy_exemption_name: The name of the policy exemption to delete. 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 IO[bytes] - :return: PolicyExemption or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.PolicyExemption + :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 IO[bytes] + :return: PolicySetDefinitionVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinitionVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -8437,9 +5483,9 @@ def update( _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", "2022-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PolicyExemption] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinitionVersion] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -8447,11 +5493,12 @@ def update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "PolicyExemptionUpdate") + _json = self._serialize.body(parameters, "PolicySetDefinitionVersion") - _request = build_policy_exemptions_update_request( - scope=scope, - policy_exemption_name=policy_exemption_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, api_version=api_version, content_type=content_type, json=_json, @@ -8468,11 +5515,15 @@ def update( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyExemption", pipeline_response.http_response) + deserialized = self._deserialize("PolicySetDefinitionVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -8480,39 +5531,22 @@ def update( return deserialized # type: ignore @distributed_trace - 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 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 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. - :type filter: str - :return: An iterator like instance of either PolicyExemption or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyExemption] + :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 or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) - cls: ClsType[_models.PolicyExemptionListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -8521,85 +5555,91 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> ItemPaged["_model } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_policy_exemptions_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _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=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + _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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if cls: + return cls(pipeline_response, None, {}) # type: ignore - return pipeline_response - return ItemPaged(get_next, extract_data) +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - @distributed_trace - 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. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.PolicyClient`'s + :attr:`policy_definitions` attribute. + """ - 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. + models = _models - :param resource_group_name: The name of the resource group containing the resource. Required. - :type resource_group_name: str - :param 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. + 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, 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 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. :type filter: str - :return: An iterator like instance of either PolicyExemption or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyExemption] + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) - cls: ClsType[_models.PolicyExemptionListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinitionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -8612,10 +5652,9 @@ def list_for_resource_group( 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, + _request = build_policy_definitions_list_built_in_request( filter=filter, + top=top, api_version=api_version, headers=_headers, params=_params, @@ -8629,7 +5668,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -8646,81 +5685,26 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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, - **kwargs: Any, - ) -> ItemPaged["_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'). + 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 resource_group_name: The name of the resource group containing the resource. 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 - :param 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. - :type filter: str - :return: An iterator like instance of either PolicyExemption or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyExemption] + :param policy_definition_name: The name of the built-in policy definition to get. Required. + :type policy_definition_name: str + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) - cls: ClsType[_models.PolicyExemptionListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -8729,89 +5713,81 @@ def list_for_resource( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _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=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinition] = kwargs.pop("cls", None) - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _request = build_policy_definitions_get_built_in_request( + policy_definition_name=policy_definition_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + _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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("PolicyDefinition", pipeline_response.http_response) - 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_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. + 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 - :param 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. + :param 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. :type filter: str - :return: An iterator like instance of either PolicyExemption or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyExemption] + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) - cls: ClsType[_models.PolicyExemptionListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinitionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -8824,9 +5800,10 @@ def list_for_management_group( def prepare_request(next_link=None): if not next_link: - _request = build_policy_exemptions_list_for_management_group_request( + _request = build_policy_definitions_list_by_management_group_request( management_group_id=management_group_id, filter=filter, + top=top, api_version=api_version, headers=_headers, params=_params, @@ -8840,7 +5817,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -8857,44 +5834,29 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) - -class VariablesOperations: - """ - .. 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. - """ - - models = _models - - 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 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 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 variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :return: None or the result of cls(response) - :rtype: None + :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 or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -8908,12 +5870,12 @@ def delete(self, variable_name: str, **kwargs: Any) -> None: # pylint: disable= _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinition] = kwargs.pop("cls", None) - _request = build_variables_delete_request( - variable_name=variable_name, - subscription_id=self._config.subscription_id, + _request = build_policy_definitions_get_at_management_group_request( + management_group_id=management_group_id, + policy_definition_name=policy_definition_name, api_version=api_version, headers=_headers, params=_params, @@ -8927,71 +5889,95 @@ def delete(self, variable_name: str, **kwargs: Any) -> None: # pylint: disable= response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PolicyDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore - @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. + return deserialized # type: ignore - 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. + @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 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 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: Variable or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.Variable + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :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. + 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 variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param parameters: Parameters for the variable. 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: Variable or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.Variable + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create_or_update( - self, variable_name: str, parameters: Union[_models.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. + def create_or_update_at_management_group( + self, + management_group_id: str, + policy_definition_name: str, + parameters: Union[_models.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 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. - Required. - :type parameters: ~azure.mgmt.resource.policy.models.Variable or IO[bytes] - :return: Variable or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.Variable + :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 IO[bytes] + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -9005,9 +5991,9 @@ def create_or_update( _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", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Variable] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -9015,11 +6001,11 @@ def create_or_update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "Variable") + _json = self._serialize.body(parameters, "PolicyDefinition") - _request = build_variables_create_or_update_request( - variable_name=variable_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, api_version=api_version, content_type=content_type, json=_json, @@ -9036,11 +6022,15 @@ def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Variable", pipeline_response.http_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -9048,16 +6038,17 @@ def create_or_update( return deserialized # type: ignore @distributed_trace - 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 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 variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :return: Variable or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.Variable + :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 or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -9071,12 +6062,12 @@ def get(self, variable_name: str, **kwargs: Any) -> _models.Variable: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.Variable] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_variables_get_request( - variable_name=variable_name, - subscription_id=self._config.subscription_id, + _request = build_policy_definitions_delete_at_management_group_request( + management_group_id=management_group_id, + policy_definition_name=policy_definition_name, api_version=api_version, headers=_headers, params=_params, @@ -9090,33 +6081,117 @@ def get(self, variable_name: str, **kwargs: Any) -> _models.Variable: response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Variable", pipeline_response.http_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, management_group_id: str, variable_name: str, **kwargs: Any - ) -> None: - """Deletes a variable. + 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}. - 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 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. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - :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 or the result of cls(response) - :rtype: None + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinitionListResult] = 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=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @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 or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -9130,12 +6205,12 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicyDefinition] = 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_definitions_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, @@ -9149,93 +6224,83 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PolicyDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @overload - def create_or_update_at_management_group( + def create_or_update( self, - management_group_id: str, - variable_name: str, - parameters: _models.Variable, + policy_definition_name: str, + parameters: _models.PolicyDefinition, *, 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. + ) -> _models.PolicyDefinition: + """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 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_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: Variable or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.Variable + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update_at_management_group( + def create_or_update( self, - management_group_id: str, - variable_name: str, + policy_definition_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 management group and name. Policy - variables can only be used by a policy definition at the scope they are created or below. + ) -> _models.PolicyDefinition: + """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 variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :param parameters: Parameters for the variable. 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: Variable or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.Variable + :return: PolicyDefinition or the result of cls(response) + :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, - variable_name: str, - parameters: Union[_models.Variable, IO[bytes]], - **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. + def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO[bytes]], **kwargs: Any + ) -> _models.PolicyDefinition: + """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 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. - Required. - :type parameters: ~azure.mgmt.resource.policy.models.Variable or IO[bytes] - :return: Variable or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.Variable + :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 IO[bytes] + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -9249,9 +6314,9 @@ def create_or_update_at_management_group( _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", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Variable] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -9259,11 +6324,11 @@ def create_or_update_at_management_group( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "Variable") + _json = self._serialize.body(parameters, "PolicyDefinition") - _request = build_variables_create_or_update_at_management_group_request( - management_group_id=management_group_id, - variable_name=variable_name, + _request = build_policy_definitions_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, @@ -9280,11 +6345,15 @@ 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 [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Variable", pipeline_response.http_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -9292,18 +6361,15 @@ def create_or_update_at_management_group( return deserialized # type: ignore @distributed_trace - 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. + 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 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.Variable + :param policy_definition_name: The name of the policy definition to get. Required. + :type policy_definition_name: str + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -9317,12 +6383,12 @@ def get_at_management_group(self, management_group_id: str, variable_name: str, _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.Variable] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_variables_get_at_management_group_request( - management_group_id=management_group_id, - variable_name=variable_name, + _request = build_policy_definitions_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, @@ -9336,32 +6402,70 @@ def get_at_management_group(self, management_group_id: str, variable_name: str, response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Variable", pipeline_response.http_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) 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, **kwargs: Any) -> ItemPaged["_models.Variable"]: - """Retrieves all variables that are at this subscription level. +class PolicySetDefinitionsOperations: + """ + .. 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. + """ + + models = _models - This operation retrieves the list of all variables associated with the given subscription. + 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, 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}. - :return: An iterator like instance of either Variable or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.Variable] + :param 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. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.VariableListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -9374,8 +6478,10 @@ def list(self, **kwargs: Any) -> ItemPaged["_models.Variable"]: def prepare_request(next_link=None): if not next_link: - _request = build_variables_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=api_version, headers=_headers, params=_params, @@ -9389,7 +6495,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("VariableListResult", pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -9406,29 +6512,125 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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, **kwargs: Any) -> ItemPaged["_models.Variable"]: - """Retrieves all variables that are at this management group level. + 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 + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :return: PolicySetDefinition or the result of cls(response) + :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + 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=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PolicySetDefinition", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore - This operation retrieves the list of all variables applicable to the management group. + @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 - :return: An iterator like instance of either Variable or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.Variable] + :param 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. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.VariableListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -9441,8 +6643,11 @@ 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( + _request = build_policy_set_definitions_list_by_management_group_request( management_group_id=management_group_id, + filter=filter, + expand=expand, + top=top, api_version=api_version, headers=_headers, params=_params, @@ -9456,7 +6661,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("VariableListResult", pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -9473,48 +6678,33 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) - -class VariableValuesOperations: - """ - .. 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. - """ - - models = _models - - 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 delete( # pylint: disable=inconsistent-return-statements - 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}'. + 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 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 or the result of cls(response) - :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 + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -9528,13 +6718,13 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinition] = 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_definitions_get_at_management_group_request( + management_group_id=management_group_id, + policy_set_definition_name=policy_set_definition_name, + expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -9548,93 +6738,95 @@ def delete( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PolicySetDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + 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_id: str, + policy_set_definition_name: str, + parameters: _models.PolicySetDefinition, *, 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.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: VariableValue or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :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_id: str, + policy_set_definition_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 subscription and name for a - given variable. Variable values are scoped to the variable for which they are created for. + ) -> _models.PolicySetDefinition: + """This operation creates or updates a policy set definition in the given management group with + the given name. - :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_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: VariableValue or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create_or_update( + def create_or_update_at_management_group( self, - variable_name: str, - variable_value_name: str, - parameters: Union[_models.VariableValue, IO[bytes]], + management_group_id: str, + policy_set_definition_name: str, + parameters: Union[_models.PolicySetDefinition, 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.PolicySetDefinition: + """This operation creates or updates a policy set definition in the given management group with + the given name. - :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 IO[bytes] - :return: VariableValue or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :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 IO[bytes] + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -9648,9 +6840,9 @@ def create_or_update( _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", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VariableValue] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -9658,12 +6850,11 @@ def create_or_update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "VariableValue") + _json = self._serialize.body(parameters, "PolicySetDefinition") - _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_definitions_create_or_update_at_management_group_request( + management_group_id=management_group_id, + policy_set_definition_name=policy_set_definition_name, api_version=api_version, content_type=content_type, json=_json, @@ -9682,9 +6873,13 @@ def create_or_update( if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("VariableValue", pipeline_response.http_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -9692,18 +6887,18 @@ def create_or_update( return deserialized # type: ignore @distributed_trace - 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + 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. + + :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 or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -9717,13 +6912,12 @@ def get(self, variable_name: str, variable_value_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.VariableValue] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[None] = 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_definitions_delete_at_management_group_request( + management_group_id=management_group_id, + policy_set_definition_name=policy_set_definition_name, api_version=api_version, headers=_headers, params=_params, @@ -9737,35 +6931,57 @@ def get(self, variable_name: str, variable_value_name: str, **kwargs: Any) -> _m response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VariableValue", pipeline_response.http_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - 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( + 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}. - :param variable_name: The name of the variable to operate on. Required. - :type variable_name: str - :return: An iterator like instance of either VariableValue or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.VariableValue] + :param 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. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.PolicySetDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.VariableValueListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + cls: ClsType[_models.PolicySetDefinitionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -9778,9 +6994,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, + _request = build_policy_set_definitions_list_request( subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + top=top, api_version=api_version, headers=_headers, params=_params, @@ -9794,7 +7012,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("VariableValueListResult", pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -9811,35 +7029,143 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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, 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. + 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_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 either VariableValue or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.VariableValue] + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :param expand: Comma-separated list of additional properties to be included in the response. + Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'. Default value is + None. + :type expand: str + :return: PolicySetDefinition or the result of cls(response) + :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.VariableValueListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + 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=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PolicySetDefinition", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + 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 or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + 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 or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, policy_set_definition_name: str, parameters: Union[_models.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 IO[bytes] + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -9848,64 +7174,63 @@ def list_for_management_group( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_variable_values_list_for_management_group_request( - management_group_id=management_group_id, - variable_name=variable_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicySetDefinition] = kwargs.pop("cls", None) - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") - def extract_data(pipeline_response): - deserialized = self._deserialize("VariableValueListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + _request = build_policy_set_definitions_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - 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 + ) - _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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response.http_response) - 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 delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, management_group_id: str, variable_name: str, variable_value_name: str, **kwargs: Any + def delete( # pylint: disable=inconsistent-return-statements + self, policy_set_definition_name: str, **kwargs: Any ) -> None: - """Deletes a variable value. - - 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 deletes the policy set 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 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 policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -9921,13 +7246,12 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) cls: ClsType[None] = 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_definitions_delete_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, @@ -9943,100 +7267,106 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) # type: ignore + +class PolicyTokensOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.PolicyClient`'s + :attr:`policy_tokens` attribute. + """ + + models = _models + + 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") + @overload - def create_or_update_at_management_group( + def acquire_at_management_group( self, - management_group_id: str, - variable_name: str, - variable_value_name: str, - parameters: _models.VariableValue, + management_group_name: str, + parameters: _models.PolicyTokenRequest, *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.VariableValue: - """Creates or updates a variable value. + ) -> _models.PolicyTokenResponse: + """Acquires a policy token at management group level. - 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 acquires a policy token in the given management group for the given request + body. - :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 + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param parameters: The policy token properties. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicyTokenRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: VariableValue or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :return: PolicyTokenResponse or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyTokenResponse :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update_at_management_group( + def acquire_at_management_group( self, - management_group_id: str, - variable_name: str, - variable_value_name: str, + management_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any, - ) -> _models.VariableValue: - """Creates or updates a variable value. + ) -> _models.PolicyTokenResponse: + """Acquires a policy token at management group level. - 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 acquires a policy token in the given management group for the given request + body. - :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. + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param parameters: The policy token 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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :return: PolicyTokenResponse or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyTokenResponse :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create_or_update_at_management_group( - self, - management_group_id: str, - variable_name: str, - variable_value_name: str, - parameters: Union[_models.VariableValue, IO[bytes]], - **kwargs: Any, - ) -> _models.VariableValue: - """Creates or updates a variable value. + def acquire_at_management_group( + self, management_group_name: str, parameters: Union[_models.PolicyTokenRequest, IO[bytes]], **kwargs: Any + ) -> _models.PolicyTokenResponse: + """Acquires a policy token at management group level. - 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 acquires a policy token in the given management group for the given request + body. - :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 + :param management_group_name: The name of the management group. The name is case insensitive. + Required. + :type management_group_name: str + :param parameters: The policy token properties. Is either a PolicyTokenRequest type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.resource.policy.models.VariableValue or IO[bytes] - :return: VariableValue or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :type parameters: ~azure.mgmt.resource.policy.models.PolicyTokenRequest or IO[bytes] + :return: PolicyTokenResponse or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyTokenResponse :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -10050,9 +7380,9 @@ def create_or_update_at_management_group( _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", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VariableValue] = kwargs.pop("cls", None) + cls: ClsType[_models.PolicyTokenResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -10060,12 +7390,10 @@ def create_or_update_at_management_group( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "VariableValue") + _json = self._serialize.body(parameters, "PolicyTokenRequest") - _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, + _request = build_policy_tokens_acquire_at_management_group_request( + management_group_name=management_group_name, api_version=api_version, content_type=content_type, json=_json, @@ -10082,34 +7410,158 @@ 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("VariableValue", pipeline_response.http_response) + deserialized = self._deserialize("PolicyTokenResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @overload + def acquire( + self, parameters: _models.PolicyTokenRequest, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyTokenResponse: + """Acquires a policy token. + + This operation acquires a policy token in the given subscription for the given request body. + + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicyTokenRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyTokenResponse or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyTokenResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def acquire( + self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyTokenResponse: + """Acquires a policy token. + + This operation acquires a policy token in the given subscription for the given request body. + + :param parameters: The request body. 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: PolicyTokenResponse or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyTokenResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - 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 acquire( + self, parameters: Union[_models.PolicyTokenRequest, IO[bytes]], **kwargs: Any + ) -> _models.PolicyTokenResponse: + """Acquires a policy token. - 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 acquires a policy token in the given subscription for the given request body. - :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 or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.models.VariableValue + :param parameters: The request body. Is either a PolicyTokenRequest type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.resource.policy.models.PolicyTokenRequest or IO[bytes] + :return: PolicyTokenResponse or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.PolicyTokenResponse + :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicyTokenResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyTokenRequest") + + _request = build_policy_tokens_acquire_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PolicyTokenResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class DataPolicyManifestsOperations: + """ + .. 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. + """ + + models = _models + + 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_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 or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.models.DataPolicyManifest :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -10123,13 +7575,11 @@ def get_at_management_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.VariableValue] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.DataPolicyManifest] = 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_data_policy_manifests_get_by_policy_mode_request( + policy_mode=policy_mode, api_version=api_version, headers=_headers, params=_params, @@ -10145,11 +7595,93 @@ def get_at_management_group( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("VariableValue", pipeline_response.http_response) + deserialized = self._deserialize("DataPolicyManifest", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + + @distributed_trace + 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. + + :param 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. + :type filter: str + :return: An iterator like instance of either DataPolicyManifest or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.models.DataPolicyManifest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.DataPolicyManifestListResult] = 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=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DataPolicyManifestListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link 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 = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_variable.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/acquire_policy_token.py similarity index 74% rename from sdk/resources/azure-mgmt-resource-policy/generated_samples/get_variable.py rename to sdk/resources/azure-mgmt-resource-policy/generated_samples/acquire_policy_token.py index a5c344300f51..0cbe983a73c6 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_variable.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/acquire_policy_token.py @@ -16,7 +16,7 @@ pip install azure-identity pip install azure-mgmt-resource-policy # USAGE - python get_variable.py + python acquire_policy_token.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,12 +31,17 @@ def main(): subscription_id="ae640e6b-ba3e-4256-9d62-2993eecfa6f2", ) - response = client.variables.get( - variable_name="DemoTestVariable", + response = client.policy_tokens.acquire( + parameters={ + "operation": { + "httpMethod": "delete", + "uri": "https://management.azure.com/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testRG/providers/Microsoft.Compute/virtualMachines/testVM?api-version=2024-01-01", + } + }, ) print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-08-01-preview/examples/getVariable.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/acquirePolicyToken.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/acquire_policy_token_at_management_group.py similarity index 69% rename from sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_variable_value_at_management_group.py rename to sdk/resources/azure-mgmt-resource-policy/generated_samples/acquire_policy_token_at_management_group.py index 2d97c14eea1f..b45f965e35ca 100644 --- 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/acquire_policy_token_at_management_group.py @@ -16,7 +16,7 @@ pip install azure-identity pip install azure-mgmt-resource-policy # USAGE - python create_or_update_variable_value_at_management_group.py + python acquire_policy_token_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, @@ -31,22 +31,18 @@ def main(): 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", + response = client.policy_tokens.acquire_at_management_group( + management_group_name="MyManagementGroup", parameters={ - "properties": { - "values": [ - {"columnName": "StringColumn", "columnValue": "SampleValue"}, - {"columnName": "IntegerColumn", "columnValue": 10}, - ] + "operation": { + "httpMethod": "delete", + "uri": "https://management.azure.com/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/roleAssignments/00000000-0000-0000-0000-000000000000?api-version=2022-04-01", } }, ) print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-08-01-preview/examples/createOrUpdateVariableValueAtManagementGroup.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 f65eaafdf6ac..34a0a7ff03c9 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 @@ -61,6 +61,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/createOrUpdatePolicyDefinition.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 f55fd0ac68c4..4dff90a28700 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: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/createOrUpdatePolicyDefinitionAdvancedParams.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 4f224ca49f83..8d348bb3b390 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 @@ -62,6 +62,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/createOrUpdatePolicyDefinitionAtManagementGroup.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 new file mode 100644 index 000000000000..d5be0ea62cab --- /dev/null +++ b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_definition_external_evaluation_enforcement_settings.py @@ -0,0 +1,67 @@ +# 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) AutoRest 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_definition_external_evaluation_enforcement_settings.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="ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + ) + + response = client.policy_definitions.create_or_update( + policy_definition_name="RandomizeVMAllocation", + parameters={ + "properties": { + "description": "Randomly disable VM allocation in eastus by having policy rule reference the outcome of invoking an external endpoint using the CoinFlip endpoint that returns random values.", + "displayName": "Randomize VM Allocation", + "externalEvaluationEnforcementSettings": { + "endpointSettings": {"details": {"successProbability": 0.5}, "kind": "CoinFlip"}, + "missingTokenAction": "audit", + "roleDefinitionIds": [ + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/roleDefinitions/f0cc2aea-b517-48f6-8f9e-0c01c687907b" + ], + }, + "metadata": {"category": "VM"}, + "mode": "Indexed", + "policyRule": { + "if": { + "allOf": [ + {"equals": "Microsoft.Compute/virtualMachines", "field": "type"}, + {"equals": "eastus", "field": "location"}, + {"equals": "false", "value": "[claims().isValid]"}, + ] + }, + "then": {"effect": "deny"}, + }, + } + }, + ) + print(response) + + +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 36cc0d983bd5..ab9a836e4fff 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 @@ -63,6 +63,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/createOrUpdatePolicyDefinitionVersion.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 80c3c9d59f06..e3d34ba6936c 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 @@ -64,6 +64,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/createOrUpdatePolicyDefinitionVersionAtManagementGroup.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/createOrUpdatePolicyDefinitionVersionAtManagementGroup.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 bbb5324203b5..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) AutoRest 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: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-07-01-preview/examples/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 b2c3fe5d6ce6..d8d931bdf0bc 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: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/createOrUpdatePolicySetDefinition.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 c4c885842014..80eba3948822 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 @@ -57,6 +57,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/createOrUpdatePolicySetDefinitionAtManagementGroup.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 031cbf732061..5ebcb16ec036 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: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/createOrUpdatePolicySetDefinitionVersion.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 2e03544efa6e..166dd7468e13 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 @@ -59,6 +59,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/createOrUpdatePolicySetDefinitionVersionAtManagementGroup.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 7cb82d92e353..e47aa302a977 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: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/createOrUpdatePolicySetDefinitionWithGroups.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 de0a96816915..f50a023a01ca 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: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/createOrUpdatePolicySetDefinitionWithGroupsAtManagementGroup.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 89cbf2505824..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_variable.py +++ /dev/null @@ -1,43 +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) AutoRest 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="ae640e6b-ba3e-4256-9d62-2993eecfa6f2", - ) - - response = client.variables.create_or_update( - variable_name="DemoTestVariable", - parameters={"properties": {"columns": [{"columnName": "TestColumn"}]}}, - ) - print(response) - - -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-08-01-preview/examples/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 a075f0dbc3b5..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_variable_at_management_group.py +++ /dev/null @@ -1,44 +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) AutoRest 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: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-08-01-preview/examples/createOrUpdateVariableAtManagementGroup.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/create_or_update_variable_value.py deleted file mode 100644 index 825d5a80e2ad..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_variable_value.py +++ /dev/null @@ -1,51 +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) AutoRest 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.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="ae640e6b-ba3e-4256-9d62-2993eecfa6f2", - ) - - response = client.variable_values.create_or_update( - variable_name="DemoTestVariable", - variable_value_name="TestValue", - parameters={ - "properties": { - "values": [ - {"columnName": "StringColumn", "columnValue": "SampleValue"}, - {"columnName": "IntegerColumn", "columnValue": 10}, - ] - } - }, - ) - print(response) - - -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-08-01-preview/examples/createOrUpdateVariableValue.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 aa0bc1951369..abe8ad46e8cf 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: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/createPolicyAssignment.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/createPolicyAssignment.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_by_id.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_by_id.py deleted file mode 100644 index 94e796f90136..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_by_id.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) AutoRest 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_policy_assignment_by_id.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_assignments.create_by_id( - policy_assignment_id="providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", - parameters={ - "properties": { - "definitionVersion": "1.*.*", - "description": "Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created", - "displayName": "Enforce storage account SKU", - "enforcementMode": "Default", - "metadata": {"assignedBy": "Cheapskate Boss"}, - "parameters": {"listOfAllowedSKUs": {"value": ["Standard_GRS", "Standard_LRS"]}}, - "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", - } - }, - ) - print(response) - - -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/createPolicyAssignmentById.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 a359570f354f..593d90d73817 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: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/createPolicyAssignmentNonComplianceMessages.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/createPolicyAssignmentNonComplianceMessages.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_policy_assignment_with_enroll_enforcement.py similarity index 68% rename from sdk/resources/azure-mgmt-resource-policy/generated_samples/create_or_update_policy_exemption.py rename to sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_enroll_enforcement.py index d866ff95c75a..c9d374a68788 100644 --- 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_policy_assignment_with_enroll_enforcement.py @@ -16,7 +16,7 @@ pip install azure-identity pip install azure-mgmt-resource-policy # USAGE - python create_or_update_policy_exemption.py + python create_policy_assignment_with_enroll_enforcement.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,23 +31,23 @@ def main(): subscription_id="SUBSCRIPTION_ID", ) - response = client.policy_exemptions.create_or_update( - scope="subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", - policy_exemption_name="DemoExpensiveVM", + response = client.policy_assignments.create( + scope="subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", + policy_assignment_name="EnforceNamingEnroll", 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"], + "description": "Force resource names to begin with given DeptA and end with -LC", + "displayName": "Enforce resource naming rules", + "enforcementMode": "Enroll", + "metadata": {"assignedBy": "Special Someone"}, + "parameters": {"prefix": {"value": "DeptA"}, "suffix": {"value": "-LC"}}, + "policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", } }, ) print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-07-01-preview/examples/createOrUpdatePolicyExemption.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 a76ddf832052..d17423158ada 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: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/createPolicyAssignmentWithIdentity.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/createPolicyAssignmentWithIdentity.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_identity_by_id.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_identity_by_id.py deleted file mode 100644 index 1909f06ca22a..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/create_policy_assignment_with_identity_by_id.py +++ /dev/null @@ -1,55 +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) AutoRest 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_policy_assignment_with_identity_by_id.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_assignments.create_by_id( - policy_assignment_id="providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", - parameters={ - "identity": {"type": "SystemAssigned"}, - "location": "eastus", - "properties": { - "definitionVersion": "1.*.*", - "description": "Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created", - "displayName": "Enforce storage account SKU", - "enforcementMode": "Default", - "metadata": {"assignedBy": "Cheapskate Boss"}, - "parameters": {"listOfAllowedSKUs": {"value": ["Standard_GRS", "Standard_LRS"]}}, - "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", - }, - }, - ) - print(response) - - -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/createPolicyAssignmentWithIdentityById.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 8624ed97d9c0..a9036e274f1a 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 @@ -36,6 +36,7 @@ def main(): policy_assignment_name="CostManagement", parameters={ "properties": { + "definitionVersion": "1.*.*", "description": "Limit the resource location and resource SKU", "displayName": "Limit the resource location and resource SKU", "metadata": {"assignedBy": "Special Someone"}, @@ -44,7 +45,12 @@ def main(): "kind": "policyEffect", "selectors": [{"in": ["Limit_Skus", "Limit_Locations"], "kind": "policyDefinitionReferenceId"}], "value": "Audit", - } + }, + { + "kind": "definitionVersion", + "selectors": [{"in": ["eastUSEuap", "centralUSEuap"], "kind": "resourceLocation"}], + "value": "2.*.*", + }, ], "policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement", } @@ -53,6 +59,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/createPolicyAssignmentWithOverrides.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/createPolicyAssignmentWithOverrides.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 bf192cdef215..fb55a7b5ef57 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: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/createPolicyAssignmentWithResourceSelectors.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/createPolicyAssignmentWithResourceSelectors.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 6a61c49b9bdd..f647ef9b7e80 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: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/createPolicyAssignmentWithUserAssignedIdentity.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 832f7c603611..5f72e5e498cb 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: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/createPolicyAssignmentWithoutEnforcement.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 c748e634c9d3..a3dd385bf7f1 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 @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/deletePolicyAssignment.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/deletePolicyAssignment.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_assignment_by_id.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_assignment_by_id.py deleted file mode 100644 index f0d7b17c75f3..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_assignment_by_id.py +++ /dev/null @@ -1,42 +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) AutoRest 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_assignment_by_id.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_assignments.delete_by_id( - policy_assignment_id="providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", - ) - print(response) - - -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/deletePolicyAssignmentById.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 b2cecb119bf3..b8a956b9e6f7 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 @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/deletePolicyDefinition.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 aa2e5e3137b9..6adbc2ab0dc2 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 @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/deletePolicyDefinitionAtManagementGroup.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 0e2c938ec759..0dfabf2d5c05 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 @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/deletePolicyDefinitionVersion.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 16268fe9a212..b98c9cc84102 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 @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/deletePolicyDefinitionVersionAtManagementGroup.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/deletePolicyDefinitionVersionAtManagementGroup.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 6d232dfe8c25..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_policy_exemption.py +++ /dev/null @@ -1,42 +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) AutoRest 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: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-07-01-preview/examples/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 3c96c8c9e3a6..f55101eb91c9 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 @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/deletePolicySetDefinition.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 6b1e72fb0f5c..c5afd4571dd0 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 @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/deletePolicySetDefinitionAtManagementGroup.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 51bf0707e2c7..51ea8e7b39c5 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 @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/deletePolicySetDefinitionVersion.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 d6cfec176671..6235cb11594e 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 @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/deletePolicySetDefinitionVersionAtManagementGroup.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 0cd87280bc4d..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_variable.py +++ /dev/null @@ -1,41 +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) AutoRest 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="ae640e6b-ba3e-4256-9d62-2993eecfa6f2", - ) - - client.variables.delete( - variable_name="DemoTestVariable", - ) - - -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-08-01-preview/examples/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 5a7459323877..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_variable_at_management_group.py +++ /dev/null @@ -1,42 +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) AutoRest 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: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-08-01-preview/examples/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 bcf9ecab1c46..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_variable_value.py +++ /dev/null @@ -1,42 +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) AutoRest 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="ae640e6b-ba3e-4256-9d62-2993eecfa6f2", - ) - - client.variable_values.delete( - variable_name="DemoTestVariable", - variable_value_name="TestValue", - ) - - -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-08-01-preview/examples/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 1bfaf14fdce7..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/delete_variable_value_at_management_group.py +++ /dev/null @@ -1,43 +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) AutoRest 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: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-08-01-preview/examples/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 95af387b1ee5..d564ccf3db39 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 @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/getBuiltInPolicySetDefinition.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 5c7b4fe5f760..6eeb2bdf8f31 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 @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/getBuiltInPolicySetDefinitionVersion.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 438e7e01b788..9da98adbab67 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 @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/getBuiltinPolicyDefinition.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 a384f86096eb..043e8583c4d2 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 @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/getBuiltinPolicyDefinitionVersion.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/getBuiltinPolicyDefinitionVersion.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 190c5389fc5b..1fd75d5c9819 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 @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/getPolicyAssignment.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/getPolicyAssignment.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_by_id.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_by_id.py deleted file mode 100644 index 5f00fa2e9f29..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_by_id.py +++ /dev/null @@ -1,42 +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) AutoRest 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_assignment_by_id.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_assignments.get_by_id( - policy_assignment_id="providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", - ) - print(response) - - -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/getPolicyAssignmentById.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 2bdaa63dd312..43d983007e15 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 @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/getPolicyAssignmentWithIdentity.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/getPolicyAssignmentWithIdentity.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_with_identity_by_id.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_with_identity_by_id.py deleted file mode 100644 index 0ffcba7ede4e..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_assignment_with_identity_by_id.py +++ /dev/null @@ -1,42 +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) AutoRest 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_assignment_with_identity_by_id.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_assignments.get_by_id( - policy_assignment_id="providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", - ) - print(response) - - -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/getPolicyAssignmentWithIdentityById.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 b24ae0f2bebc..a1d835d81590 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 @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/getPolicyAssignmentWithOverrides.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/getPolicyAssignmentWithOverrides.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 434e44b7f811..036a342c3287 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 @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/getPolicyAssignmentWithResourceSelectors.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 070db7d59fc7..8faa55b3c7c6 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 @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 dd5ea749063f..2dbcdf948764 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 @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/getPolicyDefinition.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 ab5a9b98371c..acfc6e0e9112 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 @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/getPolicyDefinitionAtManagementGroup.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 9863b1360530..c6a265246986 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 @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/getPolicyDefinitionVersion.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 e7f872f16e23..744af3fd68e6 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 @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/getPolicyDefinitionVersionAtManagementGroup.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/getPolicyDefinitionVersionAtManagementGroup.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_exemption.py deleted file mode 100644 index d9eae16f8384..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_exemption.py +++ /dev/null @@ -1,43 +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) AutoRest 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.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: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-07-01-preview/examples/getPolicyExemption.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 7d75b672778b..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_policy_exemption_with_resource_selectors.py +++ /dev/null @@ -1,43 +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) AutoRest 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: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-07-01-preview/examples/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 a7446c1726ca..1387b9c81cc0 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 @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/getPolicySetDefinition.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 54d50c033243..ce3d2ec8a076 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 @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/getPolicySetDefinitionAtManagementGroup.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 4446c6afc50a..22052b93947c 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 @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/getPolicySetDefinitionVersion.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 0360da53741c..6513004003c2 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 @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/getPolicySetDefinitionVersionAtManagementGroup.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/getPolicySetDefinitionVersionAtManagementGroup.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 fb8ba6ad8112..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_variable_at_management_group.py +++ /dev/null @@ -1,43 +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) AutoRest 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: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-08-01-preview/examples/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 8717e590786e..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_variable_value.py +++ /dev/null @@ -1,43 +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) AutoRest 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="ae640e6b-ba3e-4256-9d62-2993eecfa6f2", - ) - - response = client.variable_values.get( - variable_name="DemoTestVariable", - variable_value_name="TestValue", - ) - print(response) - - -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-08-01-preview/examples/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 3e3ebaad39f0..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/get_variable_value_at_management_group.py +++ /dev/null @@ -1,44 +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) AutoRest 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: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-08-01-preview/examples/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 c2cc14995a1d..96cf511a5479 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 @@ -35,6 +35,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/listAllBuiltInPolicyDefinitionVersions.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 570ea95e8229..cf57dc7251fb 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 @@ -35,6 +35,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/listAllBuiltInPolicySetDefinitionVersions.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 753966d70c72..c2a6b9fdf278 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 @@ -35,6 +35,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/listAllPolicyDefinitionVersions.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 f0c37614e70a..840018c14e6b 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 @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/listAllPolicyDefinitionVersionsByManagementGroup.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 a7dcddd6e26d..3bbd572a8926 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 @@ -35,6 +35,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/listAllPolicySetDefinitionVersions.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 2a7dd0b58a56..84b305e7eb57 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 @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/listAllPolicySetDefinitionVersionsByManagementGroup.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 dec4b4ba6314..8d468534115f 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 @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/listBuiltInPolicyDefinitionVersions.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 382439ab8e77..16a8af888167 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 @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/listBuiltInPolicyDefinitions.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 b6b3e257e496..39c39d549ae4 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 @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/listBuiltInPolicySetDefinitionVersions.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 039c1d302864..34cb08b5a9bb 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 @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/listBuiltInPolicySetDefinitions.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/listBuiltInPolicySetDefinitions.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 bb41649763fd..35e37787f129 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 @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/listPolicyAssignments.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 905dbd340aa4..15aedd7fc351 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 @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/listPolicyAssignmentsForManagementGroup.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 d466fd6f688c..fb9e51455d01 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 @@ -42,6 +42,6 @@ def main(): print(item) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/listPolicyAssignmentsForResource.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 0ba2def195ac..e10dc6571069 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 @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/listPolicyAssignmentsForResourceGroup.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 1516a56dfd53..b3daaa78c544 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 @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/listPolicyDefinitionVersions.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 ed6f7b4025e5..a7dc5e52399e 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 @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/listPolicyDefinitionVersionsByManagementGroup.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 998a00be3403..9e30a89028db 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 @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/listPolicyDefinitions.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 e7575f9876b1..1d120a302a05 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 @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/listPolicyDefinitionsByManagementGroup.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/listPolicyDefinitionsByManagementGroup.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 873b7eed1370..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_exemptions_for_management_group.py +++ /dev/null @@ -1,43 +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) AutoRest 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: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-07-01-preview/examples/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 8315c35c4114..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_exemptions_for_resource.py +++ /dev/null @@ -1,47 +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) AutoRest 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="ae640e6b-ba3e-4256-9d62-2993eecfa6f2", - ) - - 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: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-07-01-preview/examples/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 787aea63be6d..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_exemptions_for_resource_group.py +++ /dev/null @@ -1,43 +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) AutoRest 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="ae640e6b-ba3e-4256-9d62-2993eecfa6f2", - ) - - response = client.policy_exemptions.list_for_resource_group( - resource_group_name="TestResourceGroup", - ) - for item in response: - print(item) - - -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-07-01-preview/examples/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 1cf11b5e582c..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_policy_exemptions_for_subscription.py +++ /dev/null @@ -1,41 +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) AutoRest 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="ae640e6b-ba3e-4256-9d62-2993eecfa6f2", - ) - - response = client.policy_exemptions.list() - for item in response: - print(item) - - -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-07-01-preview/examples/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 7741de50dc73..194e1ecdbc21 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 @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/listPolicySetDefinitionVersions.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 21269baede20..f4ca33f70f44 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 @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/listPolicySetDefinitionVersionsByManagementGroup.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 708600c70528..8cd565622255 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 @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/listPolicySetDefinitions.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 b7160f81cb8d..328a70ecd999 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 @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/listPolicySetDefinitionsByManagementGroup.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/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 00f9d01c0e9c..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_variable_values_for_management_group.py +++ /dev/null @@ -1,44 +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) AutoRest 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: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-08-01-preview/examples/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 b6cbe7624322..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_variable_values_for_subscription.py +++ /dev/null @@ -1,43 +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) AutoRest 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="ae640e6b-ba3e-4256-9d62-2993eecfa6f2", - ) - - response = client.variable_values.list( - variable_name="DemoTestVariable", - ) - for item in response: - print(item) - - -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-08-01-preview/examples/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 e57dbb4f5283..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_variables_for_management_group.py +++ /dev/null @@ -1,43 +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) AutoRest 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: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-08-01-preview/examples/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 ef937a8c21ee..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/list_variables_for_subscription.py +++ /dev/null @@ -1,41 +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) AutoRest 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="ae640e6b-ba3e-4256-9d62-2993eecfa6f2", - ) - - response = client.variables.list() - for item in response: - print(item) - - -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-08-01-preview/examples/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 976fddd0b378..825d16ddf1d0 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 @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/updatePolicyAssignmentWithIdentity.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/updatePolicyAssignmentWithIdentity.json if __name__ == "__main__": main() diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_identity_by_id.py b/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_identity_by_id.py deleted file mode 100644 index e2a6827f7227..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_assignment_with_identity_by_id.py +++ /dev/null @@ -1,43 +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) AutoRest 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_assignment_with_identity_by_id.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_assignments.update_by_id( - policy_assignment_id="providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", - parameters={"identity": {"type": "SystemAssigned"}, "location": "eastus"}, - ) - print(response) - - -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/updatePolicyAssignmentWithIdentityById.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 5d194a7b03f6..000150829466 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 @@ -49,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/updatePolicyAssignmentWithOverrides.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/updatePolicyAssignmentWithOverrides.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 2cbbbb2310ce..ae60d007bbba 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 @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/updatePolicyAssignmentWithResourceSelectors.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/updatePolicyAssignmentWithResourceSelectors.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 05ce73c9e30f..dfe43266f7d5 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: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2023-04-01/examples/updatePolicyAssignmentWithUserAssignedIdentity.json +# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/examples/updatePolicyAssignmentWithUserAssignedIdentity.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 88445a05426f..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/generated_samples/update_policy_exemption_with_resource_selectors.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) AutoRest 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: specification/resources/resource-manager/Microsoft.Authorization/policy/preview/2022-07-01-preview/examples/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 57b128e19c3b..b8f60411c714 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 @@ -20,11 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_assignments_delete(self, resource_group): - response = self.client.policy_assignments.delete( + def test_policy_assignments_get(self, resource_group): + response = self.client.policy_assignments.get( scope="str", policy_assignment_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -37,6 +37,7 @@ def test_policy_assignments_create(self, resource_group): scope="str", policy_assignment_name="str", parameters={ + "assignmentType": "str", "definitionVersion": "str", "description": "str", "displayName": "str", @@ -49,6 +50,7 @@ def test_policy_assignments_create(self, resource_group): "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, + "instanceId": "str", "latestDefinitionVersion": "str", "location": "str", "metadata": {}, @@ -72,19 +74,7 @@ def test_policy_assignments_create(self, resource_group): }, "type": "str", }, - api_version="2023-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_assignments_get(self, resource_group): - response = self.client.policy_assignments.get( - scope="str", - policy_assignment_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -109,7 +99,7 @@ def test_policy_assignments_update(self, resource_group): ], "resourceSelectors": [{"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}]}], }, - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -117,10 +107,22 @@ def test_policy_assignments_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_assignments_list_for_resource_group(self, resource_group): - response = self.client.policy_assignments.list_for_resource_group( - resource_group_name=resource_group.name, - api_version="2023-04-01", + def test_policy_assignments_delete(self, resource_group): + response = self.client.policy_assignments.delete( + scope="str", + policy_assignment_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_assignments_list_for_management_group(self, resource_group): + response = self.client.policy_assignments.list_for_management_group( + management_group_id="str", + api_version="2025-03-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -128,14 +130,9 @@ def test_policy_assignments_list_for_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_assignments_list_for_resource(self, resource_group): - response = self.client.policy_assignments.list_for_resource( - resource_group_name=resource_group.name, - resource_provider_namespace="str", - parent_resource_path="str", - resource_type="str", - resource_name="str", - api_version="2023-04-01", + def test_policy_assignments_list(self, resource_group): + response = self.client.policy_assignments.list( + api_version="2025-03-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -143,10 +140,14 @@ def test_policy_assignments_list_for_resource(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_assignments_list_for_management_group(self, resource_group): - response = self.client.policy_assignments.list_for_management_group( - management_group_id="str", - api_version="2023-04-01", + def test_policy_assignments_list_for_resource(self, resource_group): + response = self.client.policy_assignments.list_for_resource( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + parent_resource_path="str", + resource_type="str", + resource_name="str", + api_version="2025-03-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -154,9 +155,10 @@ def test_policy_assignments_list_for_management_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_assignments_list(self, resource_group): - response = self.client.policy_assignments.list( - api_version="2023-04-01", + def test_policy_assignments_list_for_resource_group(self, resource_group): + response = self.client.policy_assignments.list_for_resource_group( + resource_group_name=resource_group.name, + api_version="2025-03-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -167,7 +169,7 @@ def test_policy_assignments_list(self, resource_group): def test_policy_assignments_delete_by_id(self, resource_group): response = self.client.policy_assignments.delete_by_id( policy_assignment_id="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -179,6 +181,7 @@ def test_policy_assignments_create_by_id(self, resource_group): response = self.client.policy_assignments.create_by_id( policy_assignment_id="str", parameters={ + "assignmentType": "str", "definitionVersion": "str", "description": "str", "displayName": "str", @@ -191,6 +194,7 @@ def test_policy_assignments_create_by_id(self, resource_group): "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, + "instanceId": "str", "latestDefinitionVersion": "str", "location": "str", "metadata": {}, @@ -214,7 +218,7 @@ def test_policy_assignments_create_by_id(self, resource_group): }, "type": "str", }, - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -225,7 +229,7 @@ def test_policy_assignments_create_by_id(self, resource_group): def test_policy_assignments_get_by_id(self, resource_group): response = self.client.policy_assignments.get_by_id( policy_assignment_id="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -249,7 +253,7 @@ def test_policy_assignments_update_by_id(self, resource_group): ], "resourceSelectors": [{"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}]}], }, - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself 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 4dc457727160..17dfe859fdf9 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 @@ -21,11 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_assignments_delete(self, resource_group): - response = await self.client.policy_assignments.delete( + async def test_policy_assignments_get(self, resource_group): + response = await self.client.policy_assignments.get( scope="str", policy_assignment_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -38,6 +38,7 @@ async def test_policy_assignments_create(self, resource_group): scope="str", policy_assignment_name="str", parameters={ + "assignmentType": "str", "definitionVersion": "str", "description": "str", "displayName": "str", @@ -50,6 +51,7 @@ async def test_policy_assignments_create(self, resource_group): "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, + "instanceId": "str", "latestDefinitionVersion": "str", "location": "str", "metadata": {}, @@ -73,19 +75,7 @@ async def test_policy_assignments_create(self, resource_group): }, "type": "str", }, - api_version="2023-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_assignments_get(self, resource_group): - response = await self.client.policy_assignments.get( - scope="str", - policy_assignment_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -110,7 +100,7 @@ async def test_policy_assignments_update(self, resource_group): ], "resourceSelectors": [{"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}]}], }, - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -118,10 +108,22 @@ async def test_policy_assignments_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_assignments_list_for_resource_group(self, resource_group): - response = self.client.policy_assignments.list_for_resource_group( - resource_group_name=resource_group.name, - api_version="2023-04-01", + async def test_policy_assignments_delete(self, resource_group): + response = await self.client.policy_assignments.delete( + scope="str", + policy_assignment_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_assignments_list_for_management_group(self, resource_group): + response = self.client.policy_assignments.list_for_management_group( + management_group_id="str", + api_version="2025-03-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -129,14 +131,9 @@ async def test_policy_assignments_list_for_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_assignments_list_for_resource(self, resource_group): - response = self.client.policy_assignments.list_for_resource( - resource_group_name=resource_group.name, - resource_provider_namespace="str", - parent_resource_path="str", - resource_type="str", - resource_name="str", - api_version="2023-04-01", + async def test_policy_assignments_list(self, resource_group): + response = self.client.policy_assignments.list( + api_version="2025-03-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -144,10 +141,14 @@ async def test_policy_assignments_list_for_resource(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_assignments_list_for_management_group(self, resource_group): - response = self.client.policy_assignments.list_for_management_group( - management_group_id="str", - api_version="2023-04-01", + async def test_policy_assignments_list_for_resource(self, resource_group): + response = self.client.policy_assignments.list_for_resource( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + parent_resource_path="str", + resource_type="str", + resource_name="str", + api_version="2025-03-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -155,9 +156,10 @@ async def test_policy_assignments_list_for_management_group(self, resource_group @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_assignments_list(self, resource_group): - response = self.client.policy_assignments.list( - api_version="2023-04-01", + async def test_policy_assignments_list_for_resource_group(self, resource_group): + response = self.client.policy_assignments.list_for_resource_group( + resource_group_name=resource_group.name, + api_version="2025-03-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -168,7 +170,7 @@ async def test_policy_assignments_list(self, resource_group): async def test_policy_assignments_delete_by_id(self, resource_group): response = await self.client.policy_assignments.delete_by_id( policy_assignment_id="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -180,6 +182,7 @@ async def test_policy_assignments_create_by_id(self, resource_group): response = await self.client.policy_assignments.create_by_id( policy_assignment_id="str", parameters={ + "assignmentType": "str", "definitionVersion": "str", "description": "str", "displayName": "str", @@ -192,6 +195,7 @@ async def test_policy_assignments_create_by_id(self, resource_group): "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, + "instanceId": "str", "latestDefinitionVersion": "str", "location": "str", "metadata": {}, @@ -215,7 +219,7 @@ async def test_policy_assignments_create_by_id(self, resource_group): }, "type": "str", }, - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -226,7 +230,7 @@ async def test_policy_assignments_create_by_id(self, resource_group): async def test_policy_assignments_get_by_id(self, resource_group): response = await self.client.policy_assignments.get_by_id( policy_assignment_id="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -250,7 +254,7 @@ async def test_policy_assignments_update_by_id(self, resource_group): ], "resourceSelectors": [{"name": "str", "selectors": [{"in": ["str"], "kind": "str", "notIn": ["str"]}]}], }, - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself diff --git a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_definition_versions_operations.py b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_definition_versions_operations.py index 784e7081ae10..9e6208d6e6fe 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_definition_versions_operations.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_definition_versions_operations.py @@ -22,7 +22,30 @@ def setup_method(self, method): @recorded_by_proxy def test_policy_definition_versions_list_all_builtins(self, resource_group): response = self.client.policy_definition_versions.list_all_builtins( - api_version="2023-04-01", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_definition_versions_list_built_in(self, resource_group): + response = self.client.policy_definition_versions.list_built_in( + policy_definition_name="str", + api_version="2025-03-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_definition_versions_get_built_in(self, resource_group): + response = self.client.policy_definition_versions.get_built_in( + policy_definition_name="str", + policy_definition_version="str", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -33,7 +56,7 @@ def test_policy_definition_versions_list_all_builtins(self, resource_group): def test_policy_definition_versions_list_all_at_management_group(self, resource_group): response = self.client.policy_definition_versions.list_all_at_management_group( management_group_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -41,9 +64,24 @@ def test_policy_definition_versions_list_all_at_management_group(self, resource_ @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_definition_versions_list_all(self, resource_group): - response = self.client.policy_definition_versions.list_all( - api_version="2023-04-01", + def test_policy_definition_versions_list_by_management_group(self, resource_group): + response = self.client.policy_definition_versions.list_by_management_group( + management_group_name="str", + policy_definition_name="str", + api_version="2025-03-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_definition_versions_get_at_management_group(self, resource_group): + response = self.client.policy_definition_versions.get_at_management_group( + management_group_name="str", + policy_definition_name="str", + policy_definition_version="str", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -51,13 +89,20 @@ def test_policy_definition_versions_list_all(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_definition_versions_create_or_update(self, resource_group): - response = self.client.policy_definition_versions.create_or_update( + def test_policy_definition_versions_create_or_update_at_management_group(self, resource_group): + response = self.client.policy_definition_versions.create_or_update_at_management_group( + management_group_name="str", policy_definition_name="str", policy_definition_version="str", parameters={ "description": "str", "displayName": "str", + "externalEvaluationEnforcementSettings": { + "endpointSettings": {"details": {}, "kind": "str"}, + "missingTokenAction": "str", + "resultLifespan": "str", + "roleDefinitionIds": ["str"], + }, "id": "str", "metadata": {}, "mode": "Indexed", @@ -89,7 +134,7 @@ def test_policy_definition_versions_create_or_update(self, resource_group): "type": "str", "version": "str", }, - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -97,11 +142,12 @@ def test_policy_definition_versions_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_definition_versions_delete(self, resource_group): - response = self.client.policy_definition_versions.delete( + def test_policy_definition_versions_delete_at_management_group(self, resource_group): + response = self.client.policy_definition_versions.delete_at_management_group( + management_group_name="str", policy_definition_name="str", policy_definition_version="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -109,11 +155,9 @@ def test_policy_definition_versions_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_definition_versions_get(self, resource_group): - response = self.client.policy_definition_versions.get( - policy_definition_name="str", - policy_definition_version="str", - api_version="2023-04-01", + def test_policy_definition_versions_list_all(self, resource_group): + response = self.client.policy_definition_versions.list_all( + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -121,11 +165,22 @@ def test_policy_definition_versions_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_definition_versions_get_built_in(self, resource_group): - response = self.client.policy_definition_versions.get_built_in( + def test_policy_definition_versions_list(self, resource_group): + response = self.client.policy_definition_versions.list( + policy_definition_name="str", + api_version="2025-03-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_definition_versions_get(self, resource_group): + response = self.client.policy_definition_versions.get( policy_definition_name="str", policy_definition_version="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -133,14 +188,19 @@ def test_policy_definition_versions_get_built_in(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_definition_versions_create_or_update_at_management_group(self, resource_group): - response = self.client.policy_definition_versions.create_or_update_at_management_group( - management_group_name="str", + def test_policy_definition_versions_create_or_update(self, resource_group): + response = self.client.policy_definition_versions.create_or_update( policy_definition_name="str", policy_definition_version="str", parameters={ "description": "str", "displayName": "str", + "externalEvaluationEnforcementSettings": { + "endpointSettings": {"details": {}, "kind": "str"}, + "missingTokenAction": "str", + "resultLifespan": "str", + "roleDefinitionIds": ["str"], + }, "id": "str", "metadata": {}, "mode": "Indexed", @@ -172,7 +232,7 @@ def test_policy_definition_versions_create_or_update_at_management_group(self, r "type": "str", "version": "str", }, - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -180,60 +240,12 @@ def test_policy_definition_versions_create_or_update_at_management_group(self, r @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_definition_versions_delete_at_management_group(self, resource_group): - response = self.client.policy_definition_versions.delete_at_management_group( - management_group_name="str", - policy_definition_name="str", - policy_definition_version="str", - api_version="2023-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_definition_versions_get_at_management_group(self, resource_group): - response = self.client.policy_definition_versions.get_at_management_group( - management_group_name="str", + def test_policy_definition_versions_delete(self, resource_group): + response = self.client.policy_definition_versions.delete( policy_definition_name="str", policy_definition_version="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_definition_versions_list(self, resource_group): - response = self.client.policy_definition_versions.list( - policy_definition_name="str", - api_version="2023-04-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_definition_versions_list_built_in(self, resource_group): - response = self.client.policy_definition_versions.list_built_in( - policy_definition_name="str", - api_version="2023-04-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_definition_versions_list_by_management_group(self, resource_group): - response = self.client.policy_definition_versions.list_by_management_group( - management_group_name="str", - policy_definition_name="str", - api_version="2023-04-01", - ) - 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_definition_versions_operations_async.py b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_definition_versions_operations_async.py index 24f06e299437..c2c7b6a61b43 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_definition_versions_operations_async.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_definition_versions_operations_async.py @@ -23,7 +23,30 @@ def setup_method(self, method): @recorded_by_proxy_async async def test_policy_definition_versions_list_all_builtins(self, resource_group): response = await self.client.policy_definition_versions.list_all_builtins( - api_version="2023-04-01", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_definition_versions_list_built_in(self, resource_group): + response = self.client.policy_definition_versions.list_built_in( + policy_definition_name="str", + api_version="2025-03-01", + ) + 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_definition_versions_get_built_in(self, resource_group): + response = await self.client.policy_definition_versions.get_built_in( + policy_definition_name="str", + policy_definition_version="str", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -34,7 +57,7 @@ async def test_policy_definition_versions_list_all_builtins(self, resource_group async def test_policy_definition_versions_list_all_at_management_group(self, resource_group): response = await self.client.policy_definition_versions.list_all_at_management_group( management_group_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -42,9 +65,24 @@ async def test_policy_definition_versions_list_all_at_management_group(self, res @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_definition_versions_list_all(self, resource_group): - response = await self.client.policy_definition_versions.list_all( - api_version="2023-04-01", + async def test_policy_definition_versions_list_by_management_group(self, resource_group): + response = self.client.policy_definition_versions.list_by_management_group( + management_group_name="str", + policy_definition_name="str", + api_version="2025-03-01", + ) + 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_definition_versions_get_at_management_group(self, resource_group): + response = await self.client.policy_definition_versions.get_at_management_group( + management_group_name="str", + policy_definition_name="str", + policy_definition_version="str", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -52,13 +90,20 @@ async def test_policy_definition_versions_list_all(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_definition_versions_create_or_update(self, resource_group): - response = await self.client.policy_definition_versions.create_or_update( + async def test_policy_definition_versions_create_or_update_at_management_group(self, resource_group): + response = await self.client.policy_definition_versions.create_or_update_at_management_group( + management_group_name="str", policy_definition_name="str", policy_definition_version="str", parameters={ "description": "str", "displayName": "str", + "externalEvaluationEnforcementSettings": { + "endpointSettings": {"details": {}, "kind": "str"}, + "missingTokenAction": "str", + "resultLifespan": "str", + "roleDefinitionIds": ["str"], + }, "id": "str", "metadata": {}, "mode": "Indexed", @@ -90,7 +135,7 @@ async def test_policy_definition_versions_create_or_update(self, resource_group) "type": "str", "version": "str", }, - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -98,11 +143,12 @@ async def test_policy_definition_versions_create_or_update(self, resource_group) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_definition_versions_delete(self, resource_group): - response = await self.client.policy_definition_versions.delete( + async def test_policy_definition_versions_delete_at_management_group(self, resource_group): + response = await self.client.policy_definition_versions.delete_at_management_group( + management_group_name="str", policy_definition_name="str", policy_definition_version="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -110,11 +156,9 @@ async def test_policy_definition_versions_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_definition_versions_get(self, resource_group): - response = await self.client.policy_definition_versions.get( - policy_definition_name="str", - policy_definition_version="str", - api_version="2023-04-01", + async def test_policy_definition_versions_list_all(self, resource_group): + response = await self.client.policy_definition_versions.list_all( + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -122,11 +166,22 @@ async def test_policy_definition_versions_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_definition_versions_get_built_in(self, resource_group): - response = await self.client.policy_definition_versions.get_built_in( + async def test_policy_definition_versions_list(self, resource_group): + response = self.client.policy_definition_versions.list( + policy_definition_name="str", + api_version="2025-03-01", + ) + 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_definition_versions_get(self, resource_group): + response = await self.client.policy_definition_versions.get( policy_definition_name="str", policy_definition_version="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -134,14 +189,19 @@ async def test_policy_definition_versions_get_built_in(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_definition_versions_create_or_update_at_management_group(self, resource_group): - response = await self.client.policy_definition_versions.create_or_update_at_management_group( - management_group_name="str", + async def test_policy_definition_versions_create_or_update(self, resource_group): + response = await self.client.policy_definition_versions.create_or_update( policy_definition_name="str", policy_definition_version="str", parameters={ "description": "str", "displayName": "str", + "externalEvaluationEnforcementSettings": { + "endpointSettings": {"details": {}, "kind": "str"}, + "missingTokenAction": "str", + "resultLifespan": "str", + "roleDefinitionIds": ["str"], + }, "id": "str", "metadata": {}, "mode": "Indexed", @@ -173,7 +233,7 @@ async def test_policy_definition_versions_create_or_update_at_management_group(s "type": "str", "version": "str", }, - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -181,60 +241,12 @@ async def test_policy_definition_versions_create_or_update_at_management_group(s @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_definition_versions_delete_at_management_group(self, resource_group): - response = await self.client.policy_definition_versions.delete_at_management_group( - management_group_name="str", - policy_definition_name="str", - policy_definition_version="str", - api_version="2023-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_definition_versions_get_at_management_group(self, resource_group): - response = await self.client.policy_definition_versions.get_at_management_group( - management_group_name="str", + async def test_policy_definition_versions_delete(self, resource_group): + response = await self.client.policy_definition_versions.delete( policy_definition_name="str", policy_definition_version="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_definition_versions_list(self, resource_group): - response = self.client.policy_definition_versions.list( - policy_definition_name="str", - api_version="2023-04-01", - ) - 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_definition_versions_list_built_in(self, resource_group): - response = self.client.policy_definition_versions.list_built_in( - policy_definition_name="str", - api_version="2023-04-01", - ) - 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_definition_versions_list_by_management_group(self, resource_group): - response = self.client.policy_definition_versions.list_by_management_group( - management_group_name="str", - policy_definition_name="str", - api_version="2023-04-01", - ) - 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_definitions_operations.py b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_definitions_operations.py index 2b1965134aa6..be7cba1b047d 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_definitions_operations.py @@ -20,12 +20,63 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_definitions_create_or_update(self, resource_group): - response = self.client.policy_definitions.create_or_update( + def test_policy_definitions_list_built_in(self, resource_group): + response = self.client.policy_definitions.list_built_in( + api_version="2025-03-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_definitions_get_built_in(self, resource_group): + response = self.client.policy_definitions.get_built_in( + policy_definition_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_definitions_list_by_management_group(self, resource_group): + response = self.client.policy_definitions.list_by_management_group( + management_group_id="str", + api_version="2025-03-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_definitions_get_at_management_group(self, resource_group): + response = self.client.policy_definitions.get_at_management_group( + management_group_id="str", + policy_definition_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_definitions_create_or_update_at_management_group(self, resource_group): + response = self.client.policy_definitions.create_or_update_at_management_group( + management_group_id="str", policy_definition_name="str", parameters={ "description": "str", "displayName": "str", + "externalEvaluationEnforcementSettings": { + "endpointSettings": {"details": {}, "kind": "str"}, + "missingTokenAction": "str", + "resultLifespan": "str", + "roleDefinitionIds": ["str"], + }, "id": "str", "metadata": {}, "mode": "Indexed", @@ -58,7 +109,7 @@ def test_policy_definitions_create_or_update(self, resource_group): "version": "str", "versions": ["str"], }, - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -66,10 +117,11 @@ def test_policy_definitions_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_definitions_delete(self, resource_group): - response = self.client.policy_definitions.delete( + def test_policy_definitions_delete_at_management_group(self, resource_group): + response = self.client.policy_definitions.delete_at_management_group( + management_group_id="str", policy_definition_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -77,21 +129,20 @@ def test_policy_definitions_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_definitions_get(self, resource_group): - response = self.client.policy_definitions.get( - policy_definition_name="str", - api_version="2023-04-01", + def test_policy_definitions_list(self, resource_group): + response = self.client.policy_definitions.list( + api_version="2025-03-01", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_definitions_get_built_in(self, resource_group): - response = self.client.policy_definitions.get_built_in( + def test_policy_definitions_get(self, resource_group): + response = self.client.policy_definitions.get( policy_definition_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -99,13 +150,18 @@ def test_policy_definitions_get_built_in(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_definitions_create_or_update_at_management_group(self, resource_group): - response = self.client.policy_definitions.create_or_update_at_management_group( - management_group_id="str", + def test_policy_definitions_create_or_update(self, resource_group): + response = self.client.policy_definitions.create_or_update( policy_definition_name="str", parameters={ "description": "str", "displayName": "str", + "externalEvaluationEnforcementSettings": { + "endpointSettings": {"details": {}, "kind": "str"}, + "missingTokenAction": "str", + "resultLifespan": "str", + "roleDefinitionIds": ["str"], + }, "id": "str", "metadata": {}, "mode": "Indexed", @@ -138,19 +194,7 @@ def test_policy_definitions_create_or_update_at_management_group(self, resource_ "version": "str", "versions": ["str"], }, - api_version="2023-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_definitions_delete_at_management_group(self, resource_group): - response = self.client.policy_definitions.delete_at_management_group( - management_group_id="str", - policy_definition_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -158,43 +202,11 @@ def test_policy_definitions_delete_at_management_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_definitions_get_at_management_group(self, resource_group): - response = self.client.policy_definitions.get_at_management_group( - management_group_id="str", + def test_policy_definitions_delete(self, resource_group): + response = self.client.policy_definitions.delete( policy_definition_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_definitions_list(self, resource_group): - response = self.client.policy_definitions.list( - api_version="2023-04-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_definitions_list_built_in(self, resource_group): - response = self.client.policy_definitions.list_built_in( - api_version="2023-04-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_definitions_list_by_management_group(self, resource_group): - response = self.client.policy_definitions.list_by_management_group( - management_group_id="str", - api_version="2023-04-01", - ) - 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_definitions_operations_async.py b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_definitions_operations_async.py index bbec542c33e9..c8020bc9ef0e 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_definitions_operations_async.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_definitions_operations_async.py @@ -21,12 +21,63 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_definitions_create_or_update(self, resource_group): - response = await self.client.policy_definitions.create_or_update( + async def test_policy_definitions_list_built_in(self, resource_group): + response = self.client.policy_definitions.list_built_in( + api_version="2025-03-01", + ) + 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_definitions_get_built_in(self, resource_group): + response = await self.client.policy_definitions.get_built_in( + policy_definition_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_definitions_list_by_management_group(self, resource_group): + response = self.client.policy_definitions.list_by_management_group( + management_group_id="str", + api_version="2025-03-01", + ) + 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_definitions_get_at_management_group(self, resource_group): + response = await self.client.policy_definitions.get_at_management_group( + management_group_id="str", + policy_definition_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_definitions_create_or_update_at_management_group(self, resource_group): + response = await self.client.policy_definitions.create_or_update_at_management_group( + management_group_id="str", policy_definition_name="str", parameters={ "description": "str", "displayName": "str", + "externalEvaluationEnforcementSettings": { + "endpointSettings": {"details": {}, "kind": "str"}, + "missingTokenAction": "str", + "resultLifespan": "str", + "roleDefinitionIds": ["str"], + }, "id": "str", "metadata": {}, "mode": "Indexed", @@ -59,7 +110,7 @@ async def test_policy_definitions_create_or_update(self, resource_group): "version": "str", "versions": ["str"], }, - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -67,10 +118,11 @@ async def test_policy_definitions_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_definitions_delete(self, resource_group): - response = await self.client.policy_definitions.delete( + async def test_policy_definitions_delete_at_management_group(self, resource_group): + response = await self.client.policy_definitions.delete_at_management_group( + management_group_id="str", policy_definition_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -78,21 +130,20 @@ async def test_policy_definitions_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_definitions_get(self, resource_group): - response = await self.client.policy_definitions.get( - policy_definition_name="str", - api_version="2023-04-01", + async def test_policy_definitions_list(self, resource_group): + response = self.client.policy_definitions.list( + api_version="2025-03-01", ) - + 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_definitions_get_built_in(self, resource_group): - response = await self.client.policy_definitions.get_built_in( + async def test_policy_definitions_get(self, resource_group): + response = await self.client.policy_definitions.get( policy_definition_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -100,13 +151,18 @@ async def test_policy_definitions_get_built_in(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_definitions_create_or_update_at_management_group(self, resource_group): - response = await self.client.policy_definitions.create_or_update_at_management_group( - management_group_id="str", + async def test_policy_definitions_create_or_update(self, resource_group): + response = await self.client.policy_definitions.create_or_update( policy_definition_name="str", parameters={ "description": "str", "displayName": "str", + "externalEvaluationEnforcementSettings": { + "endpointSettings": {"details": {}, "kind": "str"}, + "missingTokenAction": "str", + "resultLifespan": "str", + "roleDefinitionIds": ["str"], + }, "id": "str", "metadata": {}, "mode": "Indexed", @@ -139,19 +195,7 @@ async def test_policy_definitions_create_or_update_at_management_group(self, res "version": "str", "versions": ["str"], }, - api_version="2023-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_definitions_delete_at_management_group(self, resource_group): - response = await self.client.policy_definitions.delete_at_management_group( - management_group_id="str", - policy_definition_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -159,43 +203,11 @@ async def test_policy_definitions_delete_at_management_group(self, resource_grou @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_definitions_get_at_management_group(self, resource_group): - response = await self.client.policy_definitions.get_at_management_group( - management_group_id="str", + async def test_policy_definitions_delete(self, resource_group): + response = await self.client.policy_definitions.delete( policy_definition_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_definitions_list(self, resource_group): - response = self.client.policy_definitions.list( - api_version="2023-04-01", - ) - 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_definitions_list_built_in(self, resource_group): - response = self.client.policy_definitions.list_built_in( - api_version="2023-04-01", - ) - 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_definitions_list_by_management_group(self, resource_group): - response = self.client.policy_definitions.list_by_management_group( - management_group_id="str", - api_version="2023-04-01", - ) - 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_set_definition_versions_operations.py b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_set_definition_versions_operations.py index 62b7d7194bf4..b45dd92edb26 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_set_definition_versions_operations.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_set_definition_versions_operations.py @@ -22,7 +22,30 @@ def setup_method(self, method): @recorded_by_proxy def test_policy_set_definition_versions_list_all_builtins(self, resource_group): response = self.client.policy_set_definition_versions.list_all_builtins( - api_version="2023-04-01", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_set_definition_versions_list_built_in(self, resource_group): + response = self.client.policy_set_definition_versions.list_built_in( + policy_set_definition_name="str", + api_version="2025-03-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_set_definition_versions_get_built_in(self, resource_group): + response = self.client.policy_set_definition_versions.get_built_in( + policy_set_definition_name="str", + policy_definition_version="str", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -33,7 +56,7 @@ def test_policy_set_definition_versions_list_all_builtins(self, resource_group): def test_policy_set_definition_versions_list_all_at_management_group(self, resource_group): response = self.client.policy_set_definition_versions.list_all_at_management_group( management_group_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -41,9 +64,24 @@ def test_policy_set_definition_versions_list_all_at_management_group(self, resou @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_set_definition_versions_list_all(self, resource_group): - response = self.client.policy_set_definition_versions.list_all( - api_version="2023-04-01", + def test_policy_set_definition_versions_list_by_management_group(self, resource_group): + response = self.client.policy_set_definition_versions.list_by_management_group( + management_group_name="str", + policy_set_definition_name="str", + api_version="2025-03-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_set_definition_versions_get_at_management_group(self, resource_group): + response = self.client.policy_set_definition_versions.get_at_management_group( + management_group_name="str", + policy_set_definition_name="str", + policy_definition_version="str", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -51,8 +89,9 @@ def test_policy_set_definition_versions_list_all(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_set_definition_versions_create_or_update(self, resource_group): - response = self.client.policy_set_definition_versions.create_or_update( + def test_policy_set_definition_versions_create_or_update_at_management_group(self, resource_group): + response = self.client.policy_set_definition_versions.create_or_update_at_management_group( + management_group_name="str", policy_set_definition_name="str", policy_definition_version="str", parameters={ @@ -107,19 +146,7 @@ def test_policy_set_definition_versions_create_or_update(self, resource_group): "type": "str", "version": "str", }, - api_version="2023-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_set_definition_versions_delete(self, resource_group): - response = self.client.policy_set_definition_versions.delete( - policy_set_definition_name="str", - policy_definition_version="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -127,11 +154,12 @@ def test_policy_set_definition_versions_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_set_definition_versions_get(self, resource_group): - response = self.client.policy_set_definition_versions.get( + def test_policy_set_definition_versions_delete_at_management_group(self, resource_group): + response = self.client.policy_set_definition_versions.delete_at_management_group( + management_group_name="str", policy_set_definition_name="str", policy_definition_version="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -139,11 +167,9 @@ def test_policy_set_definition_versions_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_set_definition_versions_get_built_in(self, resource_group): - response = self.client.policy_set_definition_versions.get_built_in( - policy_set_definition_name="str", - policy_definition_version="str", - api_version="2023-04-01", + def test_policy_set_definition_versions_list_all(self, resource_group): + response = self.client.policy_set_definition_versions.list_all( + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -154,7 +180,7 @@ def test_policy_set_definition_versions_get_built_in(self, resource_group): def test_policy_set_definition_versions_list(self, resource_group): response = self.client.policy_set_definition_versions.list( policy_set_definition_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -162,20 +188,20 @@ def test_policy_set_definition_versions_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_set_definition_versions_list_built_in(self, resource_group): - response = self.client.policy_set_definition_versions.list_built_in( + def test_policy_set_definition_versions_get(self, resource_group): + response = self.client.policy_set_definition_versions.get( policy_set_definition_name="str", - api_version="2023-04-01", + policy_definition_version="str", + api_version="2025-03-01", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_set_definition_versions_create_or_update_at_management_group(self, resource_group): - response = self.client.policy_set_definition_versions.create_or_update_at_management_group( - management_group_name="str", + def test_policy_set_definition_versions_create_or_update(self, resource_group): + response = self.client.policy_set_definition_versions.create_or_update( policy_set_definition_name="str", policy_definition_version="str", parameters={ @@ -230,7 +256,7 @@ def test_policy_set_definition_versions_create_or_update_at_management_group(sel "type": "str", "version": "str", }, - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -238,38 +264,12 @@ def test_policy_set_definition_versions_create_or_update_at_management_group(sel @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_set_definition_versions_delete_at_management_group(self, resource_group): - response = self.client.policy_set_definition_versions.delete_at_management_group( - management_group_name="str", - policy_set_definition_name="str", - policy_definition_version="str", - api_version="2023-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_set_definition_versions_get_at_management_group(self, resource_group): - response = self.client.policy_set_definition_versions.get_at_management_group( - management_group_name="str", + def test_policy_set_definition_versions_delete(self, resource_group): + response = self.client.policy_set_definition_versions.delete( policy_set_definition_name="str", policy_definition_version="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_set_definition_versions_list_by_management_group(self, resource_group): - response = self.client.policy_set_definition_versions.list_by_management_group( - management_group_name="str", - policy_set_definition_name="str", - api_version="2023-04-01", - ) - 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_set_definition_versions_operations_async.py b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_set_definition_versions_operations_async.py index 8bcf4cb39fb2..946a85186252 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_set_definition_versions_operations_async.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_set_definition_versions_operations_async.py @@ -23,7 +23,30 @@ def setup_method(self, method): @recorded_by_proxy_async async def test_policy_set_definition_versions_list_all_builtins(self, resource_group): response = await self.client.policy_set_definition_versions.list_all_builtins( - api_version="2023-04-01", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_set_definition_versions_list_built_in(self, resource_group): + response = self.client.policy_set_definition_versions.list_built_in( + policy_set_definition_name="str", + api_version="2025-03-01", + ) + 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_set_definition_versions_get_built_in(self, resource_group): + response = await self.client.policy_set_definition_versions.get_built_in( + policy_set_definition_name="str", + policy_definition_version="str", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -34,7 +57,7 @@ async def test_policy_set_definition_versions_list_all_builtins(self, resource_g async def test_policy_set_definition_versions_list_all_at_management_group(self, resource_group): response = await self.client.policy_set_definition_versions.list_all_at_management_group( management_group_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -42,9 +65,24 @@ async def test_policy_set_definition_versions_list_all_at_management_group(self, @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_set_definition_versions_list_all(self, resource_group): - response = await self.client.policy_set_definition_versions.list_all( - api_version="2023-04-01", + async def test_policy_set_definition_versions_list_by_management_group(self, resource_group): + response = self.client.policy_set_definition_versions.list_by_management_group( + management_group_name="str", + policy_set_definition_name="str", + api_version="2025-03-01", + ) + 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_set_definition_versions_get_at_management_group(self, resource_group): + response = await self.client.policy_set_definition_versions.get_at_management_group( + management_group_name="str", + policy_set_definition_name="str", + policy_definition_version="str", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -52,8 +90,9 @@ async def test_policy_set_definition_versions_list_all(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_set_definition_versions_create_or_update(self, resource_group): - response = await self.client.policy_set_definition_versions.create_or_update( + async def test_policy_set_definition_versions_create_or_update_at_management_group(self, resource_group): + response = await self.client.policy_set_definition_versions.create_or_update_at_management_group( + management_group_name="str", policy_set_definition_name="str", policy_definition_version="str", parameters={ @@ -108,19 +147,7 @@ async def test_policy_set_definition_versions_create_or_update(self, resource_gr "type": "str", "version": "str", }, - api_version="2023-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_set_definition_versions_delete(self, resource_group): - response = await self.client.policy_set_definition_versions.delete( - policy_set_definition_name="str", - policy_definition_version="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -128,11 +155,12 @@ async def test_policy_set_definition_versions_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_set_definition_versions_get(self, resource_group): - response = await self.client.policy_set_definition_versions.get( + async def test_policy_set_definition_versions_delete_at_management_group(self, resource_group): + response = await self.client.policy_set_definition_versions.delete_at_management_group( + management_group_name="str", policy_set_definition_name="str", policy_definition_version="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -140,11 +168,9 @@ async def test_policy_set_definition_versions_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_set_definition_versions_get_built_in(self, resource_group): - response = await self.client.policy_set_definition_versions.get_built_in( - policy_set_definition_name="str", - policy_definition_version="str", - api_version="2023-04-01", + async def test_policy_set_definition_versions_list_all(self, resource_group): + response = await self.client.policy_set_definition_versions.list_all( + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -155,7 +181,7 @@ async def test_policy_set_definition_versions_get_built_in(self, resource_group) async def test_policy_set_definition_versions_list(self, resource_group): response = self.client.policy_set_definition_versions.list( policy_set_definition_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -163,20 +189,20 @@ async def test_policy_set_definition_versions_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_set_definition_versions_list_built_in(self, resource_group): - response = self.client.policy_set_definition_versions.list_built_in( + async def test_policy_set_definition_versions_get(self, resource_group): + response = await self.client.policy_set_definition_versions.get( policy_set_definition_name="str", - api_version="2023-04-01", + policy_definition_version="str", + api_version="2025-03-01", ) - 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_set_definition_versions_create_or_update_at_management_group(self, resource_group): - response = await self.client.policy_set_definition_versions.create_or_update_at_management_group( - management_group_name="str", + async def test_policy_set_definition_versions_create_or_update(self, resource_group): + response = await self.client.policy_set_definition_versions.create_or_update( policy_set_definition_name="str", policy_definition_version="str", parameters={ @@ -231,7 +257,7 @@ async def test_policy_set_definition_versions_create_or_update_at_management_gro "type": "str", "version": "str", }, - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -239,38 +265,12 @@ async def test_policy_set_definition_versions_create_or_update_at_management_gro @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_set_definition_versions_delete_at_management_group(self, resource_group): - response = await self.client.policy_set_definition_versions.delete_at_management_group( - management_group_name="str", - policy_set_definition_name="str", - policy_definition_version="str", - api_version="2023-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_set_definition_versions_get_at_management_group(self, resource_group): - response = await self.client.policy_set_definition_versions.get_at_management_group( - management_group_name="str", + async def test_policy_set_definition_versions_delete(self, resource_group): + response = await self.client.policy_set_definition_versions.delete( policy_set_definition_name="str", policy_definition_version="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_set_definition_versions_list_by_management_group(self, resource_group): - response = self.client.policy_set_definition_versions.list_by_management_group( - management_group_name="str", - policy_set_definition_name="str", - api_version="2023-04-01", - ) - 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_set_definitions_operations.py b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_set_definitions_operations.py index 640d2c73344f..e46765fd7a9e 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_set_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_set_definitions_operations.py @@ -20,8 +20,53 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_set_definitions_create_or_update(self, resource_group): - response = self.client.policy_set_definitions.create_or_update( + def test_policy_set_definitions_list_built_in(self, resource_group): + response = self.client.policy_set_definitions.list_built_in( + api_version="2025-03-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_set_definitions_get_built_in(self, resource_group): + response = self.client.policy_set_definitions.get_built_in( + policy_set_definition_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_set_definitions_list_by_management_group(self, resource_group): + response = self.client.policy_set_definitions.list_by_management_group( + management_group_id="str", + api_version="2025-03-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_set_definitions_get_at_management_group(self, resource_group): + response = self.client.policy_set_definitions.get_at_management_group( + management_group_id="str", + policy_set_definition_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_set_definitions_create_or_update_at_management_group(self, resource_group): + response = self.client.policy_set_definitions.create_or_update_at_management_group( + management_group_id="str", policy_set_definition_name="str", parameters={ "description": "str", @@ -76,29 +121,7 @@ def test_policy_set_definitions_create_or_update(self, resource_group): "version": "str", "versions": ["str"], }, - api_version="2023-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_set_definitions_delete(self, resource_group): - response = self.client.policy_set_definitions.delete( - policy_set_definition_name="str", - api_version="2023-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_set_definitions_get(self, resource_group): - response = self.client.policy_set_definitions.get( - policy_set_definition_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -106,10 +129,11 @@ def test_policy_set_definitions_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_set_definitions_get_built_in(self, resource_group): - response = self.client.policy_set_definitions.get_built_in( + def test_policy_set_definitions_delete_at_management_group(self, resource_group): + response = self.client.policy_set_definitions.delete_at_management_group( + management_group_id="str", policy_set_definition_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -119,7 +143,7 @@ def test_policy_set_definitions_get_built_in(self, resource_group): @recorded_by_proxy def test_policy_set_definitions_list(self, resource_group): response = self.client.policy_set_definitions.list( - api_version="2023-04-01", + api_version="2025-03-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -127,19 +151,19 @@ def test_policy_set_definitions_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_set_definitions_list_built_in(self, resource_group): - response = self.client.policy_set_definitions.list_built_in( - api_version="2023-04-01", + def test_policy_set_definitions_get(self, resource_group): + response = self.client.policy_set_definitions.get( + policy_set_definition_name="str", + api_version="2025-03-01", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_set_definitions_create_or_update_at_management_group(self, resource_group): - response = self.client.policy_set_definitions.create_or_update_at_management_group( - management_group_id="str", + def test_policy_set_definitions_create_or_update(self, resource_group): + response = self.client.policy_set_definitions.create_or_update( policy_set_definition_name="str", parameters={ "description": "str", @@ -194,19 +218,7 @@ def test_policy_set_definitions_create_or_update_at_management_group(self, resou "version": "str", "versions": ["str"], }, - api_version="2023-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_set_definitions_delete_at_management_group(self, resource_group): - response = self.client.policy_set_definitions.delete_at_management_group( - management_group_id="str", - policy_set_definition_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -214,23 +226,11 @@ def test_policy_set_definitions_delete_at_management_group(self, resource_group) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_set_definitions_get_at_management_group(self, resource_group): - response = self.client.policy_set_definitions.get_at_management_group( - management_group_id="str", + def test_policy_set_definitions_delete(self, resource_group): + response = self.client.policy_set_definitions.delete( policy_set_definition_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_set_definitions_list_by_management_group(self, resource_group): - response = self.client.policy_set_definitions.list_by_management_group( - management_group_id="str", - api_version="2023-04-01", - ) - 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_set_definitions_operations_async.py b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_set_definitions_operations_async.py index f1fdf201e272..68e34ddaf7da 100644 --- a/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_set_definitions_operations_async.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_set_definitions_operations_async.py @@ -21,8 +21,53 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_set_definitions_create_or_update(self, resource_group): - response = await self.client.policy_set_definitions.create_or_update( + async def test_policy_set_definitions_list_built_in(self, resource_group): + response = self.client.policy_set_definitions.list_built_in( + api_version="2025-03-01", + ) + 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_set_definitions_get_built_in(self, resource_group): + response = await self.client.policy_set_definitions.get_built_in( + policy_set_definition_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_set_definitions_list_by_management_group(self, resource_group): + response = self.client.policy_set_definitions.list_by_management_group( + management_group_id="str", + api_version="2025-03-01", + ) + 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_set_definitions_get_at_management_group(self, resource_group): + response = await self.client.policy_set_definitions.get_at_management_group( + management_group_id="str", + policy_set_definition_name="str", + api_version="2025-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_set_definitions_create_or_update_at_management_group(self, resource_group): + response = await self.client.policy_set_definitions.create_or_update_at_management_group( + management_group_id="str", policy_set_definition_name="str", parameters={ "description": "str", @@ -77,29 +122,7 @@ async def test_policy_set_definitions_create_or_update(self, resource_group): "version": "str", "versions": ["str"], }, - api_version="2023-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_set_definitions_delete(self, resource_group): - response = await self.client.policy_set_definitions.delete( - policy_set_definition_name="str", - api_version="2023-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_set_definitions_get(self, resource_group): - response = await self.client.policy_set_definitions.get( - policy_set_definition_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -107,10 +130,11 @@ async def test_policy_set_definitions_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_set_definitions_get_built_in(self, resource_group): - response = await self.client.policy_set_definitions.get_built_in( + async def test_policy_set_definitions_delete_at_management_group(self, resource_group): + response = await self.client.policy_set_definitions.delete_at_management_group( + management_group_id="str", policy_set_definition_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -120,7 +144,7 @@ async def test_policy_set_definitions_get_built_in(self, resource_group): @recorded_by_proxy_async async def test_policy_set_definitions_list(self, resource_group): response = self.client.policy_set_definitions.list( - api_version="2023-04-01", + api_version="2025-03-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -128,19 +152,19 @@ async def test_policy_set_definitions_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_set_definitions_list_built_in(self, resource_group): - response = self.client.policy_set_definitions.list_built_in( - api_version="2023-04-01", + async def test_policy_set_definitions_get(self, resource_group): + response = await self.client.policy_set_definitions.get( + policy_set_definition_name="str", + api_version="2025-03-01", ) - 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_set_definitions_create_or_update_at_management_group(self, resource_group): - response = await self.client.policy_set_definitions.create_or_update_at_management_group( - management_group_id="str", + async def test_policy_set_definitions_create_or_update(self, resource_group): + response = await self.client.policy_set_definitions.create_or_update( policy_set_definition_name="str", parameters={ "description": "str", @@ -195,19 +219,7 @@ async def test_policy_set_definitions_create_or_update_at_management_group(self, "version": "str", "versions": ["str"], }, - api_version="2023-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_set_definitions_delete_at_management_group(self, resource_group): - response = await self.client.policy_set_definitions.delete_at_management_group( - management_group_id="str", - policy_set_definition_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself @@ -215,23 +227,11 @@ async def test_policy_set_definitions_delete_at_management_group(self, resource_ @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_set_definitions_get_at_management_group(self, resource_group): - response = await self.client.policy_set_definitions.get_at_management_group( - management_group_id="str", + async def test_policy_set_definitions_delete(self, resource_group): + response = await self.client.policy_set_definitions.delete( policy_set_definition_name="str", - api_version="2023-04-01", + api_version="2025-03-01", ) # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_policy_set_definitions_list_by_management_group(self, resource_group): - response = self.client.policy_set_definitions.list_by_management_group( - management_group_id="str", - api_version="2023-04-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/resources/azure-mgmt-resource-policy/tests/test_policy_policy_exemptions_operations_test.py b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_tokens_operations.py similarity index 51% rename from sdk/resources/azure-mgmt-resource-policy/tests/test_policy_policy_exemptions_operations_test.py rename to sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_tokens_operations.py index 3d078607ddfc..a17ed23998a5 100644 --- a/sdk/resources/azure-mgmt-resource-policy/tests/test_policy_policy_exemptions_operations_test.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_tokens_operations.py @@ -13,23 +13,30 @@ AZURE_LOCATION = "eastus" -@pytest.mark.live_test_only -class TestPolicyPolicyExemptionsOperations(AzureMgmtRecordedTestCase): +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPolicyPolicyTokensOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(PolicyClient) @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] - assert response + def test_policy_tokens_acquire_at_management_group(self, resource_group): + response = self.client.policy_tokens.acquire_at_management_group( + management_group_name="str", + parameters={"operation": {"httpMethod": "str", "uri": "str", "content": {}}, "changeReference": "str"}, + api_version="2025-03-01", + ) + + # 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, + def test_policy_tokens_acquire(self, resource_group): + response = self.client.policy_tokens.acquire( + parameters={"operation": {"httpMethod": "str", "uri": "str", "content": {}}, "changeReference": "str"}, + api_version="2025-03-01", ) - result = [r for r in response] - assert response + + # please add some check logic here by yourself + # ... diff --git a/sdk/resources/azure-mgmt-resource-policy/tests/test_policy_policy_exemptions_operations_async_test.py b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_tokens_operations_async.py similarity index 52% rename from sdk/resources/azure-mgmt-resource-policy/tests/test_policy_policy_exemptions_operations_async_test.py rename to sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_tokens_operations_async.py index dc2337c35ac7..31203136ed8c 100644 --- a/sdk/resources/azure-mgmt-resource-policy/tests/test_policy_policy_exemptions_operations_async_test.py +++ b/sdk/resources/azure-mgmt-resource-policy/generated_tests/test_policy_policy_tokens_operations_async.py @@ -14,23 +14,30 @@ AZURE_LOCATION = "eastus" -@pytest.mark.live_test_only -class TestPolicyPolicyExemptionsOperationsAsync(AzureMgmtRecordedTestCase): +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPolicyPolicyTokensOperationsAsync(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_list(self, resource_group): - response = self.client.policy_exemptions.list() - result = [r async for r in response] - assert response + async def test_policy_tokens_acquire_at_management_group(self, resource_group): + response = await self.client.policy_tokens.acquire_at_management_group( + management_group_name="str", + parameters={"operation": {"httpMethod": "str", "uri": "str", "content": {}}, "changeReference": "str"}, + api_version="2025-03-01", + ) + + # 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, + async def test_policy_tokens_acquire(self, resource_group): + response = await self.client.policy_tokens.acquire( + parameters={"operation": {"httpMethod": "str", "uri": "str", "content": {}}, "changeReference": "str"}, + api_version="2025-03-01", ) - result = [r async for r in response] - assert response + + # please add some check logic here by yourself + # ... diff --git a/sdk/resources/azure-mgmt-resource-policy/tests/test_policy_variables_operations_async_test.py b/sdk/resources/azure-mgmt-resource-policy/tests/test_policy_variables_operations_async_test.py deleted file mode 100644 index 9682e9c9c549..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/tests/test_policy_variables_operations_async_test.py +++ /dev/null @@ -1,27 +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) AutoRest 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.live_test_only -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_list(self, resource_group): - response = self.client.variables.list() - result = [r async for r in response] - assert response diff --git a/sdk/resources/azure-mgmt-resource-policy/tests/test_policy_variables_operations_test.py b/sdk/resources/azure-mgmt-resource-policy/tests/test_policy_variables_operations_test.py deleted file mode 100644 index e70731415786..000000000000 --- a/sdk/resources/azure-mgmt-resource-policy/tests/test_policy_variables_operations_test.py +++ /dev/null @@ -1,26 +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) AutoRest 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.live_test_only -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_list(self, resource_group): - response = self.client.variables.list() - result = [r for r in response] - assert response